feat: distribute new local posts to followers via websocket
This commit is contained in:
parent
5c6da51234
commit
97b05d787f
6 changed files with 107 additions and 75 deletions
|
@ -85,10 +85,16 @@ func (s *BlogStore) LocalCount(ctx context.Context) (count int64, err error) {
|
|||
return count, nil
|
||||
}
|
||||
|
||||
func (s *BlogStore) Followers(ctx context.Context, id ulid.ULID) ([]ulid.ULID, error) {
|
||||
q := sqlf.Sprintf("SELECT account_id FROM account_follows WHERE blog_id = %s", id)
|
||||
type BlogFollower struct {
|
||||
AccountID ulid.ULID
|
||||
IsLocal bool
|
||||
}
|
||||
|
||||
follows, err := Select[ulid.ULID](ctx, s.q, q)
|
||||
func (s *BlogStore) Followers(ctx context.Context, id ulid.ULID) ([]BlogFollower, error) {
|
||||
q := sqlf.Sprintf(`SELECT f.account_id, a.domain IS NOT NULL AS is_local
|
||||
FROM account_follows f JOIN accounts a ON a.id = f.account_id WHERE f.blog_id = %s`, id)
|
||||
|
||||
follows, err := Select[BlogFollower](ctx, s.q, q)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "executing query")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue