Skip to content

Commit

Permalink
A user can now add himself as a contact
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaosKid42 committed Jan 13, 2020
1 parent e2d744d commit bebe316
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -6,6 +6,7 @@
- #1820: Set focus on jid field after controlbox is loaded
- #1823: New config options [muc_roomid_policy](https://conversejs.org/docs/html/configuration.html#muc-roomid-policy)
and [muc_roomid_policy_hint](https://conversejs.org/docs/html/configuration.html#muc-roomid-policy-hint)
- #1826: A user can now add himself as a contact

## 6.0.0 (2020-01-09)

Expand Down
14 changes: 10 additions & 4 deletions src/converse-rosterview.js
Expand Up @@ -358,7 +358,8 @@ converse.plugins.add('converse-rosterview', {
const ask = this.model.get('ask'),
show = this.model.presence.get('show'),
requesting = this.model.get('requesting'),
subscription = this.model.get('subscription');
subscription = this.model.get('subscription'),
jid = this.model.get('jid');

const classes_to_remove = [
'current-xmpp-contact',
Expand Down Expand Up @@ -414,7 +415,7 @@ converse.plugins.add('converse-rosterview', {
'allow_chat_pending_contacts': _converse.allow_chat_pending_contacts
})
);
} else if (subscription === 'both' || subscription === 'to') {
} else if (subscription === 'both' || subscription === 'to' || _converse.rosterview.isSelf(jid)) {
this.el.classList.add('current-xmpp-contact');
this.el.classList.remove(without(['both', 'to'], subscription)[0]);
this.el.classList.add(subscription);
Expand Down Expand Up @@ -947,13 +948,18 @@ converse.plugins.add('converse-rosterview', {
groups.forEach(g => this.addContactToGroup(contact, g, options));
},

isSelf (jid) {
return u.isSameBareJID(jid, _converse.connection.jid);
},

addRosterContact (contact, options) {
if (contact.get('subscription') === 'both' || contact.get('subscription') === 'to') {
const jid = contact.get('jid');
if (contact.get('subscription') === 'both' || contact.get('subscription') === 'to' || this.isSelf(jid)) {
this.addExistingContact(contact, options);
} else {
if (!_converse.allow_contact_requests) {
log.debug(
`Not adding requesting or pending contact ${contact.get('jid')} `+
`Not adding requesting or pending contact ${jid} `+
`because allow_contact_requests is false`
);
return;
Expand Down
1 change: 0 additions & 1 deletion src/headless/converse-roster.js
Expand Up @@ -655,7 +655,6 @@ converse.plugins.add('converse-roster', {
*/
updateContact (item) {
const jid = item.getAttribute('jid');
if (this.isSelf(jid)) { return; }

const contact = this.get(jid);
const subscription = item.getAttribute("subscription");
Expand Down

0 comments on commit bebe316

Please sign in to comment.