mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02: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:
@@ -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)
|
||||
|
Reference in New Issue
Block a user