Feed insertions and other feed stuff
This commit is contained in:
parent
72e1c67488
commit
5232bb0741
7 changed files with 134 additions and 8 deletions
|
@ -594,6 +594,7 @@ type IUserToUserRelationDo interface {
|
|||
GetFollowingApLinksPagedForId(id string, page int) (result []string, err error)
|
||||
CountFollowersForId(id string) (result int, err error)
|
||||
CountFollowingForId(id string) (result int, err error)
|
||||
GetLocalFollowerIdsOfId(id string) (result []string, err error)
|
||||
}
|
||||
|
||||
// Get all inbox links for accounts following the user with the specified id
|
||||
|
@ -720,6 +721,34 @@ func (u userToUserRelationDo) CountFollowingForId(id string) (result int, err er
|
|||
return
|
||||
}
|
||||
|
||||
// Get the ids of all local accounts following the user with the target id
|
||||
//
|
||||
// SELECT
|
||||
// r.user_id
|
||||
// FROM
|
||||
//
|
||||
// user_to_user_relations r
|
||||
// LEFT JOIN users u ON r.user_id = u.id
|
||||
// LEFT JOIN remote_servers s ON u.server_id = s.id
|
||||
//
|
||||
// WHERE
|
||||
//
|
||||
// s.is_self = true
|
||||
// AND r.target_user_id = @id;
|
||||
func (u userToUserRelationDo) GetLocalFollowerIdsOfId(id string) (result []string, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
params = append(params, id)
|
||||
generateSQL.WriteString("SELECT r.user_id FROM user_to_user_relations r LEFT JOIN users u ON r.user_id = u.id LEFT JOIN remote_servers s ON u.server_id = s.id WHERE s.is_self = true AND r.target_user_id = ?; ")
|
||||
|
||||
var executeSQL *gorm.DB
|
||||
executeSQL = u.UnderlyingDB().Raw(generateSQL.String(), params...).Find(&result) // ignore_security_alert
|
||||
err = executeSQL.Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Debug() IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Debug())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue