mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-13 07:29:30 +01:00
(hopefully) fix labeled-response behaviour
This commit is contained in:
parent
e0fa97d344
commit
a70cc6713c
@ -7,6 +7,9 @@ package caps
|
|||||||
type Capability string
|
type Capability string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// LabelTagName is the tag name used for the labeled-response spec.
|
||||||
|
LabelTagName = "draft/label"
|
||||||
|
|
||||||
// AccountNotify is this IRCv3 capability: http://ircv3.net/specs/extensions/account-notify-3.1.html
|
// AccountNotify is this IRCv3 capability: http://ircv3.net/specs/extensions/account-notify-3.1.html
|
||||||
AccountNotify Capability = "account-notify"
|
AccountNotify Capability = "account-notify"
|
||||||
// AccountTag is this IRCv3 capability: http://ircv3.net/specs/extensions/account-tag-3.2.html
|
// AccountTag is this IRCv3 capability: http://ircv3.net/specs/extensions/account-tag-3.2.html
|
||||||
|
@ -549,12 +549,26 @@ func (channel *Channel) sendMessage(msgid, cmd string, requiredCaps []caps.Capab
|
|||||||
if minPrefix != nil {
|
if minPrefix != nil {
|
||||||
minPrefixMode = *minPrefix
|
minPrefixMode = *minPrefix
|
||||||
}
|
}
|
||||||
|
// send echo-message
|
||||||
|
if client.capabilities.Has(caps.EchoMessage) {
|
||||||
|
var messageTagsToUse *map[string]ircmsg.TagValue
|
||||||
|
if client.capabilities.Has(caps.MessageTags) {
|
||||||
|
messageTagsToUse = clientOnlyTags
|
||||||
|
}
|
||||||
|
|
||||||
|
if message == nil {
|
||||||
|
rb.AddFromClient(msgid, client, messageTagsToUse, cmd, channel.name)
|
||||||
|
} else {
|
||||||
|
rb.AddFromClient(msgid, client, messageTagsToUse, cmd, channel.name, *message)
|
||||||
|
}
|
||||||
|
}
|
||||||
for _, member := range channel.Members() {
|
for _, member := range channel.Members() {
|
||||||
if minPrefix != nil && !channel.ClientIsAtLeast(member, minPrefixMode) {
|
if minPrefix != nil && !channel.ClientIsAtLeast(member, minPrefixMode) {
|
||||||
// STATUSMSG
|
// STATUSMSG
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if member == client && !client.capabilities.Has(caps.EchoMessage) {
|
// echo-message is handled above, so skip sending the msg to the user themselves as well
|
||||||
|
if member == client {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -574,9 +588,9 @@ func (channel *Channel) sendMessage(msgid, cmd string, requiredCaps []caps.Capab
|
|||||||
}
|
}
|
||||||
|
|
||||||
if message == nil {
|
if message == nil {
|
||||||
rb.AddFromClient(msgid, client, messageTagsToUse, cmd, channel.name)
|
member.SendFromClient(msgid, client, messageTagsToUse, cmd, channel.name)
|
||||||
} else {
|
} else {
|
||||||
rb.AddFromClient(msgid, client, messageTagsToUse, cmd, channel.name, *message)
|
member.SendFromClient(msgid, client, messageTagsToUse, cmd, channel.name, *message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -602,12 +616,25 @@ func (channel *Channel) sendSplitMessage(msgid, cmd string, minPrefix *modes.Mod
|
|||||||
if minPrefix != nil {
|
if minPrefix != nil {
|
||||||
minPrefixMode = *minPrefix
|
minPrefixMode = *minPrefix
|
||||||
}
|
}
|
||||||
|
// send echo-message
|
||||||
|
if client.capabilities.Has(caps.EchoMessage) {
|
||||||
|
var tagsToUse *map[string]ircmsg.TagValue
|
||||||
|
if client.capabilities.Has(caps.MessageTags) {
|
||||||
|
tagsToUse = clientOnlyTags
|
||||||
|
}
|
||||||
|
if message == nil {
|
||||||
|
rb.AddFromClient(msgid, client, tagsToUse, cmd, channel.name)
|
||||||
|
} else {
|
||||||
|
rb.AddSplitMessageFromClient(msgid, client, tagsToUse, cmd, channel.name, *message)
|
||||||
|
}
|
||||||
|
}
|
||||||
for _, member := range channel.Members() {
|
for _, member := range channel.Members() {
|
||||||
if minPrefix != nil && !channel.ClientIsAtLeast(member, minPrefixMode) {
|
if minPrefix != nil && !channel.ClientIsAtLeast(member, minPrefixMode) {
|
||||||
// STATUSMSG
|
// STATUSMSG
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if member == client && !client.capabilities.Has(caps.EchoMessage) {
|
// echo-message is handled above, so skip sending the msg to the user themselves as well
|
||||||
|
if member == client {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var tagsToUse *map[string]ircmsg.TagValue
|
var tagsToUse *map[string]ircmsg.TagValue
|
||||||
@ -615,18 +642,10 @@ func (channel *Channel) sendSplitMessage(msgid, cmd string, minPrefix *modes.Mod
|
|||||||
tagsToUse = clientOnlyTags
|
tagsToUse = clientOnlyTags
|
||||||
}
|
}
|
||||||
|
|
||||||
if member == client {
|
if message == nil {
|
||||||
if message == nil {
|
member.SendFromClient(msgid, client, tagsToUse, cmd, channel.name)
|
||||||
rb.AddFromClient(msgid, client, tagsToUse, cmd, channel.name)
|
|
||||||
} else {
|
|
||||||
rb.AddSplitMessageFromClient(msgid, client, tagsToUse, cmd, channel.name, *message)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if message == nil {
|
member.SendSplitMsgFromClient(msgid, client, tagsToUse, cmd, channel.name, *message)
|
||||||
member.SendFromClient(msgid, client, tagsToUse, cmd, channel.name)
|
|
||||||
} else {
|
|
||||||
member.SendSplitMsgFromClient(msgid, client, tagsToUse, cmd, channel.name, *message)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1770,11 +1770,7 @@ func noticeHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
|
|||||||
// restrict messages appropriately when +R is set
|
// restrict messages appropriately when +R is set
|
||||||
// intentionally make the sending user think the message went through fine
|
// intentionally make the sending user think the message went through fine
|
||||||
if !user.flags[modes.RegisteredOnly] || client.registered {
|
if !user.flags[modes.RegisteredOnly] || client.registered {
|
||||||
if user == client {
|
user.SendSplitMsgFromClient(msgid, client, clientOnlyTags, "NOTICE", user.nick, splitMsg)
|
||||||
rb.AddSplitMessageFromClient(msgid, client, clientOnlyTags, "NOTICE", user.nick, splitMsg)
|
|
||||||
} else {
|
|
||||||
user.SendSplitMsgFromClient(msgid, client, clientOnlyTags, "NOTICE", user.nick, splitMsg)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if client.capabilities.Has(caps.EchoMessage) {
|
if client.capabilities.Has(caps.EchoMessage) {
|
||||||
rb.AddSplitMessageFromClient(msgid, client, clientOnlyTags, "NOTICE", user.nick, splitMsg)
|
rb.AddSplitMessageFromClient(msgid, client, clientOnlyTags, "NOTICE", user.nick, splitMsg)
|
||||||
@ -2002,11 +1998,7 @@ func privmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *R
|
|||||||
// restrict messages appropriately when +R is set
|
// restrict messages appropriately when +R is set
|
||||||
// intentionally make the sending user think the message went through fine
|
// intentionally make the sending user think the message went through fine
|
||||||
if !user.flags[modes.RegisteredOnly] || client.registered {
|
if !user.flags[modes.RegisteredOnly] || client.registered {
|
||||||
if user == client {
|
user.SendSplitMsgFromClient(msgid, client, clientOnlyTags, "PRIVMSG", user.nick, splitMsg)
|
||||||
rb.AddSplitMessageFromClient(msgid, client, clientOnlyTags, "PRIVMSG", user.nick, splitMsg)
|
|
||||||
} else {
|
|
||||||
user.SendSplitMsgFromClient(msgid, client, clientOnlyTags, "PRIVMSG", user.nick, splitMsg)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if client.capabilities.Has(caps.EchoMessage) {
|
if client.capabilities.Has(caps.EchoMessage) {
|
||||||
rb.AddSplitMessageFromClient(msgid, client, clientOnlyTags, "PRIVMSG", user.nick, splitMsg)
|
rb.AddSplitMessageFromClient(msgid, client, clientOnlyTags, "PRIVMSG", user.nick, splitMsg)
|
||||||
@ -2258,11 +2250,7 @@ func tagmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
|
|||||||
if !user.capabilities.Has(caps.MessageTags) {
|
if !user.capabilities.Has(caps.MessageTags) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if user == client {
|
user.SendFromClient(msgid, client, clientOnlyTags, "TAGMSG", user.nick)
|
||||||
rb.AddFromClient(msgid, client, clientOnlyTags, "TAGMSG", user.nick)
|
|
||||||
} else {
|
|
||||||
user.SendFromClient(msgid, client, clientOnlyTags, "TAGMSG", user.nick)
|
|
||||||
}
|
|
||||||
if client.capabilities.Has(caps.EchoMessage) {
|
if client.capabilities.Has(caps.EchoMessage) {
|
||||||
rb.AddFromClient(msgid, client, clientOnlyTags, "TAGMSG", user.nick)
|
rb.AddFromClient(msgid, client, clientOnlyTags, "TAGMSG", user.nick)
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ type ResponseBuffer struct {
|
|||||||
|
|
||||||
// GetLabel returns the label from the given message.
|
// GetLabel returns the label from the given message.
|
||||||
func GetLabel(msg ircmsg.IrcMessage) string {
|
func GetLabel(msg ircmsg.IrcMessage) string {
|
||||||
return msg.Tags["label"].Value
|
return msg.Tags[caps.LabelTagName].Value
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewResponseBuffer returns a new ResponseBuffer.
|
// NewResponseBuffer returns a new ResponseBuffer.
|
||||||
@ -90,13 +90,13 @@ func (rb *ResponseBuffer) Send() error {
|
|||||||
// if label but no batch, add label to first message
|
// if label but no batch, add label to first message
|
||||||
if useLabel && batch == nil {
|
if useLabel && batch == nil {
|
||||||
message := rb.messages[0]
|
message := rb.messages[0]
|
||||||
message.Tags["label"] = ircmsg.MakeTagValue(rb.Label)
|
message.Tags[caps.LabelTagName] = ircmsg.MakeTagValue(rb.Label)
|
||||||
rb.messages[0] = message
|
rb.messages[0] = message
|
||||||
}
|
}
|
||||||
|
|
||||||
// start batch if required
|
// start batch if required
|
||||||
if batch != nil {
|
if batch != nil {
|
||||||
batch.Start(rb.target, ircmsg.MakeTags("label", rb.Label))
|
batch.Start(rb.target, ircmsg.MakeTags(caps.LabelTagName, rb.Label))
|
||||||
}
|
}
|
||||||
|
|
||||||
// send each message out
|
// send each message out
|
||||||
|
Loading…
Reference in New Issue
Block a user