mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-23 05:46:14 -06:00
tidy up some federation stuff
This commit is contained in:
parent
621e59fd42
commit
211c43073f
11 changed files with 199 additions and 86 deletions
|
|
@ -137,6 +137,11 @@ func IsInboxPath(id *url.URL) bool {
|
|||
return inboxPathRegex.MatchString(strings.ToLower(id.Path))
|
||||
}
|
||||
|
||||
// IsOutboxPath returns true if the given URL path corresponds to eg /users/example_username/outbox
|
||||
func IsOutboxPath(id *url.URL) bool {
|
||||
return outboxPathRegex.MatchString(strings.ToLower(id.Path))
|
||||
}
|
||||
|
||||
// IsInstanceActorPath returns true if the given URL path corresponds to eg /actors/example_username
|
||||
func IsInstanceActorPath(id *url.URL) bool {
|
||||
return actorPathRegex.MatchString(strings.ToLower(id.Path))
|
||||
|
|
@ -195,3 +200,14 @@ func ParseInboxPath(id *url.URL) (username string, err error) {
|
|||
username = matches[1]
|
||||
return
|
||||
}
|
||||
|
||||
// ParseOutboxPath returns the username from a path such as /users/example_username/outbox
|
||||
func ParseOutboxPath(id *url.URL) (username string, err error) {
|
||||
matches := outboxPathRegex.FindStringSubmatch(id.Path)
|
||||
if len(matches) != 2 {
|
||||
err = fmt.Errorf("expected 2 matches but matches length was %d", len(matches))
|
||||
return
|
||||
}
|
||||
username = matches[1]
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue