From 507b7349bac970a2994d9553eef193834b124cc8 Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 16 Oct 2023 15:08:36 +0200 Subject: [PATCH] fix: only send non-direct messages over websockets --- internal/database/token.go | 8 ++++++-- internal/processor/processor.go | 15 ++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/internal/database/token.go b/internal/database/token.go index ca330ec..615815c 100644 --- a/internal/database/token.go +++ b/internal/database/token.go @@ -58,12 +58,16 @@ const ( TokenScopePostsRead TokenScope = "posts.read" TokenScopePostsWrite TokenScope = "posts.write" TokenScopeTimeline TokenScope = "timeline" - TokenScopeStreaming TokenScope = "streaming" + TokenScopeStreaming TokenScope = "streaming" ) 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 diff --git a/internal/processor/processor.go b/internal/processor/processor.go index 5993ee2..8dc10f9 100644 --- a/internal/processor/processor.go +++ b/internal/processor/processor.go @@ -71,11 +71,16 @@ func (p *Processor) handlePostLocal( apiPost := api.DBPostToPost(post, blog, acct) p.SocketHolder.Send(acct.ID, streaming.EventTypePost, apiPost) - for _, follower := range followers { - if !follower.IsLocal { - continue - } + // send to followers + if post.Visibility != database.DirectVisibility { + for _, follower := range followers { + if !follower.IsLocal { + continue + } - p.SocketHolder.Send(follower.AccountID, streaming.EventTypePost, apiPost) + p.SocketHolder.Send(follower.AccountID, streaming.EventTypePost, apiPost) + } } + + // TODO: send to mentions }