summaryrefslogtreecommitdiff
path: root/internal/processing/stream/delete.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2024-02-20 18:07:49 +0000
committerLibravatar GitHub <noreply@github.com>2024-02-20 18:07:49 +0000
commit291e18099050ff9e19b8ee25c2ffad68d9baafef (patch)
tree0ad1be36b4c958830d1371f3b9a32f017c5dcff0 /internal/processing/stream/delete.go
parent[feature] Add `requested_by` to relationship model (#2672) (diff)
downloadgotosocial-291e18099050ff9e19b8ee25c2ffad68d9baafef.tar.xz
[bugfix] fix possible mutex lockup during streaming code (#2633)
* rewrite Stream{} to use much less mutex locking, update related code * use new context for the stream context * ensure stream gets closed on return of writeTo / readFrom WSConn() * ensure stream write timeout gets cancelled * remove embedded context type from Stream{}, reformat log messages for consistency * use c.Request.Context() for context passed into Stream().Open() * only return 1 boolean, fix tests to expect multiple stream types in messages * changes to ping logic * further improved ping logic * don't export unused function types, update message sending to only include relevant stream type * ensure stream gets closed :facepalm: * update to error log on failed json marshal (instead of panic) * inverse websocket read error checking to _ignore_ expected close errors
Diffstat (limited to 'internal/processing/stream/delete.go')
-rw-r--r--internal/processing/stream/delete.go34
1 files changed, 6 insertions, 28 deletions
diff --git a/internal/processing/stream/delete.go b/internal/processing/stream/delete.go
index d7745eef8..1c61b98d3 100644
--- a/internal/processing/stream/delete.go
+++ b/internal/processing/stream/delete.go
@@ -18,38 +18,16 @@
package stream
import (
- "fmt"
- "strings"
+ "context"
"github.com/superseriousbusiness/gotosocial/internal/stream"
)
// Delete streams the delete of the given statusID to *ALL* open streams.
-func (p *Processor) Delete(statusID string) error {
- errs := []string{}
-
- // get all account IDs with open streams
- accountIDs := []string{}
- p.streamMap.Range(func(k interface{}, _ interface{}) bool {
- key, ok := k.(string)
- if !ok {
- panic("streamMap key was not a string (account id)")
- }
-
- accountIDs = append(accountIDs, key)
- return true
+func (p *Processor) Delete(ctx context.Context, statusID string) {
+ p.streams.PostAll(ctx, stream.Message{
+ Payload: statusID,
+ Event: stream.EventTypeDelete,
+ Stream: stream.AllStatusTimelines,
})
-
- // stream the delete to every account
- for _, accountID := range accountIDs {
- if err := p.toAccount(statusID, stream.EventTypeDelete, stream.AllStatusTimelines, accountID); err != nil {
- errs = append(errs, err.Error())
- }
- }
-
- if len(errs) != 0 {
- return fmt.Errorf("one or more errors streaming status delete: %s", strings.Join(errs, ";"))
- }
-
- return nil
}