Commit graph

53 commits

Author SHA1 Message Date
erik
c8456d57ff Add thoughts on user creation 2024-02-10 15:09:54 +01:00
erik
22ba03ae4d Don't use redundant implementation of person 2024-02-10 15:09:51 +01:00
erik
a8d5e7ba77 Fix typos and format 2024-02-10 15:09:41 +01:00
erik
d43c4ba739 Use person generation 2024-02-10 15:09:38 +01:00
erik
9f016d3673 Move to extra var 2024-02-10 15:09:37 +01:00
erik
fde8de4f90 Rename to ParseActorIDFromStarActivity 2024-02-10 15:09:35 +01:00
erik
e60d89cb67 Use correct target for get request 2024-02-10 15:09:33 +01:00
erik
0388240039 WIP Use non generated HTTP client 2024-02-10 15:09:32 +01:00
erik
6284355e1e Remove redundant ValidateStar and err check, call coorect function 2024-02-10 15:09:29 +01:00
erik
546ce50337 Use PanicIfInvalid in repository.go 2024-02-10 15:09:27 +01:00
erik
8300d3fbde Add ToDos from code review 2024-02-10 15:09:25 +01:00
erik
34c511ae98 Use data from actor, improve formatting 2024-02-10 15:09:24 +01:00
erik
aee2ee2596 Also log error on person creation 2024-02-10 15:09:24 +01:00
erik
3d2b5115ad Implement and use Validatable interface 2024-02-10 15:09:18 +01:00
erik
235ed7cd1e Rename to actorID 2024-02-10 15:09:18 +01:00
Michael Jerger
5e111f14ef use the swagger-api 2024-02-10 15:09:17 +01:00
Michael Jerger
5c998a5c46 add comment 2024-02-10 15:09:08 +01:00
erik
5729cee3e5 Move test to model/activitypub 2024-02-10 15:09:07 +01:00
erik
7193c0bd9b WIP test for parsing the actor 2024-02-10 15:09:07 +01:00
erik
0c367070af Call validate star 2024-02-10 15:09:06 +01:00
erik
78fc75135f Rename to ActorData 2024-02-10 15:09:04 +01:00
erik
91dcd59e68 Import parser from model and call validation 2024-02-10 15:09:00 +01:00
erik
e44321221e WIP: Add test for parser 2024-02-10 15:08:55 +01:00
erik
ad65976677 Reorder functions 2024-02-10 15:08:54 +01:00
erik
d52bb4bf8f Remove newline from error string 2024-02-10 15:08:52 +01:00
erik
b869d91dc1 Parse Actor URL 2024-02-10 15:08:51 +01:00
erik
9fa8d19cf4 Fix typo 2024-02-10 15:08:47 +01:00
Michael Jerger
d10c1094d9 add some pseudocode 2024-02-10 15:08:45 +01:00
erik
ab92891091 Use actor 2024-02-10 15:08:41 +01:00
erik
f48b4d1f55 Get Activity field from star 2024-02-10 15:08:29 +01:00
Michael Jerger
1044e44ee5 we got a parsed actor 2024-02-10 15:08:12 +01:00
Michael Jerger
b08580280a np in case of unauthenticated user 2024-02-10 15:08:10 +01:00
Michael Jerger
460e2fb644 prepare next steps 2024-02-10 15:08:00 +01:00
erik
5b01517c12 Get data from form 2024-02-10 15:08:00 +01:00
Michael Jerger
dc1a82bf4c use star as swagger model 2024-02-10 15:07:48 +01:00
Michael Jerger
ff5a4405fd introduce repo from exosy 2024-02-10 15:07:39 +01:00
Michael Jerger
6587b6d62b log who is doing the inbox post 2024-02-10 15:07:28 +01:00
Michael Jerger
4e1e65e14f log repository under activity 2024-02-10 15:07:26 +01:00
Michael Jerger
0d5702e501 fill in some minimal information to an actor 2024-02-10 15:07:20 +01:00
Michael Jerger
fe2a3d86d4 get repo now works somehow 2024-02-10 15:07:14 +01:00
Michael Jerger
64abf87fb0 added some logs 2024-02-10 15:07:11 +01:00
Michael Jerger
317b7fac8f wip: load repo to ctx 2024-02-10 15:07:05 +01:00
Michael Jerger
d4f507a223 remove unused imports 2024-02-10 15:07:04 +01:00
Michael Jerger
a87cbda165 add repository actor 2024-02-10 15:07:03 +01:00
JakobDev
c548dde205
More refactoring of db.DefaultContext (#27083)
Next step of #27065
2023-09-15 06:13:19 +00:00
silverwind
887a683af9
Update tool dependencies, lock govulncheck and actionlint (#25655)
- Update all tool dependencies
- Lock `govulncheck` and `actionlint` to their latest tags

---------

Co-authored-by: 6543 <m.huber@kithara.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2023-07-09 11:58:06 +00:00
wxiaoguang
17f23182ff
Use User.ID instead of User.Name in ActivityPub API for Person IRI (#23823)
Thanks to @trwnh

Close #23802

The ActivityPub id is an HTTPS URI that should remain constant, even if
the user changes their name.
2023-04-04 10:08:23 +08:00
Lunny Xiao
bd820aa9c5
Add context cache as a request level cache (#22294)
To avoid duplicated load of the same data in an HTTP request, we can set
a context cache to do that. i.e. Some pages may load a user from a
database with the same id in different areas on the same page. But the
code is hidden in two different deep logic. How should we share the
user? As a result of this PR, now if both entry functions accept
`context.Context` as the first parameter and we just need to refactor
`GetUserByID` to reuse the user from the context cache. Then it will not
be loaded twice on an HTTP request.

But of course, sometimes we would like to reload an object from the
database, that's why `RemoveContextData` is also exposed.

The core context cache is here. It defines a new context
```go
type cacheContext struct {
	ctx  context.Context
	data map[any]map[any]any
        lock sync.RWMutex
}

var cacheContextKey = struct{}{}

func WithCacheContext(ctx context.Context) context.Context {
	return context.WithValue(ctx, cacheContextKey, &cacheContext{
		ctx:  ctx,
		data: make(map[any]map[any]any),
	})
}
```

Then you can use the below 4 methods to read/write/del the data within
the same context.

```go
func GetContextData(ctx context.Context, tp, key any) any
func SetContextData(ctx context.Context, tp, key, value any)
func RemoveContextData(ctx context.Context, tp, key any)
func GetWithContextCache[T any](ctx context.Context, cacheGroupKey string, cacheTargetID any, f func() (T, error)) (T, error)
```

Then let's take a look at how `system.GetString` implement it.

```go
func GetSetting(ctx context.Context, key string) (string, error) {
	return cache.GetWithContextCache(ctx, contextCacheKey, key, func() (string, error) {
		return cache.GetString(genSettingCacheKey(key), func() (string, error) {
			res, err := GetSettingNoCache(ctx, key)
			if err != nil {
				return "", err
			}
			return res.SettingValue, nil
		})
	})
}
```

First, it will check if context data include the setting object with the
key. If not, it will query from the global cache which may be memory or
a Redis cache. If not, it will get the object from the database. In the
end, if the object gets from the global cache or database, it will be
set into the context cache.

An object stored in the context cache will only be destroyed after the
context disappeared.
2023-02-15 21:37:34 +08:00
flynnnnnnnnnn
e81ccc406b
Implement FSFE REUSE for golang files (#21840)
Change all license headers to comply with REUSE specification.

Fix #16132

Co-authored-by: flynnnnnnnnnn <flynnnnnnnnnn@github>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2022-11-27 18:20:29 +00:00
delvh
0ebb45cfe7
Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551)
Found using
`find . -type f -name '*.go' -print -exec vim {} -c
':%s/fmt\.Errorf(\(.*\)%v\(.*\)err/fmt.Errorf(\1%w\2err/g' -c ':wq' \;`

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-24 20:29:17 +01:00