Update vcard.get
API method to accept either a JID string or a model
This commit is contained in:
parent
b6f10f0efe
commit
54cafb1243
20
CHANGES.md
20
CHANGES.md
@ -1,25 +1,25 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## Http-File-Upload
|
## 4.0.0 (Unreleased)
|
||||||
|
|
||||||
## New Features
|
## New Features
|
||||||
|
|
||||||
- Support for rendering URLs sent according to XEP-0066 Out of Band Data.
|
|
||||||
- MP4 and MP3 files when sent as XEP-0066 Out of Band Data, are now playable directly in chat
|
|
||||||
- Automatically grow/shrink input as text is entered/removed
|
|
||||||
- #161 XEP-0363: HTTP File Upload
|
- #161 XEP-0363: HTTP File Upload
|
||||||
|
- Automatically grow/shrink input as text is entered/removed
|
||||||
|
- MP4 and MP3 files when sent as XEP-0066 Out of Band Data, are now playable directly in chat
|
||||||
|
- Support for rendering URLs sent according to XEP-0066 Out of Band Data.
|
||||||
|
- Geo-URIs (e.g. from Conversations) are now replaced by links to openstreetmap (works in reverse also)
|
||||||
|
|
||||||
## 4.0.0 (Unreleased)
|
### API changes
|
||||||
|
- `_converse.api.vcard.get` now also accepts a `Backbone.Model` instance and
|
||||||
|
has an additional `force` parameter to force fetching the vcard even if it
|
||||||
|
has already been fetched.
|
||||||
|
|
||||||
## UI changes
|
## UI changes
|
||||||
|
|
||||||
- The UI is now based on Bootstrap4 and Flexbox is used extensively.
|
- The UI is now based on Bootstrap4 and Flexbox is used extensively.
|
||||||
- #956 Conversation pane should show my own identity in pane header
|
- #956 Conversation pane should show my own identity in pane header
|
||||||
|
|
||||||
## New Features
|
|
||||||
|
|
||||||
- geo-URIs (e.g. from Conversations) are now replaced by links to openstreetmap (works in reverse also)
|
|
||||||
|
|
||||||
## Configuration changes
|
## Configuration changes
|
||||||
|
|
||||||
- Removed the `xhr_custom_status` and `xhr_custom_status_url` configuration
|
- Removed the `xhr_custom_status` and `xhr_custom_status_url` configuration
|
||||||
@ -94,7 +94,7 @@
|
|||||||
- Maintain MUC session upon page reload
|
- Maintain MUC session upon page reload
|
||||||
|
|
||||||
### API changes
|
### API changes
|
||||||
- New API method `_converse.disco.getIdentity` to check whether a JID has a given identity.
|
- New API method `_converse.api.disco.getIdentity` to check whether a JID has a given identity.
|
||||||
|
|
||||||
### Configuration settings
|
### Configuration settings
|
||||||
- `auto_reconnect` is now set to `true` by default.
|
- `auto_reconnect` is now set to `true` by default.
|
||||||
|
@ -1262,7 +1262,18 @@ The **vcard** grouping
|
|||||||
get
|
get
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
Returns a Promise which results with the VCard data for a particular JID.
|
Parameters:
|
||||||
|
|
||||||
|
* ``model`` either a `Backbone.Model` instance, or a string JID.
|
||||||
|
* ``force`` (optional), a boolean indicating whether the vcard should be
|
||||||
|
fetched even if it's been fetched before.
|
||||||
|
|
||||||
|
Returns a Promise which results with the VCard data for a particular JID or for
|
||||||
|
a `Backbone.Model` instance which represents an entity with a JID (such as a roster contact,
|
||||||
|
chatbox or chatroom occupant).
|
||||||
|
|
||||||
|
If a `Backbone.Model` instance is passed in, then it must have either a `jid`
|
||||||
|
attribute or a `muc_jid` attribute.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
@ -175,29 +175,33 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
_converse.on('initialized', () => {
|
_converse.on('initialized', () => {
|
||||||
_converse.roster.on("add", (contact) => {
|
_converse.roster.on("add", (contact) => _converse.api.vcard.get(contact));
|
||||||
if (!contact.get('vcard_updated')) {
|
|
||||||
_converse.api.vcard.get(contact.get('jid'));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
_converse.on('statusInitialized', function fetchOwnVCard () {
|
_converse.on('statusInitialized', function fetchOwnVCard () {
|
||||||
if (_.isNil(_converse.xmppstatus.get('vcard_updated'))) {
|
_converse.api.disco.supports(Strophe.NS.VCARD, _converse.domain)
|
||||||
_converse.api.disco.supports(Strophe.NS.VCARD, _converse.domain)
|
.then((result) => {
|
||||||
.then((result) => {
|
if (result.length) {
|
||||||
if (result.length) {
|
_converse.api.vcard.get(_converse.xmppstatus)
|
||||||
_converse.api.vcard.get(_converse.bare_jid)
|
.then((vcard) => _converse.xmppstatus.save(vcard));
|
||||||
.then((vcard) => _converse.xmppstatus.save(vcard));
|
}})
|
||||||
}})
|
.catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
|
||||||
.catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
_.extend(_converse.api, {
|
_.extend(_converse.api, {
|
||||||
'vcard': {
|
'vcard': {
|
||||||
'get' (jid) {
|
'get' (model, force) {
|
||||||
return getVCard(_converse, jid);
|
if (_.isString(model)) {
|
||||||
|
return getVCard(_converse, model);
|
||||||
|
} else if (!model.get('vcard_updated') || force) {
|
||||||
|
const jid = model.get('jid') || model.get('muc_jid');
|
||||||
|
if (!jid) {
|
||||||
|
throw new Error("No JID to get vcard for!");
|
||||||
|
}
|
||||||
|
return getVCard(_converse, jid);
|
||||||
|
} else {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user