|
|
|
@ -43,26 +43,31 @@ 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, originalFrom string) {
|
|
|
|
|
sendMessageWrapper(to, from, body, id, component, reply, timestamp, "", isCarbon, isGroupchat, originalFrom)
|
|
|
|
|
func SendMessage(to, from, body, id string, component *xmpp.Component, reply *Reply, timestamp int64, isCarbon, isGroupchat bool, originalFrom string) {
|
|
|
|
|
sendMessageWrapper(to, from, body, "", id, component, reply, timestamp, "", isCarbon, isGroupchat, false, 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, "")
|
|
|
|
|
func SendServiceMessage(to, body string, component *xmpp.Component) {
|
|
|
|
|
sendMessageWrapper(to, "", body, "", "", component, nil, 0, "", false, 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, "")
|
|
|
|
|
func SendTextMessage(to, from, body string, component *xmpp.Component) {
|
|
|
|
|
sendMessageWrapper(to, from, body, "", "", component, nil, 0, "", false, 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, originalFrom string) {
|
|
|
|
|
sendMessageWrapper(to, from, body, id, component, reply, timestamp, oob, isCarbon, isGroupchat, originalFrom)
|
|
|
|
|
func SendMessageWithOOB(to, from, body, id string, component *xmpp.Component, reply *Reply, timestamp int64, oob string, isCarbon, isGroupchat bool, originalFrom string) {
|
|
|
|
|
sendMessageWrapper(to, from, body, "", id, component, reply, timestamp, oob, isCarbon, isGroupchat, false, originalFrom)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
// SendSubjectMessage creates and sends a MUC subject
|
|
|
|
|
func SendSubjectMessage(to, from, subject, id string, component *xmpp.Component, timestamp int64) {
|
|
|
|
|
sendMessageWrapper(to, from, "", subject, id, component, nil, timestamp, "", false, true, true, "")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func sendMessageWrapper(to, from, body, subject, id string, component *xmpp.Component, reply *Reply, timestamp int64, oob string, isCarbon, isGroupchat, forceSubject bool, originalFrom string) {
|
|
|
|
|
toJid, err := stanza.NewJid(to)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.WithFields(log.Fields{
|
|
|
|
@ -115,7 +120,8 @@ func sendMessageWrapper(to string, from string, body string, id string, componen
|
|
|
|
|
Type: messageType,
|
|
|
|
|
Id: id,
|
|
|
|
|
},
|
|
|
|
|
Body: body,
|
|
|
|
|
Subject: subject,
|
|
|
|
|
Body: body,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if oob != "" {
|
|
|
|
@ -132,7 +138,7 @@ func sendMessageWrapper(to string, from string, body string, id string, componen
|
|
|
|
|
message.Extensions = append(message.Extensions, extensions.NewReplyFallback(reply.Start, reply.End))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if !isCarbon && toJid.Resource != "" {
|
|
|
|
|
if !isGroupchat && !isCarbon && toJid.Resource != "" {
|
|
|
|
|
message.Extensions = append(message.Extensions, stanza.HintNoCopy{})
|
|
|
|
|
}
|
|
|
|
|
if timestamp != 0 {
|
|
|
|
@ -159,6 +165,9 @@ func sendMessageWrapper(to string, from string, body string, id string, componen
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if subject == "" && forceSubject {
|
|
|
|
|
message.Extensions = append(message.Extensions, extensions.EmptySubject{})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if isCarbon {
|
|
|
|
|
carbonMessage := extensions.ClientMessage{
|
|
|
|
|