Add invitees to the member-list of the room.
This commit is contained in:
parent
60f433d12e
commit
09802cfbde
@ -256,26 +256,6 @@
|
|||||||
converse.ChatBoxView.prototype.close.apply(this, arguments);
|
converse.ChatBoxView.prototype.close.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
updateMembersList: function () {
|
|
||||||
/* Update the room's member-lists by sending a delta of
|
|
||||||
* changed memberships (for all affiliations).
|
|
||||||
*/
|
|
||||||
var iq = $iq({'to':this.model.get('jid'), 'type':'set', 'from':converse.connection.jid})
|
|
||||||
.c("query", {'xmlns': Strophe.NS.MUC_ADMIN});
|
|
||||||
this.occupantsview.model.each(function (occupant) {
|
|
||||||
var affiliation = occupant.get('affiliation');
|
|
||||||
iq.c('item', {
|
|
||||||
'affiliation': affiliation !== 'none' ? affiliation : 'member',
|
|
||||||
'jid': Strophe.getBareJidFromJid(occupant.get('jid'))
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return converse.connection.sendIQ(
|
|
||||||
iq.tree(),
|
|
||||||
this.onMembersListChanged.bind(this),
|
|
||||||
this.onMembersListChangedError.bind(this)
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
fetchMembersList: function (affiliation) {
|
fetchMembersList: function (affiliation) {
|
||||||
/* Fetch the member-list for a particular affiliation.
|
/* Fetch the member-list for a particular affiliation.
|
||||||
*
|
*
|
||||||
@ -296,6 +276,33 @@
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateMembersList: function (members) {
|
||||||
|
/* Update the room's member-lists by sending a delta of
|
||||||
|
* changed memberships (for all affiliations).
|
||||||
|
*/
|
||||||
|
var iq = $iq({'to':this.model.get('jid'), 'type':'set', 'from':converse.connection.jid})
|
||||||
|
.c("query", {'xmlns': Strophe.NS.MUC_ADMIN});
|
||||||
|
_.each(members, function (member) {
|
||||||
|
iq.c('item', {
|
||||||
|
'affiliation': member.affiliation !== 'none' ? member.affiliation : 'member',
|
||||||
|
'jid': Strophe.getBareJidFromJid(member.jid)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return converse.connection.sendIQ(
|
||||||
|
iq.tree(),
|
||||||
|
this.onMembersListChanged.bind(this),
|
||||||
|
this.onMembersListChangedError.bind(this)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
onMembersListChanged: function (stanza) {
|
||||||
|
converse.log("The membership-list for "+this.model.get('jid')+" has been succesfully updated");
|
||||||
|
},
|
||||||
|
|
||||||
|
onMembersListChangedError: function (stanza) {
|
||||||
|
this.showStatusNotification(__("An error occurred while trying to update the members list."));
|
||||||
|
},
|
||||||
|
|
||||||
onMembersListError: function (affiliation, iq) {
|
onMembersListError: function (affiliation, iq) {
|
||||||
if (iq.getElementsByTagName('forbidden').length) {
|
if (iq.getElementsByTagName('forbidden').length) {
|
||||||
converse.log("You are forbidden from retrieving the "+affiliation+"-list for "+this.model.get('jid'));
|
converse.log("You are forbidden from retrieving the "+affiliation+"-list for "+this.model.get('jid'));
|
||||||
@ -335,6 +342,10 @@
|
|||||||
};
|
};
|
||||||
if (reason !== null) { attrs.reason = reason; }
|
if (reason !== null) { attrs.reason = reason; }
|
||||||
if (this.model.get('password')) { attrs.password = this.model.get('password'); }
|
if (this.model.get('password')) { attrs.password = this.model.get('password'); }
|
||||||
|
|
||||||
|
// We also add the invitee to the room's member-list.
|
||||||
|
this.updateMembersList([{'jid': recipient, 'affiliation': 'member'}]);
|
||||||
|
|
||||||
var invitation = $msg({
|
var invitation = $msg({
|
||||||
from: converse.connection.jid,
|
from: converse.connection.jid,
|
||||||
to: recipient,
|
to: recipient,
|
||||||
@ -667,15 +678,14 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
onConfigSaved: function (stanza) {
|
onConfigSaved: function (stanza) {
|
||||||
// this.updateMembersList();
|
var members = [];
|
||||||
},
|
this.occupantsview.model.each(function (occupant) {
|
||||||
|
members.push({
|
||||||
onMembersListChanged: function (stanza) {
|
'affiliation': affiliation !== 'none' ? affiliation : 'member',
|
||||||
converse.log("The membership-list for "+this.model.get('jid')+" has been succesfully updated");
|
'jid': Strophe.getBareJidFromJid(occupant.get('jid'))
|
||||||
},
|
});
|
||||||
|
});
|
||||||
onMembersListChangedError: function (stanza) {
|
// this.updateMembersList(members);
|
||||||
this.showStatusNotification(__("An error occurred while trying to update the members list."));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onErrorConfigSaved: function (stanza) {
|
onErrorConfigSaved: function (stanza) {
|
||||||
|
Loading…
Reference in New Issue
Block a user