mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
Timeline manager (#40)
* start messing about with timeline manager * i have no idea what i'm doing * i continue to not know what i'm doing * it's coming along * bit more progress * update timeline with new posts as they come in * lint and fmt * Select accounts where empty string * restructure a bunch, get unfaves working * moving stuff around * federate status deletes properly * mention regex better but not 100% there * fix regex * some more hacking away at the timeline code phew * fix up some little things * i can't even * more timeline stuff * move to ulid * fiddley * some lil fixes for kibou compatibility * timelines working pretty alright! * tidy + lint
This commit is contained in:
@ -21,7 +21,6 @@ package util
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -108,19 +107,19 @@ type UserURIs struct {
|
||||
}
|
||||
|
||||
// GenerateURIForFollow returns the AP URI for a new follow -- something like:
|
||||
// https://example.org/users/whatever_user/follow/41c7f33f-1060-48d9-84df-38dcb13cf0d8
|
||||
// https://example.org/users/whatever_user/follow/01F7XTH1QGBAPMGF49WJZ91XGC
|
||||
func GenerateURIForFollow(username string, protocol string, host string, thisFollowID string) string {
|
||||
return fmt.Sprintf("%s://%s/%s/%s/%s/%s", protocol, host, UsersPath, username, FollowPath, thisFollowID)
|
||||
}
|
||||
|
||||
// GenerateURIForLike returns the AP URI for a new like/fave -- something like:
|
||||
// https://example.org/users/whatever_user/liked/41c7f33f-1060-48d9-84df-38dcb13cf0d8
|
||||
// https://example.org/users/whatever_user/liked/01F7XTH1QGBAPMGF49WJZ91XGC
|
||||
func GenerateURIForLike(username string, protocol string, host string, thisFavedID string) string {
|
||||
return fmt.Sprintf("%s://%s/%s/%s/%s/%s", protocol, host, UsersPath, username, LikedPath, thisFavedID)
|
||||
}
|
||||
|
||||
// GenerateURIForUpdate returns the AP URI for a new update activity -- something like:
|
||||
// https://example.org/users/whatever_user#updates/41c7f33f-1060-48d9-84df-38dcb13cf0d8
|
||||
// https://example.org/users/whatever_user#updates/01F7XTH1QGBAPMGF49WJZ91XGC
|
||||
func GenerateURIForUpdate(username string, protocol string, host string, thisUpdateID string) string {
|
||||
return fmt.Sprintf("%s://%s/%s/%s#%s/%s", protocol, host, UsersPath, username, UpdatePath, thisUpdateID)
|
||||
}
|
||||
@ -162,58 +161,63 @@ func GenerateURIsForAccount(username string, protocol string, host string) *User
|
||||
|
||||
// IsUserPath returns true if the given URL path corresponds to eg /users/example_username
|
||||
func IsUserPath(id *url.URL) bool {
|
||||
return userPathRegex.MatchString(strings.ToLower(id.Path))
|
||||
return userPathRegex.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 inboxPathRegex.MatchString(strings.ToLower(id.Path))
|
||||
return inboxPathRegex.MatchString(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))
|
||||
return outboxPathRegex.MatchString(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))
|
||||
return actorPathRegex.MatchString(id.Path)
|
||||
}
|
||||
|
||||
// IsFollowersPath returns true if the given URL path corresponds to eg /users/example_username/followers
|
||||
func IsFollowersPath(id *url.URL) bool {
|
||||
return followersPathRegex.MatchString(strings.ToLower(id.Path))
|
||||
return followersPathRegex.MatchString(id.Path)
|
||||
}
|
||||
|
||||
// IsFollowingPath returns true if the given URL path corresponds to eg /users/example_username/following
|
||||
func IsFollowingPath(id *url.URL) bool {
|
||||
return followingPathRegex.MatchString(strings.ToLower(id.Path))
|
||||
return followingPathRegex.MatchString(id.Path)
|
||||
}
|
||||
|
||||
// IsFollowPath returns true if the given URL path corresponds to eg /users/example_username/follow/SOME_ULID_OF_A_FOLLOW
|
||||
func IsFollowPath(id *url.URL) bool {
|
||||
return followPathRegex.MatchString(id.Path)
|
||||
}
|
||||
|
||||
// IsLikedPath returns true if the given URL path corresponds to eg /users/example_username/liked
|
||||
func IsLikedPath(id *url.URL) bool {
|
||||
return likedPathRegex.MatchString(strings.ToLower(id.Path))
|
||||
return likedPathRegex.MatchString(id.Path)
|
||||
}
|
||||
|
||||
// IsLikePath returns true if the given URL path corresponds to eg /users/example_username/liked/SOME_UUID_OF_A_STATUS
|
||||
// IsLikePath returns true if the given URL path corresponds to eg /users/example_username/liked/SOME_ULID_OF_A_STATUS
|
||||
func IsLikePath(id *url.URL) bool {
|
||||
return likePathRegex.MatchString(strings.ToLower(id.Path))
|
||||
return likePathRegex.MatchString(id.Path)
|
||||
}
|
||||
|
||||
// IsStatusesPath returns true if the given URL path corresponds to eg /users/example_username/statuses/SOME_UUID_OF_A_STATUS
|
||||
// IsStatusesPath returns true if the given URL path corresponds to eg /users/example_username/statuses/SOME_ULID_OF_A_STATUS
|
||||
func IsStatusesPath(id *url.URL) bool {
|
||||
return statusesPathRegex.MatchString(strings.ToLower(id.Path))
|
||||
return statusesPathRegex.MatchString(id.Path)
|
||||
}
|
||||
|
||||
// ParseStatusesPath returns the username and uuid from a path such as /users/example_username/statuses/SOME_UUID_OF_A_STATUS
|
||||
func ParseStatusesPath(id *url.URL) (username string, uuid string, err error) {
|
||||
// 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 := statusesPathRegex.FindStringSubmatch(id.Path)
|
||||
if len(matches) != 3 {
|
||||
err = fmt.Errorf("expected 3 matches but matches length was %d", len(matches))
|
||||
return
|
||||
}
|
||||
username = matches[1]
|
||||
uuid = matches[2]
|
||||
ulid = matches[2]
|
||||
return
|
||||
}
|
||||
|
||||
@ -272,14 +276,14 @@ func ParseFollowingPath(id *url.URL) (username string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// ParseLikedPath returns the username and uuid from a path such as /users/example_username/liked/SOME_UUID_OF_A_STATUS
|
||||
func ParseLikedPath(id *url.URL) (username string, uuid string, err error) {
|
||||
// ParseLikedPath returns the username and ulid from a path such as /users/example_username/liked/SOME_ULID_OF_A_STATUS
|
||||
func ParseLikedPath(id *url.URL) (username string, ulid string, err error) {
|
||||
matches := likePathRegex.FindStringSubmatch(id.Path)
|
||||
if len(matches) != 3 {
|
||||
err = fmt.Errorf("expected 3 matches but matches length was %d", len(matches))
|
||||
return
|
||||
}
|
||||
username = matches[1]
|
||||
uuid = matches[2]
|
||||
ulid = matches[2]
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user