Original sender JID in MUCs (why?)
This commit is contained in:
parent
e77caf2c42
commit
e8bde73164
|
@ -265,7 +265,7 @@ func (c *Client) updateMessageContent(update *client.UpdateMessageContent) {
|
|||
markupFunction,
|
||||
))
|
||||
for _, jid := range jids {
|
||||
gateway.SendMessage(jid, strconv.FormatInt(update.ChatId, 10), text, "e"+strconv.FormatInt(update.MessageId, 10), c.xmpp, nil, 0, false, false)
|
||||
gateway.SendMessage(jid, strconv.FormatInt(update.ChatId, 10), text, "e"+strconv.FormatInt(update.MessageId, 10), c.xmpp, nil, 0, false, false, "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1046,12 +1046,18 @@ func (c *Client) sendMessageToGateway(chatId int64, message *client.Message, del
|
|||
var isCarbon bool
|
||||
var jids []string
|
||||
var isGroupchat bool
|
||||
var originalFrom string
|
||||
if len(groupChatTos) == 0 {
|
||||
isCarbon = gateway.MessageOutgoingPermissionVersion > 0 && c.Session.Carbons && message.IsOutgoing
|
||||
jids = c.getCarbonFullJids(isCarbon, "")
|
||||
} else {
|
||||
isGroupchat = true
|
||||
jids = groupChatTos
|
||||
|
||||
senderId := c.getSenderId(message)
|
||||
if senderId != 0 {
|
||||
originalFrom = strconv.FormatInt(senderId, 10) + "@" + gateway.Jid.Full()
|
||||
}
|
||||
}
|
||||
|
||||
var text, oob, auxText string
|
||||
|
@ -1138,9 +1144,9 @@ func (c *Client) sendMessageToGateway(chatId int64, message *client.Message, del
|
|||
}
|
||||
|
||||
for _, jid := range jids {
|
||||
gateway.SendMessageWithOOB(jid, from, text, sId, c.xmpp, reply, timestamp, oob, isCarbon, isGroupchat)
|
||||
gateway.SendMessageWithOOB(jid, from, text, sId, c.xmpp, reply, timestamp, oob, isCarbon, isGroupchat, originalFrom)
|
||||
if auxText != "" {
|
||||
gateway.SendMessage(jid, from, auxText, sId, c.xmpp, reply, timestamp, isCarbon, isGroupchat)
|
||||
gateway.SendMessage(jid, from, auxText, sId, c.xmpp, reply, timestamp, isCarbon, isGroupchat, originalFrom)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1768,6 +1774,7 @@ func (c *Client) sendMessagesReverse(chatID int64, messages []*client.Message, p
|
|||
0,
|
||||
false,
|
||||
false,
|
||||
"",
|
||||
)
|
||||
} else {
|
||||
c.sendMessageToGateway(
|
||||
|
|
|
@ -248,6 +248,19 @@ type MessageDelayLegacy struct {
|
|||
Stamp string `xml:"stamp,attr"`
|
||||
}
|
||||
|
||||
// MessageAddresses is from XEP-0033
|
||||
type MessageAddresses struct {
|
||||
XMLName xml.Name `xml:"http://jabber.org/protocol/address addresses"`
|
||||
Addresses []MessageAddress
|
||||
}
|
||||
|
||||
// MessageAddress is from XEP-0033
|
||||
type MessageAddress struct {
|
||||
XMLName xml.Name `xml:"address"`
|
||||
Type string `xml:"type,attr"`
|
||||
Jid string `xml:"jid,attr"`
|
||||
}
|
||||
|
||||
// Namespace is a namespace!
|
||||
func (c PresenceNickExtension) Namespace() string {
|
||||
return c.XMLName.Space
|
||||
|
@ -430,4 +443,10 @@ func init() {
|
|||
"jabber:x:delay",
|
||||
"x",
|
||||
}, MessageDelayLegacy{})
|
||||
|
||||
// message addresses
|
||||
stanza.TypeRegistry.MapExtension(stanza.PKTMessage, xml.Name{
|
||||
"http://jabber.org/protocol/address",
|
||||
"addresses",
|
||||
}, MessageAddresses{})
|
||||
}
|
||||
|
|
|
@ -43,26 +43,26 @@ var DirtySessions = false
|
|||
var MessageOutgoingPermissionVersion = 0
|
||||
|
||||
// SendMessage creates and sends a message stanza
|
||||
func SendMessage(to string, from string, body string, id string, component *xmpp.Component, reply *Reply, timestamp int64, isCarbon, isGroupchat bool) {
|
||||
sendMessageWrapper(to, from, body, id, component, reply, timestamp, "", isCarbon, isGroupchat)
|
||||
func SendMessage(to string, from string, body string, id string, component *xmpp.Component, reply *Reply, timestamp int64, isCarbon, isGroupchat bool, originalFrom string) {
|
||||
sendMessageWrapper(to, from, body, id, component, reply, timestamp, "", isCarbon, isGroupchat, originalFrom)
|
||||
}
|
||||
|
||||
// SendServiceMessage creates and sends a simple message stanza from transport
|
||||
func SendServiceMessage(to string, body string, component *xmpp.Component) {
|
||||
sendMessageWrapper(to, "", body, "", component, nil, 0, "", false, false)
|
||||
sendMessageWrapper(to, "", body, "", component, nil, 0, "", false, false, "")
|
||||
}
|
||||
|
||||
// SendTextMessage creates and sends a simple message stanza
|
||||
func SendTextMessage(to string, from string, body string, component *xmpp.Component) {
|
||||
sendMessageWrapper(to, from, body, "", component, nil, 0, "", false, false)
|
||||
sendMessageWrapper(to, from, body, "", component, nil, 0, "", false, false, "")
|
||||
}
|
||||
|
||||
// SendMessageWithOOB creates and sends a message stanza with OOB URL
|
||||
func SendMessageWithOOB(to string, from string, body string, id string, component *xmpp.Component, reply *Reply, timestamp int64, oob string, isCarbon bool, isGroupchat bool) {
|
||||
sendMessageWrapper(to, from, body, id, component, reply, timestamp, oob, isCarbon, isGroupchat)
|
||||
func SendMessageWithOOB(to string, from string, body string, id string, component *xmpp.Component, reply *Reply, timestamp int64, oob string, isCarbon bool, isGroupchat bool, originalFrom string) {
|
||||
sendMessageWrapper(to, from, body, id, component, reply, timestamp, oob, isCarbon, isGroupchat, originalFrom)
|
||||
}
|
||||
|
||||
func sendMessageWrapper(to string, from string, body string, id string, component *xmpp.Component, reply *Reply, timestamp int64, oob string, isCarbon bool, isGroupchat bool) {
|
||||
func sendMessageWrapper(to string, from string, body string, id string, component *xmpp.Component, reply *Reply, timestamp int64, oob string, isCarbon bool, isGroupchat bool, originalFrom string) {
|
||||
toJid, err := stanza.NewJid(to)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
|
@ -149,6 +149,16 @@ func sendMessageWrapper(to string, from string, body string, id string, componen
|
|||
Stamp: time.Unix(timestamp, 0).UTC().Format("20060102T15:04:05"),
|
||||
})
|
||||
}
|
||||
if originalFrom != "" {
|
||||
message.Extensions = append(message.Extensions, extensions.MessageAddresses{
|
||||
Addresses: []extensions.MessageAddress{
|
||||
extensions.MessageAddress{
|
||||
Type: "ofrom",
|
||||
Jid: originalFrom,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
if isCarbon {
|
||||
carbonMessage := extensions.ClientMessage{
|
||||
|
|
Loading…
Reference in a new issue