Add follower and following collections
All checks were successful
/ docker (push) Successful in 4m34s
All checks were successful
/ docker (push) Successful in 4m34s
This commit is contained in:
parent
b75db5676b
commit
af6ff2dd30
11 changed files with 431 additions and 22 deletions
|
@ -3,5 +3,5 @@ package models
|
|||
type Collection struct {
|
||||
Id string `gorm:"primarykey"`
|
||||
TargetId string
|
||||
TargetType string `orm:"type:collection_target_type"`
|
||||
TargetType string // `orm:"type:collection_target_type"`
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ const (
|
|||
CollectionTargetPinnedNotes = CollectionTargetType("pinned")
|
||||
CollectionTargetReactions = CollectionTargetType("reactions")
|
||||
CollectionTargetBoostsAndQuotes = CollectionTargetType("boosts")
|
||||
COllectionTargetFollows = CollectionTargetType("follows")
|
||||
COllectionTargetFollowers = CollectionTargetType("followers")
|
||||
)
|
||||
|
||||
var AllCollectionTargetTypes = []CollectionTargetType{
|
||||
|
|
|
@ -103,6 +103,17 @@ type IUser interface {
|
|||
// LIMIT 1
|
||||
GetByUsername(username string) (*gen.T, error)
|
||||
|
||||
// Get a user by the id.
|
||||
// Restricted to users visible to ActivityPub
|
||||
//
|
||||
// SELECT * FROM @@table WHERE
|
||||
// id = @id AND
|
||||
// deleted_at IS NULL AND
|
||||
// finished_registration = true AND
|
||||
// verified = true
|
||||
// LIMIT 1
|
||||
GetById(id string) (*gen.T, error)
|
||||
|
||||
// Get all true public accounts (verified & no restricted follow & indexable)
|
||||
// in a paged manner, sorted by date saved
|
||||
//
|
||||
|
@ -148,4 +159,15 @@ type IUser interface {
|
|||
// )
|
||||
// LIMIT 1
|
||||
GetRemoteAccountByApUrl(url string) (*gen.T, error)
|
||||
|
||||
// Does a user with the given Id exist?
|
||||
// The user must be visible from AP
|
||||
//
|
||||
// SELECT EXISTS(
|
||||
// SELECT * FROM @@table WHERE
|
||||
// id = @id AND
|
||||
// deleted_at IS NULL AND
|
||||
// verified = true
|
||||
// )
|
||||
DoesUserWithIdExist(id string) (bool, error)
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ type UserToUserRelation struct {
|
|||
}
|
||||
|
||||
type IUserToUserRelation interface {
|
||||
// Get all inbox links for accounts following the user with the specified id
|
||||
//
|
||||
// SELECT u.inbox_link
|
||||
// FROM user_to_user_relations r
|
||||
// LEFT JOIN user_remote_links u
|
||||
|
@ -20,5 +22,49 @@ type IUserToUserRelation interface {
|
|||
// WHERE
|
||||
// r.target_user_id = @id AND
|
||||
// r.relation = 'follow'
|
||||
GetFollowersForId(id string) ([]string, error)
|
||||
GetFollowerInboxesForId(id string) ([]string, error)
|
||||
|
||||
// Get all Ids of the accounts following the user with the specified id
|
||||
//
|
||||
// SELECT u.ap_link
|
||||
// FROM user_to_user_relations r
|
||||
// LEFT JOIN user_remote_links u
|
||||
// ON r.user_id = u.user_id
|
||||
// WHERE
|
||||
// r.target_user_id = @id AND
|
||||
// r.relation = 'follow'
|
||||
// LIMIT 50
|
||||
// OFFSET @page * 50
|
||||
GetFollowerApLinksPagedForId(id string, page int) ([]string, error)
|
||||
|
||||
// Get all Ids of the accounts followed by the user with the specified id
|
||||
//
|
||||
// SELECT u.ap_link
|
||||
// FROM user_to_user_relations r
|
||||
// LEFT JOIN user_remote_links u
|
||||
// ON r.user_id = u.user_id
|
||||
// WHERE
|
||||
// r.user_id = @id AND
|
||||
// r.relation = 'follow'
|
||||
// LIMIT 50
|
||||
// OFFSET @page * 50
|
||||
GetFollowingApLinksPagedForId(id string, page int) ([]string, error)
|
||||
|
||||
// Count the accounts following the user with the specified id
|
||||
//
|
||||
// SELECT COUNT(*)
|
||||
// FROM user_to_user_relations r
|
||||
// WHERE
|
||||
// r.target_user_id = @id AND
|
||||
// r.relation = 'follow'
|
||||
CountFollowersForId(id string) (int, error)
|
||||
|
||||
// Count the accounts following the user with the specified id
|
||||
//
|
||||
// SELECT COUNT(*)
|
||||
// FROM user_to_user_relations r
|
||||
// WHERE
|
||||
// r.user_id = @id AND
|
||||
// r.relation = 'follow'
|
||||
CountFollowingForId(id string) (int, error)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue