Broadcast Web Push subscriptions in a new goroutine
This commit is contained in:
parent
05a382ef16
commit
65f0b2367e
@ -3060,7 +3060,7 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc.
|
||||
// TODO: only broadcast if draft/read-marker has been negotiated
|
||||
// TODO: use lower priority
|
||||
network.pushTargets.Del(entity)
|
||||
network.broadcastWebPush(ctx, &irc.Message{
|
||||
go network.broadcastWebPush(&irc.Message{
|
||||
Command: "MARKREAD",
|
||||
Params: []string{entity, timestampStr},
|
||||
})
|
||||
|
@ -547,7 +547,7 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
|
||||
}
|
||||
|
||||
if highlight || uc.isOurNick(target) {
|
||||
uc.network.broadcastWebPush(ctx, msg)
|
||||
go uc.network.broadcastWebPush(msg)
|
||||
uc.network.pushTargets.Add(bufferName)
|
||||
}
|
||||
|
||||
@ -1551,7 +1551,7 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
|
||||
})
|
||||
|
||||
if weAreInvited {
|
||||
uc.network.broadcastWebPush(ctx, msg)
|
||||
go uc.network.broadcastWebPush(msg)
|
||||
}
|
||||
case irc.RPL_INVITING:
|
||||
var nick, channel string
|
||||
|
9
user.go
9
user.go
@ -456,7 +456,14 @@ func (net *network) autoSaveSASLPlain(ctx context.Context, username, password st
|
||||
}
|
||||
}
|
||||
|
||||
func (net *network) broadcastWebPush(ctx context.Context, msg *irc.Message) {
|
||||
// broadcastWebPush broadcasts a Web Push message for the given IRC message.
|
||||
//
|
||||
// Broadcasting the message to all Web Push endpoints might take a while, so
|
||||
// callers should call this function in a new goroutine.
|
||||
func (net *network) broadcastWebPush(msg *irc.Message) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
|
||||
defer cancel()
|
||||
|
||||
subs, err := net.user.srv.db.ListWebPushSubscriptions(ctx, net.user.ID, net.ID)
|
||||
if err != nil {
|
||||
net.logger.Printf("failed to list Web push subscriptions: %v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user