1
0
Fork 0
forked from External/ergo

make TAGMSG storage configurable

This commit is contained in:
Shivaram Lingamneni 2020-07-09 18:36:45 -04:00
parent f2d0842453
commit bca3dd0b41
7 changed files with 74 additions and 26 deletions

View file

@ -2113,7 +2113,7 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi
AccountName: accountName,
Tags: tags,
}
if !item.IsStorable() || !allowedPlusR {
if !itemIsStorable(&item, config) || !allowedPlusR {
return
}
targetedItem := item
@ -2136,6 +2136,32 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi
}
}
func itemIsStorable(item *history.Item, config *Config) bool {
switch item.Type {
case history.Tagmsg:
if config.History.TagmsgStorage.Default {
for _, blacklistedTag := range config.History.TagmsgStorage.Blacklist {
if _, ok := item.Tags[blacklistedTag]; ok {
return false
}
}
return true
} else {
for _, whitelistedTag := range config.History.TagmsgStorage.Whitelist {
if _, ok := item.Tags[whitelistedTag]; ok {
return true
}
}
return false
}
case history.Privmsg, history.Notice:
// don't store CTCP other than ACTION
return !item.Message.IsRestrictedCTCPMessage()
default:
return true
}
}
// NPC <target> <sourcenick> <message>
func npcHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
target := msg.Params[0]