account page: fixed platform reordering bugs

This commit is contained in:
2026-01-28 02:14:27 -07:00
parent a50c0ef18d
commit 8f38f141e5
8 changed files with 141 additions and 72 deletions
+30
View File
@@ -2,9 +2,11 @@ package sse
import (
"context"
"errors"
"fmt"
"path"
"strings"
"sync"
"time"
"github.com/gin-gonic/gin"
@@ -120,6 +122,34 @@ func (p *UpdateNotificationPublisher) Publish(pathPattern string) gin.HandlerFun
}
}
func (p *UpdateNotificationPublisher) Push(ctx context.Context, acctID int64, eventTypes ...string) error {
var wg sync.WaitGroup
wg.Add(len(eventTypes))
errs := make([]error, len(eventTypes))
for i, e := range eventTypes {
i := i
e := e
go func() {
defer wg.Done()
if err := p.queue.Send(ctx, Event{
AccountID: acctID,
Type: e,
Data: []byte(fmt.Sprintf(`{"eventType": %q}`, e)),
}); err != nil {
errs[i] = fmt.Errorf("failed to send sse event to listener: %w", err)
}
}()
}
wg.Wait()
return errors.Join(errs...)
return nil
}
func getPathSegments(p string) []string {
p = path.Clean(p)
if p == "" || p == "." || p == "/" {