Commit 7b2d64b0 authored by JC Brand's avatar JC Brand

Use `_converse.api.send` instead of `_converse.connection.send`

so that we can emit an event when sending a stanza.
parent 02f1b331
......@@ -949,7 +949,7 @@ converse.plugins.add('converse-muc-views', {
if (!this.verifyRoles(['visitor', 'participant', 'moderator'])) {
break;
}
_converse.connection.send($pres({
_converse.api.send($pres({
from: _converse.connection.jid,
to: this.model.getRoomJIDAndNick(match[2]),
id: _converse.connection.getUniqueId()
......@@ -999,7 +999,7 @@ converse.plugins.add('converse-muc-views', {
case 'topic':
case 'subject':
// TODO: should be done via API call to _converse.api.rooms
_converse.connection.send(
_converse.api.send(
$msg({
to: this.model.get('jid'),
from: _converse.connection.jid,
......
......@@ -346,10 +346,10 @@ converse.plugins.add('converse-chatboxes', {
},
sendMessageStanza (stanza) {
_converse.connection.send(stanza);
_converse.api.send(stanza);
if (_converse.forward_messages) {
// Forward the message, so that other connected resources are also aware of it.
_converse.connection.send(
_converse.api.send(
$msg({
'to': _converse.bare_jid,
'type': this.get('message_type'),
......@@ -407,7 +407,7 @@ converse.plugins.add('converse-chatboxes', {
* See XEP-0085 Chat State Notifications.
*/
if (_converse.send_chat_state_notifications) {
_converse.connection.send(
_converse.api.send(
$msg({'to':this.get('jid'), 'type': 'chat'})
.c(this.get('chat_state'), {'xmlns': Strophe.NS.CHATSTATES}).up()
.c('no-store', {'xmlns': Strophe.NS.HINTS}).up()
......
......@@ -420,7 +420,7 @@ _converse.initialize = function (settings, callback) {
*/
/* Send out a Chat Status Notification (XEP-0352) */
// XXX if (converse.features[Strophe.NS.CSI] || true) {
_converse.connection.send($build(stat, {xmlns: Strophe.NS.CSI}));
_converse.api.send($build(stat, {xmlns: Strophe.NS.CSI}));
_converse.inactive = (stat === _converse.INACTIVE) ? true : false;
};
......@@ -510,7 +510,7 @@ _converse.initialize = function (settings, callback) {
*/
const pres = $pres({to: jid, type: "unsubscribed"});
if (message && message !== "") { pres.c("status").t(message); }
_converse.connection.send(pres);
_converse.api.send(pres);
};
this.reconnect = _.debounce(function () {
......@@ -914,7 +914,7 @@ _converse.initialize = function (settings, callback) {
},
sendPresence (type, status_message) {
_converse.connection.send(this.constructPresence(type, status_message));
_converse.api.send(this.constructPresence(type, status_message));
}
});
......
......@@ -333,7 +333,7 @@ converse.plugins.add('converse-disco', {
_.each(plugin._features, (feature) => {
iqresult.c('feature', {'var': feature}).up();
});
_converse.connection.send(iqresult.tree());
_converse.api.send(iqresult.tree());
return true;
}
......
......@@ -278,7 +278,7 @@ converse.plugins.add('converse-muc', {
stanza.cnode(Strophe.xmlElement("password", [], password));
}
this.save('connection_status', converse.ROOMSTATUS.CONNECTING);
_converse.connection.send(stanza);
_converse.api.send(stanza);
return this;
},
......@@ -426,7 +426,7 @@ converse.plugins.add('converse-muc', {
// <gone/> is not applicable within MUC context
return;
}
_converse.connection.send(
_converse.api.send(
$msg({'to':this.get('jid'), 'type': 'groupchat'})
.c(chat_state, {'xmlns': Strophe.NS.CHATSTATES}).up()
.c('no-store', {'xmlns': Strophe.NS.HINTS}).up()
......@@ -462,12 +462,12 @@ converse.plugins.add('converse-muc', {
if (this.get('password')) { attrs.password = this.get('password'); }
const invitation = $msg({
from: _converse.connection.jid,
to: recipient,
id: _converse.connection.getUniqueId()
'from': _converse.connection.jid,
'to': recipient,
'id': _converse.connection.getUniqueId()
}).c('x', attrs);
_converse.connection.send(invitation);
_converse.emit('roomInviteSent', {
_converse.api.send(invitation);
_converse.api.emit('roomInviteSent', {
'room': this,
'recipient': recipient,
'reason': reason
......
......@@ -268,7 +268,7 @@ converse.plugins.add('converse-roster', {
if (nick) {
pres.c('nick', {'xmlns': Strophe.NS.NICK}).t(nick).up();
}
_converse.connection.send(pres);
_converse.api.send(pres);
this.save('ask', "subscribe"); // ask === 'subscribe' Means we have asked to subscribe to them.
return this;
},
......@@ -279,7 +279,7 @@ converse.plugins.add('converse-roster', {
* state notification by sending a presence stanza of type
* "subscribe" to the contact
*/
_converse.connection.send($pres({
_converse.api.send($pres({
'type': 'subscribe',
'to': this.get('jid')
}));
......@@ -294,7 +294,7 @@ converse.plugins.add('converse-roster', {
* Parameters:
* (String) jid - The Jabber ID of the user who is unsubscribing
*/
_converse.connection.send($pres({'type': 'unsubscribe', 'to': this.get('jid')}));
_converse.api.send($pres({'type': 'unsubscribe', 'to': this.get('jid')}));
this.removeFromRoster();
this.destroy();
},
......@@ -317,7 +317,7 @@ converse.plugins.add('converse-roster', {
if (message && message !== "") {
pres.c("status").t(message);
}
_converse.connection.send(pres);
_converse.api.send(pres);
return this;
},
......@@ -546,7 +546,7 @@ converse.plugins.add('converse-roster', {
// user's bare JID <user@domainpart>.
return;
}
_converse.connection.send($iq({type: 'result', id, from: _converse.connection.jid}));
_converse.api.send($iq({type: 'result', id, from: _converse.connection.jid}));
const query = sizzle(`query[xmlns="${Strophe.NS.ROSTER}"]`, iq).pop();
this.data.save('version', query.getAttribute('ver'));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment