From 58ee4752654774cb66fb3d5c8e7963e173857ec6 Mon Sep 17 00:00:00 2001 From: delthas Date: Thu, 1 Dec 2022 17:40:11 +0100 Subject: [PATCH] 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. --- upstream.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/upstream.go b/upstream.go index 0b43fb8..49e5a76 100644 --- a/upstream.go +++ b/upstream.go @@ -593,14 +593,16 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err break } + directMessage := uc.isOurNick(target) bufferName := target - if uc.isOurNick(target) { + if directMessage { bufferName = msg.Prefix.Name } if t, ok := msg.Tags["+draft/channel-context"]; ok { ch := uc.channels.Get(string(t)) if ch != nil && ch.Members.Has(msg.Prefix.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) if timestamp, err := time.Parse(xirc.ServerTimeLayout, string(msg.Tags["time"])); err == nil { uc.network.pushTargets.Set(bufferName, timestamp)