Store only select TAGMSG types in message stores

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.
This commit is contained in:
delthas 2022-12-16 12:12:27 +01:00 committed by Simon Ser
parent 6ddfc943f5
commit 2604a14b7f

View File

@ -44,6 +44,12 @@ var permanentUpstreamCaps = map[string]bool{
"draft/extended-monitor": true, "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 { type registrationError struct {
*irc.Message *irc.Message
} }
@ -2096,6 +2102,18 @@ func (uc *upstreamConn) appendLog(entity string, msg *irc.Message) (msgID string
if uc.user.msgStore == nil { if uc.user.msgStore == nil {
return "" 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 // Don't store messages with a server mask target
if strings.HasPrefix(entity, "$") { if strings.HasPrefix(entity, "$") {