fix: only send non-direct messages over websockets

This commit is contained in:
sam 2023-10-16 15:08:36 +02:00
parent 97b05d787f
commit 507b7349ba
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
2 changed files with 16 additions and 7 deletions

View file

@ -63,7 +63,11 @@ const (
func (s TokenScope) IsValid() bool {
switch s {
case TokenScopeAccountsRead, TokenScopeAccountsMe, TokenScopeAccountsWrite:
case TokenScopeAccountsRead, TokenScopeAccountsMe,
TokenScopeAccountsWrite, TokenScopeBlogsRead,
TokenScopeBlogsWrite, TokenScopePostsRead,
TokenScopePostsWrite, TokenScopeTimeline,
TokenScopeStreaming:
return true
default:
return false

View file

@ -71,6 +71,8 @@ func (p *Processor) handlePostLocal(
apiPost := api.DBPostToPost(post, blog, acct)
p.SocketHolder.Send(acct.ID, streaming.EventTypePost, apiPost)
// send to followers
if post.Visibility != database.DirectVisibility {
for _, follower := range followers {
if !follower.IsLocal {
continue
@ -78,4 +80,7 @@ func (p *Processor) handlePostLocal(
p.SocketHolder.Send(follower.AccountID, streaming.EventTypePost, apiPost)
}
}
// TODO: send to mentions
}