~emersion/soju-dev

Store only select TAGMSG types in message stores v1 APPLIED

delthas: 1
 Store only select TAGMSG types in message stores

 1 files changed, 18 insertions(+), 0 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/37564/mbox | git am -3
Learn more about email & git

[PATCH] Store only select TAGMSG types in message stores Export this patch

We only want to store TAGMSG that should be persistent. +typing TAGMSG
should be dropped, but +react messages should be kept.

This introduces a whitelist for TAGMSG labels. We only store TAGMSG
having a least one tag in that whitelist.
---
 upstream.go | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/upstream.go b/upstream.go
index 49e5a76..542d742 100644
--- a/upstream.go
+++ b/upstream.go
@@ -44,6 +44,12 @@ var permanentUpstreamCaps = map[string]bool{
	"draft/extended-monitor":     true,
}

// storableMessageTags is the static list of message tags that will cause
// a TAGMSG to be stored.
var storableMessageTags = map[string]bool{
	"+react": true,
}

type registrationError struct {
	*irc.Message
}
@@ -2096,6 +2102,18 @@ func (uc *upstreamConn) appendLog(entity string, msg *irc.Message) (msgID string
	if uc.user.msgStore == nil {
		return ""
	}
	if msg.Command == "TAGMSG" {
		store := false
		for tag := range storableMessageTags {
			if _, ok := msg.Tags[tag]; ok {
				store = true
				break
			}
		}
		if !store {
			return ""
		}
	}

	// Don't store messages with a server mask target
	if strings.HasPrefix(entity, "$") {

base-commit: 6ddfc943f5a2f77f00ef2fc0a19787918e31999e
-- 
2.17.1
Pushed, thanks!