linstrom/storage-new/models/UserToUserRelation.go
mstar e69f53bbd7
All checks were successful
/ docker (push) Successful in 4m26s
Note down a bug for later fixing
2025-05-13 14:07:15 +02:00

74 lines
2.2 KiB
Go

package models
// A relation between two accounts
// There may be multiple relations from an account X to an account Y,
// each describing a different aspect
type UserToUserRelation struct {
ID uint64 `gorm:"primarykey"`
User User // The user X described in [RelationType]
UserId string
TargetUser User // The user Y described in [RelationType]
TargetUserId string
Relation string // `gorm:"type:relation_type"`
}
type IUserToUserRelation interface {
// FIXME: Include local users in these queries
// Currently local users don't have an entry in user_remote_links
// causing them to be ignored by these functions as of now
// 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
// ON r.user_id = u.user_id
// WHERE
// r.target_user_id = @id AND
// r.relation = 'follow'
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)
}