diff --git a/conversejs/custom/index.js b/conversejs/custom/index.js index 00dbc0c6..0ca3368c 100644 --- a/conversejs/custom/index.js +++ b/conversejs/custom/index.js @@ -61,7 +61,7 @@ CORE_PLUGINS.push('livechat-converse-poll') // (see headless/plugins/muc, getDiscoInfoFeatures, which loops on this const) ROOM_FEATURES.push('x_peertubelivechat_mute_anonymous') -_converse.CustomElement = CustomElement +_converse.exports.CustomElement = CustomElement const initialize = converse.initialize diff --git a/conversejs/custom/shared/components/font-awesome.js b/conversejs/custom/shared/components/font-awesome.js index 8a93dfef..33b8c1b0 100644 --- a/conversejs/custom/shared/components/font-awesome.js +++ b/conversejs/custom/shared/components/font-awesome.js @@ -4,7 +4,7 @@ /* eslint-disable max-len */ import { html } from 'lit' -import tplIcons from '../../../src/shared/templates/icons.js' +import tplIcons from '../../../src/shared/components/templates/icons.js' export default () => { // Here we are adding some additonal icons to ConverseJS defaults diff --git a/conversejs/custom/templates/muc-bottom-panel.js b/conversejs/custom/templates/muc-bottom-panel.js index cf70e064..37ebc48b 100644 --- a/conversejs/custom/templates/muc-bottom-panel.js +++ b/conversejs/custom/templates/muc-bottom-panel.js @@ -79,7 +79,7 @@ class SlowMode extends CustomElement { api.elements.define('livechat-slow-mode', SlowMode) const tplSlowMode = (o) => { - if (!o.can_edit) { return html`` } + if (!o.can_post) { return html`` } return html`` } @@ -128,17 +128,9 @@ const tplViewerMode = (o) => { } export default (o) => { - // ConverseJS 10.x does not handle properly the visitor role in unmoderated rooms. - // See https://github.com/conversejs/converse.js/issues/3428 for more info. - // So we will do a dirty hack here to fix this case. - // Note: ConverseJS 11.x has changed the code, and could be fixed more cleanly (or will be fixed if #3428 is fixed). - if (o.can_edit && o.model.getOwnRole() === 'visitor') { - o.can_edit = false - } - let mutedAnonymousMessage if ( - !o.can_edit && + !o.can_post && o.model.features?.get?.('x_peertubelivechat_mute_anonymous') && _converse.api.settings.get('livechat_specific_is_anonymous') === true ) { diff --git a/conversejs/custom/webpack.livechat.js b/conversejs/custom/webpack.livechat.js index bf6e041c..6825b35b 100644 --- a/conversejs/custom/webpack.livechat.js +++ b/conversejs/custom/webpack.livechat.js @@ -44,7 +44,7 @@ module.exports = merge(prod, { '../../templates/background_logo.js$': path.resolve(__dirname, 'custom/templates/background_logo.js'), './templates/muc-chatarea.js': path.resolve('custom/templates/muc-chatarea.js'), - '../templates/icons.js': path.resolve(__dirname, 'custom/shared/components/font-awesome.js'), + './templates/icons.js': path.resolve(__dirname, 'custom/shared/components/font-awesome.js'), 'shared/styles/index.scss$': path.resolve(__dirname, 'custom/shared/styles/livechat.scss'), diff --git a/conversejs/lib/plugins/livechat-specific.ts b/conversejs/lib/plugins/livechat-specific.ts index 72ee34e8..c4926307 100644 --- a/conversejs/lib/plugins/livechat-specific.ts +++ b/conversejs/lib/plugins/livechat-specific.ts @@ -117,7 +117,7 @@ export const livechatSpecificsPlugin = { }, overrides: { ChatRoom: { - getActionInfoMessage: function (this: any, code: string, nick: string, actor: any): any { + getActionInfoMessage: function getActionInfoMessage (this: any, code: string, nick: string, actor: any): any { if (code === '303') { // When there is numerous anonymous users joining at the same time, // they can all change their nicknames at the same time, generating a log of action messages. @@ -130,6 +130,12 @@ export const livechatSpecificsPlugin = { } } return this.__super__.getActionInfoMessage(code, nick, actor) + }, + canPostMessages: function canPostMessages (this: any) { + // ConverseJS does not handle properly the visitor role in unmoderated rooms. + // See https://github.com/conversejs/converse.js/issues/3428 for more info. + // FIXME: if #3428 is fixed, remove this override. + return this.isEntered() && this.getOwnRole() !== 'visitor' } }, ChatRoomMessage: {