mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-14 07:59:31 +01:00
Merge pull request #1211 from slingamn/issue1204_echomessage.3
fix #1204
This commit is contained in:
commit
dc90b3c910
@ -1246,44 +1246,19 @@ func (channel *Channel) SendSplitMessage(command string, minPrefixMode modes.Mod
|
|||||||
}
|
}
|
||||||
|
|
||||||
// send echo-message
|
// send echo-message
|
||||||
if rb.session.capabilities.Has(caps.EchoMessage) {
|
rb.addEchoMessage(clientOnlyTags, details.nickMask, details.accountName, command, chname, message)
|
||||||
var tagsToUse map[string]string
|
|
||||||
if rb.session.capabilities.Has(caps.MessageTags) {
|
|
||||||
tagsToUse = clientOnlyTags
|
|
||||||
}
|
|
||||||
if histType == history.Tagmsg && rb.session.capabilities.Has(caps.MessageTags) {
|
|
||||||
rb.AddFromClient(message.Time, message.Msgid, details.nickMask, details.accountName, tagsToUse, command, chname)
|
|
||||||
} else {
|
|
||||||
rb.AddSplitMessageFromClient(details.nickMask, details.accountName, tagsToUse, command, chname, message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// send echo-message to other connected sessions
|
|
||||||
for _, session := range client.Sessions() {
|
|
||||||
if session == rb.session {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
var tagsToUse map[string]string
|
|
||||||
if session.capabilities.Has(caps.MessageTags) {
|
|
||||||
tagsToUse = clientOnlyTags
|
|
||||||
}
|
|
||||||
if histType == history.Tagmsg && session.capabilities.Has(caps.MessageTags) {
|
|
||||||
session.sendFromClientInternal(false, message.Time, message.Msgid, details.nickMask, details.accountName, tagsToUse, command, chname)
|
|
||||||
} else if histType != history.Tagmsg {
|
|
||||||
session.sendSplitMsgFromClientInternal(false, details.nickMask, details.accountName, tagsToUse, command, chname, message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, member := range channel.Members() {
|
for _, member := range channel.Members() {
|
||||||
// echo-message is handled above, so skip sending the msg to the user themselves as well
|
|
||||||
if member == client {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if minPrefixMode != modes.Mode(0) && !channel.ClientIsAtLeast(member, minPrefixMode) {
|
if minPrefixMode != modes.Mode(0) && !channel.ClientIsAtLeast(member, minPrefixMode) {
|
||||||
// STATUSMSG
|
// STATUSMSG
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, session := range member.Sessions() {
|
for _, session := range member.Sessions() {
|
||||||
|
if session == rb.session {
|
||||||
|
continue // we already sent echo-message, if applicable
|
||||||
|
}
|
||||||
|
|
||||||
if isCTCP && session.isTor {
|
if isCTCP && session.isTor {
|
||||||
continue // #753
|
continue // #753
|
||||||
}
|
}
|
||||||
|
@ -2041,18 +2041,17 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi
|
|||||||
service, isService := OragonoServices[lowercaseTarget]
|
service, isService := OragonoServices[lowercaseTarget]
|
||||||
_, isZNC := zncHandlers[lowercaseTarget]
|
_, isZNC := zncHandlers[lowercaseTarget]
|
||||||
|
|
||||||
if histType == history.Privmsg {
|
if isService || isZNC {
|
||||||
|
details := client.Details()
|
||||||
|
rb.addEchoMessage(tags, details.nickMask, details.accountName, command, target, message)
|
||||||
|
if histType != history.Privmsg {
|
||||||
|
return // NOTICE and TAGMSG to services are ignored
|
||||||
|
}
|
||||||
if isService {
|
if isService {
|
||||||
servicePrivmsgHandler(service, server, client, message.Message, rb)
|
servicePrivmsgHandler(service, server, client, message.Message, rb)
|
||||||
return
|
|
||||||
} else if isZNC {
|
} else if isZNC {
|
||||||
zncPrivmsgHandler(client, lowercaseTarget, message.Message, rb)
|
zncPrivmsgHandler(client, lowercaseTarget, message.Message, rb)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// NOTICE and TAGMSG to services are ignored
|
|
||||||
if isService || isZNC {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2110,18 +2109,7 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// the originating session may get an echo message:
|
// the originating session may get an echo message:
|
||||||
if rb.session.capabilities.Has(caps.EchoMessage) {
|
rb.addEchoMessage(tags, nickMaskString, accountName, command, tnick, message)
|
||||||
hasTagsCap := rb.session.capabilities.Has(caps.MessageTags)
|
|
||||||
if histType == history.Tagmsg && hasTagsCap {
|
|
||||||
rb.AddFromClient(message.Time, message.Msgid, nickMaskString, accountName, tags, command, tnick)
|
|
||||||
} else {
|
|
||||||
tagsToSend := tags
|
|
||||||
if !hasTagsCap {
|
|
||||||
tagsToSend = nil
|
|
||||||
}
|
|
||||||
rb.AddSplitMessageFromClient(nickMaskString, accountName, tagsToSend, command, tnick, message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if histType != history.Notice {
|
if histType != history.Notice {
|
||||||
//TODO(dan): possibly implement cooldown of away notifications to users
|
//TODO(dan): possibly implement cooldown of away notifications to users
|
||||||
if away, awayMessage := user.Away(); away {
|
if away, awayMessage := user.Away(); away {
|
||||||
|
@ -143,6 +143,23 @@ func (rb *ResponseBuffer) AddSplitMessageFromClient(fromNickMask string, fromAcc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rb *ResponseBuffer) addEchoMessage(tags map[string]string, nickMask, accountName, command, target string, message utils.SplitMessage) {
|
||||||
|
if rb.session.capabilities.Has(caps.EchoMessage) {
|
||||||
|
hasTagsCap := rb.session.capabilities.Has(caps.MessageTags)
|
||||||
|
if command == "TAGMSG" {
|
||||||
|
if hasTagsCap {
|
||||||
|
rb.AddFromClient(message.Time, message.Msgid, nickMask, accountName, tags, command, target)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tagsToSend := tags
|
||||||
|
if !hasTagsCap {
|
||||||
|
tagsToSend = nil
|
||||||
|
}
|
||||||
|
rb.AddSplitMessageFromClient(nickMask, accountName, tagsToSend, command, target, message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (rb *ResponseBuffer) sendBatchStart(blocking bool) {
|
func (rb *ResponseBuffer) sendBatchStart(blocking bool) {
|
||||||
if rb.batchID != "" {
|
if rb.batchID != "" {
|
||||||
// batch already initialized
|
// batch already initialized
|
||||||
|
Loading…
Reference in New Issue
Block a user