diff options
author | 2024-07-26 12:04:28 +0200 | |
---|---|---|
committer | 2024-07-26 12:04:28 +0200 | |
commit | 8ab2b19a946251f258446d22f420d401f61d22f6 (patch) | |
tree | 39fb674f135fd1cfcf4de5b319913f0d0c17d11a /internal/uris/uri.go | |
parent | [docs] Add separate migration section + instructions for moving to GtS and no... (diff) | |
download | gotosocial-8ab2b19a946251f258446d22f420d401f61d22f6.tar.xz |
[feature] Federate interaction policies + Accepts; enforce policies (#3138)
* [feature] Federate interaction policies + Accepts; enforce policies
* use Acceptable type
* fix index
* remove appendIRIStrs
* add GetAccept federatingdb function
* lock on object IRI
Diffstat (limited to 'internal/uris/uri.go')
-rw-r--r-- | internal/uris/uri.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/internal/uris/uri.go b/internal/uris/uri.go index 335461d84..159508176 100644 --- a/internal/uris/uri.go +++ b/internal/uris/uri.go @@ -46,6 +46,7 @@ const ( FileserverPath = "fileserver" // FileserverPath is a path component for serving attachments + media EmojiPath = "emoji" // EmojiPath represents the activitypub emoji location TagsPath = "tags" // TagsPath represents the activitypub tags location + AcceptsPath = "accepts" // AcceptsPath represents the activitypub accepts location ) // UserURIs contains a bunch of UserURIs and URLs for a user, host, account, etc. @@ -136,6 +137,14 @@ func GenerateURIForEmailConfirm(token string) string { return fmt.Sprintf("%s://%s/%s?token=%s", protocol, host, ConfirmEmailPath, token) } +// GenerateURIForAccept returns the AP URI for a new accept activity -- something like: +// https://example.org/users/whatever_user/accepts/01F7XTH1QGBAPMGF49WJZ91XGC +func GenerateURIForAccept(username string, thisAcceptID string) string { + protocol := config.GetProtocol() + host := config.GetHost() + return fmt.Sprintf("%s://%s/%s/%s/%s/%s", protocol, host, UsersPath, username, AcceptsPath, thisAcceptID) +} + // GenerateURIsForAccount throws together a bunch of URIs for the given username, with the given protocol and host. func GenerateURIsForAccount(username string) *UserURIs { protocol := config.GetProtocol() @@ -317,6 +326,11 @@ func IsReportPath(id *url.URL) bool { return regexes.ReportPath.MatchString(id.Path) } +// IsAcceptsPath returns true if the given URL path corresponds to eg /users/example_username/accepts/SOME_ULID_OF_AN_ACCEPT +func IsAcceptsPath(id *url.URL) bool { + return regexes.AcceptsPath.MatchString(id.Path) +} + // ParseStatusesPath returns the username and ulid from a path such as /users/example_username/statuses/SOME_ULID_OF_A_STATUS func ParseStatusesPath(id *url.URL) (username string, ulid string, err error) { matches := regexes.StatusesPath.FindStringSubmatch(id.Path) |