1
0
Fork 0
forked from External/ergo

import changes

This commit is contained in:
Failure 2024-07-24 17:10:22 -07:00
parent 30f47a9b22
commit ca62b268b0
16 changed files with 272 additions and 34 deletions

View file

@ -1128,6 +1128,12 @@ func extjwtHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respo
}
claims["channel"] = channel.Name()
var channelModeStrings []string
for _, mode := range channel.flags.AllModes() {
channelModeStrings = append(channelModeStrings, mode.String())
}
claims["chanModes"] = channelModeStrings
claims["joined"] = 0
claims["cmodes"] = []string{}
if present, joinTimeSecs, cModes := channel.ClientStatus(client); present {
@ -2234,7 +2240,7 @@ func absorbBatchedMessage(server *Server, client *Client, msg ircmsg.Message, ba
if !isConcat && len(rb.session.batch.message.Split) != 0 {
rb.session.batch.lenBytes++ // bill for the newline
}
rb.session.batch.message.Append(msg.Params[1], isConcat)
rb.session.batch.message.Append(msg.Params[1], isConcat, msg.ClientOnlyTags())
rb.session.batch.lenBytes += len(msg.Params[1])
config := server.Config()
if config.Limits.Multiline.MaxBytes < rb.session.batch.lenBytes {
@ -2317,6 +2323,41 @@ func messageHandler(server *Server, client *Client, msg ircmsg.Message, rb *Resp
return false
}
// Not really sure how to do this in Go
var endChars = map[int32]bool{
' ': true,
'@': true,
':': true,
'!': true,
'?': true,
}
func detectMentions(message string) (mentions []string) {
buf := ""
mentions = []string{}
working := false
for _, char := range message {
if char == '@' {
working = true
continue
}
if !working {
continue
}
if _, stop := endChars[char]; stop {
working = false
mentions = append(mentions, buf)
buf = ""
} else {
buf += string(char)
}
}
if len(buf) != 0 {
mentions = append(mentions, buf)
}
return
}
func dispatchMessageToTarget(client *Client, tags map[string]string, histType history.ItemType, command, target string, message utils.SplitMessage, rb *ResponseBuffer) {
server := client.server
@ -2333,7 +2374,15 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi
}
return
}
// This likely isn't that great for performance. Should figure out some way to deal with this at some point
mentions := detectMentions(message.Message)
channel.SendSplitMessage(command, lowestPrefix, tags, client, message, rb)
for _, mention := range mentions {
user := client.server.clients.Get(mention)
if user != nil {
client.server.cefManager.CEFMessage("MENTION", user.nickCasefolded, channel.Name(), message.Msgid)
}
}
} else if target[0] == '$' && len(target) > 2 && client.Oper().HasRoleCapab("massmessage") {
details := client.Details()
matcher, err := utils.CompileGlob(target[2:], false)
@ -2456,7 +2505,9 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi
Message: message,
Tags: tags,
}
client.addHistoryItem(user, item, &details, &tDetails, config)
client.server.cefManager.CEFMessage("MENTION", user.nickCasefolded, client.nick, message.Msgid)
}
}
@ -2745,7 +2796,7 @@ func redactHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respo
var members []*Client // members of a channel, or both parties of a PM
var canDelete CanDelete
msgid := utils.GenerateSecretToken()
msgid := utils.GenerateMessageIdStr()
time := time.Now().UTC().Round(0)
details := client.Details()
isBot := client.HasMode(modes.Bot)