Message carbons
- Remove the `converse-carbons` plugin and make carbons part of the `converse-chat` plugin. - Remove the `message_carbons` configuration setting. Carbons are now always enabled.
This commit is contained in:
parent
12a0d0e3cc
commit
6573d080e4
@ -5,6 +5,8 @@
|
|||||||
- Don't automatically convert OpenStreetMap URLs into `geo:` URIs in sent messages
|
- Don't automatically convert OpenStreetMap URLs into `geo:` URIs in sent messages
|
||||||
- Remove the `allow_chat_pending_contacts` config option.
|
- Remove the `allow_chat_pending_contacts` config option.
|
||||||
- Show roster contacts with `subscription` set to `none`
|
- Show roster contacts with `subscription` set to `none`
|
||||||
|
- Remove the `converse-carbons` plugin and make carbons part of the `converse-chat` plugin.
|
||||||
|
- Remove the `message_carbons` configuration setting. Carbons are now always enabled.
|
||||||
|
|
||||||
## 9.1.1 (2022-05-05)
|
## 9.1.1 (2022-05-05)
|
||||||
|
|
||||||
|
@ -1202,22 +1202,6 @@ from the XMPP server.
|
|||||||
|
|
||||||
Used in conjunction with ``message_archiving`` and in context of `XEP-0313: Message Archive Management <https://xmpp.org/extensions/xep-0313.html>`_.
|
Used in conjunction with ``message_archiving`` and in context of `XEP-0313: Message Archive Management <https://xmpp.org/extensions/xep-0313.html>`_.
|
||||||
|
|
||||||
message_carbons
|
|
||||||
---------------
|
|
||||||
|
|
||||||
* Default: ``true``
|
|
||||||
|
|
||||||
Support for `XEP-0280: Message Carbons <https://xmpp.org/extensions/xep-0280.html>`_
|
|
||||||
|
|
||||||
In order to keep all IM clients for a user engaged in a conversation,
|
|
||||||
outbound messages are carbon-copied to all interested resources.
|
|
||||||
|
|
||||||
This is especially important with Converse, where each browser
|
|
||||||
tab serves as a separate IM client.
|
|
||||||
|
|
||||||
XEP-0280 requires server support, so make sure that message carbons are enabled
|
|
||||||
on your server.
|
|
||||||
|
|
||||||
|
|
||||||
message_limit
|
message_limit
|
||||||
-------------
|
-------------
|
||||||
|
@ -6,7 +6,6 @@ import "./plugins/adhoc.js"; // XEP-0050 Ad Hoc Commands
|
|||||||
import "./plugins/bookmarks/index.js"; // XEP-0199 XMPP Ping
|
import "./plugins/bookmarks/index.js"; // XEP-0199 XMPP Ping
|
||||||
import "./plugins/bosh.js"; // XEP-0206 BOSH
|
import "./plugins/bosh.js"; // XEP-0206 BOSH
|
||||||
import "./plugins/caps/index.js"; // XEP-0115 Entity Capabilities
|
import "./plugins/caps/index.js"; // XEP-0115 Entity Capabilities
|
||||||
import "./plugins/carbons.js"; // XEP-0280 Message Carbons
|
|
||||||
import "./plugins/chat/index.js"; // RFC-6121 Instant messaging
|
import "./plugins/chat/index.js"; // RFC-6121 Instant messaging
|
||||||
import "./plugins/chatboxes/index.js";
|
import "./plugins/chatboxes/index.js";
|
||||||
import "./plugins/disco/index.js"; // XEP-0030 Service discovery
|
import "./plugins/disco/index.js"; // XEP-0030 Service discovery
|
||||||
|
@ -1,61 +0,0 @@
|
|||||||
/**
|
|
||||||
* @module converse-carbons
|
|
||||||
* @copyright The Converse.js contributors
|
|
||||||
* @license Mozilla Public License (MPLv2)
|
|
||||||
* @description Implements support for XEP-0280 Message Carbons
|
|
||||||
*/
|
|
||||||
|
|
||||||
import log from '@converse/headless/log.js';
|
|
||||||
import { Strophe } from 'strophe.js/src/strophe';
|
|
||||||
import { _converse, api, converse } from "../core.js";
|
|
||||||
|
|
||||||
const { u } = converse.env;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ask the XMPP server to enable Message Carbons
|
|
||||||
* See [XEP-0280](https://xmpp.org/extensions/xep-0280.html#enabling)
|
|
||||||
*/
|
|
||||||
async function enableCarbons (reconnecting) {
|
|
||||||
if (reconnecting && _converse.session.get('carbons_enabled')) {
|
|
||||||
if (_converse.session.get('smacks_enabled')) {
|
|
||||||
// No need to re-enable carbons when resuming a XEP-0198 stream
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_converse.session.set({'carbons_enabled': false})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!api.settings.get("message_carbons") || _converse.session?.get('carbons_enabled')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const iq = new Strophe.Builder('iq', {
|
|
||||||
'from': _converse.connection.jid,
|
|
||||||
'type': 'set'
|
|
||||||
}).c('enable', {xmlns: Strophe.NS.CARBONS});
|
|
||||||
|
|
||||||
const result = await api.sendIQ(iq, null, false);
|
|
||||||
if (result === null) {
|
|
||||||
log.warn(`A timeout occurred while trying to enable carbons`);
|
|
||||||
} else if (u.isErrorStanza(result)) {
|
|
||||||
log.warn('An error occurred while trying to enable message carbons.');
|
|
||||||
log.error(result);
|
|
||||||
} else {
|
|
||||||
_converse.session.set({'carbons_enabled': true});
|
|
||||||
log.debug('Message carbons have been enabled.');
|
|
||||||
}
|
|
||||||
_converse.session.save(); // Gather multiple sets into one save
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
converse.plugins.add('converse-carbons', {
|
|
||||||
|
|
||||||
initialize () {
|
|
||||||
api.settings.extend({
|
|
||||||
message_carbons: true
|
|
||||||
});
|
|
||||||
|
|
||||||
api.listen.on('connected', () => enableCarbons());
|
|
||||||
api.listen.on('reconnected', () => enableCarbons(true));
|
|
||||||
}
|
|
||||||
});
|
|
@ -6,24 +6,18 @@ import ChatBox from './model.js';
|
|||||||
import MessageMixin from './message.js';
|
import MessageMixin from './message.js';
|
||||||
import ModelWithContact from './model-with-contact.js';
|
import ModelWithContact from './model-with-contact.js';
|
||||||
import chat_api from './api.js';
|
import chat_api from './api.js';
|
||||||
import { Collection } from "@converse/skeletor/src/collection";
|
import { Collection } from '@converse/skeletor/src/collection';
|
||||||
import { _converse, api, converse } from '../../core.js';
|
import { _converse, api, converse } from '../../core.js';
|
||||||
import { autoJoinChats, handleMessageStanza, onClearSession, openChat, registerMessageHandlers } from './utils.js';
|
import {
|
||||||
|
autoJoinChats,
|
||||||
|
enableCarbons,
|
||||||
|
handleMessageStanza,
|
||||||
|
onClearSession,
|
||||||
|
openChat,
|
||||||
|
registerMessageHandlers,
|
||||||
|
} from './utils.js';
|
||||||
|
|
||||||
converse.plugins.add('converse-chat', {
|
converse.plugins.add('converse-chat', {
|
||||||
/* Optional dependencies are other plugins which might be
|
|
||||||
* overridden or relied upon, and therefore need to be loaded before
|
|
||||||
* this plugin. They are called "optional" because they might not be
|
|
||||||
* available, in which case any overrides applicable to them will be
|
|
||||||
* ignored.
|
|
||||||
*
|
|
||||||
* It's possible however to make optional dependencies non-optional.
|
|
||||||
* If the setting "strict_plugin_dependencies" is set to true,
|
|
||||||
* an error will be raised if the plugin is not found.
|
|
||||||
*
|
|
||||||
* NB: These plugins need to have already been loaded via require.js.
|
|
||||||
*/
|
|
||||||
dependencies: ['converse-chatboxes', 'converse-disco'],
|
dependencies: ['converse-chatboxes', 'converse-disco'],
|
||||||
|
|
||||||
initialize () {
|
initialize () {
|
||||||
@ -40,14 +34,14 @@ converse.plugins.add('converse-chat', {
|
|||||||
'filter_by_resource': false,
|
'filter_by_resource': false,
|
||||||
'prune_messages_above': undefined,
|
'prune_messages_above': undefined,
|
||||||
'pruning_behavior': 'unscrolled',
|
'pruning_behavior': 'unscrolled',
|
||||||
'send_chat_markers': ["received", "displayed", "acknowledged"],
|
'send_chat_markers': ['received', 'displayed', 'acknowledged'],
|
||||||
'send_chat_state_notifications': true,
|
'send_chat_state_notifications': true,
|
||||||
});
|
});
|
||||||
|
|
||||||
_converse.Message = ModelWithContact.extend(MessageMixin);
|
_converse.Message = ModelWithContact.extend(MessageMixin);
|
||||||
_converse.Messages = Collection.extend({
|
_converse.Messages = Collection.extend({
|
||||||
model: _converse.Message,
|
model: _converse.Message,
|
||||||
comparator: 'time'
|
comparator: 'time',
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.assign(_converse, { ChatBox, handleMessageStanza });
|
Object.assign(_converse, { ChatBox, handleMessageStanza });
|
||||||
@ -58,5 +52,8 @@ converse.plugins.add('converse-chat', {
|
|||||||
api.listen.on('chatBoxesFetched', autoJoinChats);
|
api.listen.on('chatBoxesFetched', autoJoinChats);
|
||||||
api.listen.on('presencesInitialized', registerMessageHandlers);
|
api.listen.on('presencesInitialized', registerMessageHandlers);
|
||||||
api.listen.on('clearSession', onClearSession);
|
api.listen.on('clearSession', onClearSession);
|
||||||
}
|
|
||||||
|
api.listen.on('connected', () => enableCarbons());
|
||||||
|
api.listen.on('reconnected', () => enableCarbons(true));
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
@ -106,7 +106,6 @@ export function registerMessageHandlers () {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler method for all incoming single-user chat "message" stanzas.
|
* Handler method for all incoming single-user chat "message" stanzas.
|
||||||
* @private
|
|
||||||
* @param { MessageAttributes } attrs - The message attributes
|
* @param { MessageAttributes } attrs - The message attributes
|
||||||
*/
|
*/
|
||||||
export async function handleMessageStanza (stanza) {
|
export async function handleMessageStanza (stanza) {
|
||||||
@ -146,3 +145,39 @@ export async function handleMessageStanza (stanza) {
|
|||||||
*/
|
*/
|
||||||
api.trigger('message', data);
|
api.trigger('message', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ask the XMPP server to enable Message Carbons
|
||||||
|
* See [XEP-0280](https://xmpp.org/extensions/xep-0280.html#enabling)
|
||||||
|
* @param { Boolean } reconnecting
|
||||||
|
*/
|
||||||
|
export async function enableCarbons (reconnecting) {
|
||||||
|
if (reconnecting && _converse.session.get('carbons_enabled')) {
|
||||||
|
if (_converse.session.get('smacks_enabled')) {
|
||||||
|
// No need to re-enable carbons when resuming a XEP-0198 stream
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_converse.session.set({'carbons_enabled': false})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_converse.session?.get('carbons_enabled')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const iq = new Strophe.Builder('iq', {
|
||||||
|
'from': _converse.connection.jid,
|
||||||
|
'type': 'set'
|
||||||
|
}).c('enable', {xmlns: Strophe.NS.CARBONS});
|
||||||
|
|
||||||
|
const result = await api.sendIQ(iq, null, false);
|
||||||
|
if (result === null) {
|
||||||
|
log.warn(`A timeout occurred while trying to enable carbons`);
|
||||||
|
} else if (u.isErrorStanza(result)) {
|
||||||
|
log.warn('An error occurred while trying to enable message carbons.');
|
||||||
|
log.error(result);
|
||||||
|
} else {
|
||||||
|
_converse.session.set({'carbons_enabled': true});
|
||||||
|
log.debug('Message carbons have been enabled.');
|
||||||
|
}
|
||||||
|
_converse.session.save(); // Gather multiple sets into one save
|
||||||
|
}
|
||||||
|
@ -42,9 +42,7 @@ function addClientFeatures () {
|
|||||||
api.disco.own.features.add(Strophe.NS.CHATSTATES);
|
api.disco.own.features.add(Strophe.NS.CHATSTATES);
|
||||||
api.disco.own.features.add(Strophe.NS.DISCO_INFO);
|
api.disco.own.features.add(Strophe.NS.DISCO_INFO);
|
||||||
api.disco.own.features.add(Strophe.NS.ROSTERX); // Limited support
|
api.disco.own.features.add(Strophe.NS.ROSTERX); // Limited support
|
||||||
if (api.settings.get("message_carbons")) {
|
api.disco.own.features.add(Strophe.NS.CARBONS);
|
||||||
api.disco.own.features.add(Strophe.NS.CARBONS);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Triggered in converse-disco once the core disco features of
|
* Triggered in converse-disco once the core disco features of
|
||||||
* Converse have been added.
|
* Converse have been added.
|
||||||
|
@ -23,7 +23,6 @@ export const CORE_PLUGINS = [
|
|||||||
'converse-bookmarks',
|
'converse-bookmarks',
|
||||||
'converse-bosh',
|
'converse-bosh',
|
||||||
'converse-caps',
|
'converse-caps',
|
||||||
'converse-carbons',
|
|
||||||
'converse-chat',
|
'converse-chat',
|
||||||
'converse-chatboxes',
|
'converse-chatboxes',
|
||||||
'converse-disco',
|
'converse-disco',
|
||||||
|
Loading…
Reference in New Issue
Block a user