diff options
author | 2021-11-22 19:03:21 +0100 | |
---|---|---|
committer | 2021-11-22 19:03:21 +0100 | |
commit | 3caae376e77a270f57733093163eafa3db8c71bc (patch) | |
tree | 3988a324473631e49fdb7b9360a8eb749005dfb1 /internal/stream/stream.go | |
parent | Use IPv6 doc prefix for docs (#324) (diff) | |
download | gotosocial-3caae376e77a270f57733093163eafa3db8c71bc.tar.xz |
Fix streamed messages ending up in wrong timeline(s) (#325)
* define timeline consts
* remove double stream of status
* change test stream creation up a bit
* stream messages more selectively
* add test for streaming new status creation via clientAPI
* tidy code + comments a bit
* tidy up tests
* make sure new status isn't streamed to public
Diffstat (limited to 'internal/stream/stream.go')
-rw-r--r-- | internal/stream/stream.go | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/internal/stream/stream.go b/internal/stream/stream.go index 011b7dbe1..e92d610d8 100644 --- a/internal/stream/stream.go +++ b/internal/stream/stream.go @@ -2,18 +2,36 @@ package stream import "sync" -// EventType models a type of stream event. -type EventType string - const ( // EventTypeNotification -- a user should be shown a notification - EventTypeNotification EventType = "notification" + EventTypeNotification string = "notification" // EventTypeUpdate -- a user should be shown an update in their timeline - EventTypeUpdate EventType = "update" + EventTypeUpdate string = "update" // EventTypeDelete -- something should be deleted from a user - EventTypeDelete EventType = "delete" + EventTypeDelete string = "delete" +) + +const ( + // TimelineLocal -- public statuses from the LOCAL timeline. + TimelineLocal string = "public:local" + // TimelinePublic -- public statuses, including federated ones. + TimelinePublic string = "public" + // TimelineHome -- statuses for a user's Home timeline. + TimelineHome string = "user" + // TimelineNotifications -- notification events. + TimelineNotifications string = "user:notification" + // TimelineDirect -- statuses sent to a user directly. + TimelineDirect string = "direct" ) +// AllStatusTimelines contains all Timelines that a status could conceivably be delivered to -- useful for doing deletes. +var AllStatusTimelines = []string{ + TimelineLocal, + TimelinePublic, + TimelineHome, + TimelineDirect, +} + // StreamsForAccount is a wrapper for the multiple streams that one account can have running at the same time. // TODO: put a limit on this type StreamsForAccount struct { @@ -27,8 +45,8 @@ type StreamsForAccount struct { type Stream struct { // ID of this stream, generated during creation. ID string - // Type of this stream: user/public/etc - Type string + // Timeline of this stream: user/public/etc + Timeline string // Channel of messages for the client to read from Messages chan *Message // Channel to close when the client drops away |