Merge branch '0.6.x'
Conflicts: converse.js index.html
This commit is contained in:
commit
cf137c607b
86
converse.js
86
converse.js
@ -936,7 +936,7 @@
|
|||||||
updateVCard: function () {
|
updateVCard: function () {
|
||||||
var jid = this.model.get('jid'),
|
var jid = this.model.get('jid'),
|
||||||
rosteritem = converse.roster.get(jid);
|
rosteritem = converse.roster.get(jid);
|
||||||
if ((rosteritem)&&(!rosteritem.get('vcard_updated'))) {
|
if ((rosteritem) && (!rosteritem.get('vcard_updated'))) {
|
||||||
converse.getVCard(
|
converse.getVCard(
|
||||||
jid,
|
jid,
|
||||||
$.proxy(function (jid, fullname, image, image_type, url) {
|
$.proxy(function (jid, fullname, image, image_type, url) {
|
||||||
@ -944,8 +944,7 @@
|
|||||||
'fullname' : fullname || jid,
|
'fullname' : fullname || jid,
|
||||||
'url': url,
|
'url': url,
|
||||||
'image_type': image_type,
|
'image_type': image_type,
|
||||||
'image': image,
|
'image': image
|
||||||
'vcard_updated': converse.toISOString(new Date())
|
|
||||||
});
|
});
|
||||||
}, this),
|
}, this),
|
||||||
$.proxy(function (stanza) {
|
$.proxy(function (stanza) {
|
||||||
@ -2110,9 +2109,13 @@
|
|||||||
}
|
}
|
||||||
chatbox = this.get(partner_jid);
|
chatbox = this.get(partner_jid);
|
||||||
roster_item = converse.roster.get(partner_jid);
|
roster_item = converse.roster.get(partner_jid);
|
||||||
|
|
||||||
if (roster_item === undefined) {
|
if (roster_item === undefined) {
|
||||||
|
// The buddy was likely removed
|
||||||
converse.log('Could not get roster item for JID '+partner_jid, 'error');
|
converse.log('Could not get roster item for JID '+partner_jid, 'error');
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!chatbox) {
|
if (!chatbox) {
|
||||||
chatbox = this.create({
|
chatbox = this.create({
|
||||||
'id': partner_jid,
|
'id': partner_jid,
|
||||||
@ -2287,21 +2290,21 @@
|
|||||||
|
|
||||||
this.$el.addClass(item.get('chat_status'));
|
this.$el.addClass(item.get('chat_status'));
|
||||||
|
|
||||||
if (ask === 'subscribe') {
|
if ((ask === 'subscribe') && (converse.allow_contact_requests)) {
|
||||||
this.$el.addClass('pending-xmpp-contact');
|
this.$el.addClass('pending-xmpp-contact');
|
||||||
this.$el.html(this.pending_template(item.toJSON()));
|
this.$el.html(this.pending_template(item.toJSON()));
|
||||||
} else if (ask === 'request') {
|
} else if ((ask === 'request') && (converse.allow_contact_requests)) {
|
||||||
this.$el.addClass('requesting-xmpp-contact');
|
this.$el.addClass('requesting-xmpp-contact');
|
||||||
this.$el.html(this.request_template(item.toJSON()));
|
this.$el.html(this.request_template(item.toJSON()));
|
||||||
converse.showControlBox();
|
converse.showControlBox();
|
||||||
} else if (subscription === 'both' || subscription === 'to') {
|
} else if (subscription === 'both' || ((subscription === 'to') && converse.allow_contact_requests)) {
|
||||||
this.$el.addClass('current-xmpp-contact');
|
this.$el.addClass('current-xmpp-contact');
|
||||||
this.$el.html(this.template(
|
this.$el.html(this.template(
|
||||||
_.extend(item.toJSON(), {'status_desc': statuses[item.get('chat_status')||'offline']})
|
_.extend(item.toJSON(), {'status_desc': statuses[item.get('chat_status')||'offline']})
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.getVCard = function (jid, callback, errback) {
|
this.getVCard = function (jid, callback, errback) {
|
||||||
@ -2549,6 +2552,10 @@
|
|||||||
if ((presence_type === 'subscribed') || (presence_type === 'unsubscribe')) {
|
if ((presence_type === 'subscribed') || (presence_type === 'unsubscribe')) {
|
||||||
return true;
|
return true;
|
||||||
} else if (presence_type === 'subscribe') {
|
} else if (presence_type === 'subscribe') {
|
||||||
|
if (!converse.allow_contact_requests) {
|
||||||
|
converse.connection.roster.unauthorize(bare_jid);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (converse.auto_subscribe) {
|
if (converse.auto_subscribe) {
|
||||||
if ((!item) || (item.get('subscription') != 'to')) {
|
if ((!item) || (item.get('subscription') != 'to')) {
|
||||||
this.subscribeBack(jid);
|
this.subscribeBack(jid);
|
||||||
@ -2559,25 +2566,32 @@
|
|||||||
if ((item) && (item.get('subscription') != 'none')) {
|
if ((item) && (item.get('subscription') != 'none')) {
|
||||||
converse.connection.roster.authorize(bare_jid);
|
converse.connection.roster.authorize(bare_jid);
|
||||||
} else {
|
} else {
|
||||||
converse.getVCard(
|
if (!this.get(bare_jid)) {
|
||||||
bare_jid,
|
// TODO: we can perhaps do the creation inside
|
||||||
$.proxy(function (jid, fullname, img, img_type, url) {
|
// getVCard.
|
||||||
this.add({
|
converse.getVCard(
|
||||||
jid: bare_jid,
|
bare_jid,
|
||||||
subscription: 'none',
|
$.proxy(function (jid, fullname, img, img_type, url) {
|
||||||
ask: 'request',
|
this.add({
|
||||||
fullname: fullname,
|
jid: bare_jid,
|
||||||
image: img,
|
subscription: 'none',
|
||||||
image_type: img_type,
|
ask: 'request',
|
||||||
url: url,
|
fullname: fullname,
|
||||||
is_last: true
|
image: img,
|
||||||
});
|
image_type: img_type,
|
||||||
}, this),
|
url: url,
|
||||||
$.proxy(function (jid, fullname, img, img_type, url) {
|
vcard_updated: converse.toISOString(new Date()),
|
||||||
converse.log("Error while retrieving vcard");
|
is_last: true
|
||||||
this.add({jid: bare_jid, subscription: 'none', ask: 'request', fullname: jid, is_last: true});
|
});
|
||||||
}, this)
|
}, this),
|
||||||
);
|
$.proxy(function (jid, fullname, img, img_type, url) {
|
||||||
|
converse.log("Error while retrieving vcard");
|
||||||
|
this.add({jid: bare_jid, subscription: 'none', ask: 'request', fullname: jid, is_last: true});
|
||||||
|
}, this)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (presence_type === 'unsubscribed') {
|
} else if (presence_type === 'unsubscribed') {
|
||||||
@ -2611,6 +2625,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
requesting_contacts_template: _.template(
|
||||||
|
'<dt id="xmpp-contact-requests">'+__('Contact requests')+'</dt>'),
|
||||||
|
|
||||||
|
contacts_template: _.template(
|
||||||
|
'<dt id="xmpp-contacts">'+__('My contacts')+'</dt>'),
|
||||||
|
|
||||||
|
pending_contacts_template: _.template(
|
||||||
|
'<dt id="pending-xmpp-contacts">'+__('Pending contacts')+'</dt>'),
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
this.model.on("add", function (item) {
|
this.model.on("add", function (item) {
|
||||||
var view = new converse.RosterItemView({model: item});
|
var view = new converse.RosterItemView({model: item});
|
||||||
@ -2634,7 +2657,12 @@
|
|||||||
this.model.on("remove", function (item) { this.removeRosterItem(item); }, this);
|
this.model.on("remove", function (item) { this.removeRosterItem(item); }, this);
|
||||||
this.model.on("destroy", function (item) { this.removeRosterItem(item); }, this);
|
this.model.on("destroy", function (item) { this.removeRosterItem(item); }, this);
|
||||||
|
|
||||||
this.$el.hide().html(this.template());
|
var roster_markup = this.contacts_template()
|
||||||
|
if (converse.allow_contact_requests) {
|
||||||
|
roster_markup = this.requesting_contacts_template() + roster_markup + this.pending_contacts_template();
|
||||||
|
}
|
||||||
|
this.$el.hide().html(roster_markup);
|
||||||
|
|
||||||
this.model.fetch({
|
this.model.fetch({
|
||||||
add: true,
|
add: true,
|
||||||
success: function (model, resp, options) {
|
success: function (model, resp, options) {
|
||||||
@ -2664,10 +2692,6 @@
|
|||||||
chatbox.save(changes);
|
chatbox.save(changes);
|
||||||
},
|
},
|
||||||
|
|
||||||
template: _.template('<dt id="xmpp-contact-requests">'+__('Contact requests')+'</dt>' +
|
|
||||||
'<dt id="xmpp-contacts">'+__('My contacts')+'</dt>' +
|
|
||||||
'<dt id="pending-xmpp-contacts">'+__('Pending contacts')+'</dt>'),
|
|
||||||
|
|
||||||
render: function (item) {
|
render: function (item) {
|
||||||
var $my_contacts = this.$el.find('#xmpp-contacts'),
|
var $my_contacts = this.$el.find('#xmpp-contacts'),
|
||||||
$contact_requests = this.$el.find('#xmpp-contact-requests'),
|
$contact_requests = this.$el.find('#xmpp-contact-requests'),
|
||||||
|
@ -465,6 +465,16 @@ JS file so that it will include the new settings. Please refer to the
|
|||||||
Configuration variables
|
Configuration variables
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
|
allow_contact_requests
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
Default = ``true``
|
||||||
|
|
||||||
|
Allow users to add one another as contacts. If this is set to false, the
|
||||||
|
**Add a contact** widget, **Contact Requests** and **Pending Contacts** roster
|
||||||
|
sections will all not appear. Additionally, all incoming contact requests will be
|
||||||
|
ignored.
|
||||||
|
|
||||||
allow_muc
|
allow_muc
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user