Converse converse.js

Namespace: vcard

_converse.api.vcard

The XEP-0054 VCard API

This API lets you access and update user VCards

Source:

Methods

(static) get(model, forceopt) → {promise}

Parameters:
Name Type Attributes Description
model Model | string

Either a Model instance, or a string JID. If a Model instance is passed in, then it must have either a jid attribute or a muc_jid attribute.

force boolean <optional>

A boolean indicating whether the vcard should be fetched from the server even if it's been fetched before.

Source:
Returns:

A Promise which resolves with the VCard data for a particular JID or for a Model instance which represents an entity with a JID (such as a roster contact, chat or chatroom occupant).

Type
promise
Example
const { api } = _converse;
api.waitUntil('rosterContactsFetched').then(() => {
    api.vcard.get('someone@example.org').then(
        (vcard) => {
            // Do something with the vcard...
        }
    );
});

(static) get(model, forceopt) → {promise}

Parameters:
Name Type Attributes Description
model Model | string

Either a Model instance, or a string JID. If a Model instance is passed in, then it must have either a jid attribute or a muc_jid attribute.

force boolean <optional>

A boolean indicating whether the vcard should be fetched from the server even if it's been fetched before.

Source:
Returns:

A Promise which resolves with the VCard data for a particular JID or for a Model instance which represents an entity with a JID (such as a roster contact, chat or chatroom occupant).

Type
promise
Example
const { api } = _converse;
api.waitUntil('rosterContactsFetched').then(() => {
    api.vcard.get('someone@example.org').then(
        (vcard) => {
            // Do something with the vcard...
        }
    );
});

(static) set(jid, data)

Enables setting new values for a VCard.

Sends out an IQ stanza to set the user's VCard and if successful, it updates the _converse.VCard for the passed in JID.

Parameters:
Name Type Description
jid string

The JID for which the VCard should be set

data object

A map of VCard keys and values

Source:
Example
let jid = _converse.bare_jid;
_converse.api.vcard.set( jid, {
    'fn': 'John Doe',
    'nickname': 'jdoe'
}).then(() => {
    // Succes
}).catch((e) => {
    // Failure, e is your error object
}).

(static) set(jid, data)

Enables setting new values for a VCard.

Sends out an IQ stanza to set the user's VCard and if successful, it updates the _converse.VCard for the passed in JID.

Parameters:
Name Type Description
jid string

The JID for which the VCard should be set

data object

A map of VCard keys and values

Source:
Example
let jid = _converse.bare_jid;
_converse.api.vcard.set( jid, {
    'fn': 'John Doe',
    'nickname': 'jdoe'
}).then(() => {
    // Succes
}).catch((e) => {
    // Failure, e is your error object
}).

(static) update(model, forceopt) → {promise}

Fetches the VCard associated with a particular Model instance (by using its jid or muc_jid attribute) and then updates the model with the returned VCard data.

Parameters:
Name Type Attributes Description
model Model

A Model instance

force boolean <optional>

A boolean indicating whether the vcard should be fetched again even if it's been fetched before.

Source:
Returns:

A promise which resolves once the update has completed.

Type
promise
Example
const { api } = _converse;
api.waitUntil('rosterContactsFetched').then(async () => {
    const chatbox = await api.chats.get('someone@example.org');
    api.vcard.update(chatbox);
});

(static) update(model, forceopt) → {promise}

Fetches the VCard associated with a particular Model instance (by using its jid or muc_jid attribute) and then updates the model with the returned VCard data.

Parameters:
Name Type Attributes Description
model Model

A Model instance

force boolean <optional>

A boolean indicating whether the vcard should be fetched again even if it's been fetched before.

Source:
Returns:

A promise which resolves once the update has completed.

Type
promise
Example
const { api } = _converse;
api.waitUntil('rosterContactsFetched').then(async () => {
    const chatbox = await api.chats.get('someone@example.org');
    api.vcard.update(chatbox);
});

_converse.api.vcard

The XEP-0054 VCard API

This API lets you access and update user VCards

Source:

Methods

(static) get(model, forceopt) → {promise}

Parameters:
Name Type Attributes Description
model Model | string

Either a Model instance, or a string JID. If a Model instance is passed in, then it must have either a jid attribute or a muc_jid attribute.

force boolean <optional>

A boolean indicating whether the vcard should be fetched from the server even if it's been fetched before.

Source:
Returns:

A Promise which resolves with the VCard data for a particular JID or for a Model instance which represents an entity with a JID (such as a roster contact, chat or chatroom occupant).

Type
promise
Example
const { api } = _converse;
api.waitUntil('rosterContactsFetched').then(() => {
    api.vcard.get('someone@example.org').then(
        (vcard) => {
            // Do something with the vcard...
        }
    );
});

(static) get(model, forceopt) → {promise}

Parameters:
Name Type Attributes Description
model Model | string

Either a Model instance, or a string JID. If a Model instance is passed in, then it must have either a jid attribute or a muc_jid attribute.

force boolean <optional>

A boolean indicating whether the vcard should be fetched from the server even if it's been fetched before.

Source:
Returns:

A Promise which resolves with the VCard data for a particular JID or for a Model instance which represents an entity with a JID (such as a roster contact, chat or chatroom occupant).

Type
promise
Example
const { api } = _converse;
api.waitUntil('rosterContactsFetched').then(() => {
    api.vcard.get('someone@example.org').then(
        (vcard) => {
            // Do something with the vcard...
        }
    );
});

(static) set(jid, data)

Enables setting new values for a VCard.

Sends out an IQ stanza to set the user's VCard and if successful, it updates the _converse.VCard for the passed in JID.

Parameters:
Name Type Description
jid string

The JID for which the VCard should be set

data object

A map of VCard keys and values

Source:
Example
let jid = _converse.bare_jid;
_converse.api.vcard.set( jid, {
    'fn': 'John Doe',
    'nickname': 'jdoe'
}).then(() => {
    // Succes
}).catch((e) => {
    // Failure, e is your error object
}).

(static) set(jid, data)

Enables setting new values for a VCard.

Sends out an IQ stanza to set the user's VCard and if successful, it updates the _converse.VCard for the passed in JID.

Parameters:
Name Type Description
jid string

The JID for which the VCard should be set

data object

A map of VCard keys and values

Source:
Example
let jid = _converse.bare_jid;
_converse.api.vcard.set( jid, {
    'fn': 'John Doe',
    'nickname': 'jdoe'
}).then(() => {
    // Succes
}).catch((e) => {
    // Failure, e is your error object
}).

(static) update(model, forceopt) → {promise}

Fetches the VCard associated with a particular Model instance (by using its jid or muc_jid attribute) and then updates the model with the returned VCard data.

Parameters:
Name Type Attributes Description
model Model

A Model instance

force boolean <optional>

A boolean indicating whether the vcard should be fetched again even if it's been fetched before.

Source:
Returns:

A promise which resolves once the update has completed.

Type
promise
Example
const { api } = _converse;
api.waitUntil('rosterContactsFetched').then(async () => {
    const chatbox = await api.chats.get('someone@example.org');
    api.vcard.update(chatbox);
});

(static) update(model, forceopt) → {promise}

Fetches the VCard associated with a particular Model instance (by using its jid or muc_jid attribute) and then updates the model with the returned VCard data.

Parameters:
Name Type Attributes Description
model Model

A Model instance

force boolean <optional>

A boolean indicating whether the vcard should be fetched again even if it's been fetched before.

Source:
Returns:

A promise which resolves once the update has completed.

Type
promise
Example
const { api } = _converse;
api.waitUntil('rosterContactsFetched').then(async () => {
    const chatbox = await api.chats.get('someone@example.org');
    api.vcard.update(chatbox);
});