mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 07:12:25 -05:00
[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
This commit is contained in:
parent
f8d399cf6a
commit
8ab2b19a94
42 changed files with 3541 additions and 254 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue