mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 07:22:24 -05:00
[bugfix] Don't return Account or Status if new and dereferencing failed, other small fixes (#2563)
* tidy up account, status, webfingering logic a wee bit * go fmt * invert published check * alter resp initialization * get Published from account in typeutils * don't instantiate error for no darn good reason * shadow err * don't repeat error codes in wrapped errors * don't wrap error unnecessarily
This commit is contained in:
parent
07207e71e9
commit
e3052e8c82
13 changed files with 461 additions and 211 deletions
|
|
@ -248,6 +248,11 @@ func IsUserPath(id *url.URL) bool {
|
|||
return regexes.UserPath.MatchString(id.Path)
|
||||
}
|
||||
|
||||
// IsUserWebPath returns true if the given URL path corresponds to eg /@example_username
|
||||
func IsUserWebPath(id *url.URL) bool {
|
||||
return regexes.UserWebPath.MatchString(id.Path)
|
||||
}
|
||||
|
||||
// IsInboxPath returns true if the given URL path corresponds to eg /users/example_username/inbox
|
||||
func IsInboxPath(id *url.URL) bool {
|
||||
return regexes.InboxPath.MatchString(id.Path)
|
||||
|
|
@ -326,6 +331,17 @@ func ParseUserPath(id *url.URL) (username string, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// ParseUserPath returns the username from a path such as /@example_username
|
||||
func ParseUserWebPath(id *url.URL) (username string, err error) {
|
||||
matches := regexes.UserWebPath.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
|
||||
}
|
||||
|
||||
// ParseInboxPath returns the username from a path such as /users/example_username/inbox
|
||||
func ParseInboxPath(id *url.URL) (username string, err error) {
|
||||
matches := regexes.InboxPath.FindStringSubmatch(id.Path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue