Avoid sending push notifications for all channel context messages

...Instead, send them only when their text content contains the user
nick, as if they were regular channel messages.
This commit is contained in:
delthas 2022-12-01 17:40:11 +01:00 committed by Simon Ser
parent ec2c0685dd
commit 58ee475265
1 changed files with 4 additions and 2 deletions

View File

@ -593,14 +593,16 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
break break
} }
directMessage := uc.isOurNick(target)
bufferName := target bufferName := target
if uc.isOurNick(target) { if directMessage {
bufferName = msg.Prefix.Name bufferName = msg.Prefix.Name
} }
if t, ok := msg.Tags["+draft/channel-context"]; ok { if t, ok := msg.Tags["+draft/channel-context"]; ok {
ch := uc.channels.Get(string(t)) ch := uc.channels.Get(string(t))
if ch != nil && ch.Members.Has(msg.Prefix.Name) { if ch != nil && ch.Members.Has(msg.Prefix.Name) {
bufferName = ch.Name bufferName = ch.Name
directMessage = false
} }
} }
@ -619,7 +621,7 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
} }
} }
if highlight || uc.isOurNick(target) { if highlight || directMessage {
go uc.network.broadcastWebPush(msg) go uc.network.broadcastWebPush(msg)
if timestamp, err := time.Parse(xirc.ServerTimeLayout, string(msg.Tags["time"])); err == nil { if timestamp, err := time.Parse(xirc.ServerTimeLayout, string(msg.Tags["time"])); err == nil {
uc.network.pushTargets.Set(bufferName, timestamp) uc.network.pushTargets.Set(bufferName, timestamp)