~emersion/soju-dev

Avoid sending push notifications for all channel context messages v1 APPLIED

delthas: 1
 Avoid sending push notifications for all channel context messages

 1 files changed, 4 insertions(+), 2 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/soju-dev/patches/37273/mbox | git am -3
Learn more about email & git

[PATCH] Avoid sending push notifications for all channel context messages Export this patch

...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)

base-commit: ec2c0685dd280da43b7422d677b42e2f75636758
-- 
2.17.1
Pushed, thanks!