aboutsummaryrefslogtreecommitdiff
path: root/xmpp/gateway/gateway.go
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp/gateway/gateway.go')
-rw-r--r--xmpp/gateway/gateway.go29
1 files changed, 18 insertions, 11 deletions
diff --git a/xmpp/gateway/gateway.go b/xmpp/gateway/gateway.go
index 09cd42f..1a37cc7 100644
--- a/xmpp/gateway/gateway.go
+++ b/xmpp/gateway/gateway.go
@@ -44,35 +44,40 @@ var MessageOutgoingPermissionVersion = 0
// SendMessage creates and sends a message stanza
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, 0)
+ sendMessageWrapper(to, from, body, "", "", id, component, reply, timestamp, "", isCarbon, isGroupchat, false, originalFrom, 0)
}
// SendServiceMessage creates and sends a simple message stanza from transport
func SendServiceMessage(to, body string, component *xmpp.Component) {
- sendMessageWrapper(to, "", body, "", "", component, nil, 0, "", false, false, false, "", 0)
+ sendMessageWrapper(to, "", body, "", "", "", component, nil, 0, "", false, false, false, "", 0)
}
// SendTextMessage creates and sends a simple message stanza
func SendTextMessage(to, from, body string, component *xmpp.Component) {
- sendMessageWrapper(to, from, body, "", "", component, nil, 0, "", false, false, false, "", 0)
+ sendMessageWrapper(to, from, body, "", "", "", component, nil, 0, "", false, false, false, "", 0)
}
// SendErrorMessage creates and sends an error message stanza
func SendErrorMessage(to, from, text string, code int, isGroupchat bool, component *xmpp.Component) {
- sendMessageWrapper(to, from, text, "", "", component, nil, 0, "", false, isGroupchat, false, "", code)
+ sendMessageWrapper(to, from, "", "", text, "", component, nil, 0, "", false, isGroupchat, false, "", code)
+}
+
+// SendErrorMessageWithBody creates and sends an error message stanza with body payload
+func SendErrorMessageWithBody(to, from, body, errorText, id string, code int, isGroupchat bool, component *xmpp.Component) {
+ sendMessageWrapper(to, from, body, "", errorText, id, component, nil, 0, "", false, isGroupchat, false, "", code)
}
// SendMessageWithOOB creates and sends a message stanza with OOB URL
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, 0)
+ sendMessageWrapper(to, from, body, "", "", id, component, reply, timestamp, oob, isCarbon, isGroupchat, false, originalFrom, 0)
}
// 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, "", 0)
+ sendMessageWrapper(to, from, "", subject, "", id, component, nil, timestamp, "", false, true, true, "", 0)
}
-func sendMessageWrapper(to, from, body, subject, id string, component *xmpp.Component, reply *Reply, timestamp int64, oob string, isCarbon, isGroupchat, forceSubject bool, originalFrom string, errorCode int) {
+func sendMessageWrapper(to, from, body, subject, errorText, id string, component *xmpp.Component, reply *Reply, timestamp int64, oob string, isCarbon, isGroupchat, forceSubject bool, originalFrom string, errorCode int) {
toJid, err := stanza.NewJid(to)
if err != nil {
log.WithFields(log.Fields{
@@ -128,13 +133,12 @@ func sendMessageWrapper(to, from, body, subject, id string, component *xmpp.Comp
Id: id,
},
Subject: subject,
+ Body: body,
}
- if errorCode == 0 {
- message.Body = body
- } else {
+ if errorCode != 0 {
message.Error = stanza.Err{
Code: errorCode,
- Text: body,
+ Text: errorText,
}
switch errorCode {
case 400:
@@ -146,6 +150,9 @@ func sendMessageWrapper(to, from, body, subject, id string, component *xmpp.Comp
case 404:
message.Error.Type = stanza.ErrorTypeCancel
message.Error.Reason = "item-not-found"
+ case 406:
+ message.Error.Type = stanza.ErrorTypeModify
+ message.Error.Reason = "not-acceptable"
case 500:
message.Error.Type = stanza.ErrorTypeWait
message.Error.Reason = "internal-server-error"