From b6d4c6dfae6e5494d6bfa5be236cd6b37b6784ee Mon Sep 17 00:00:00 2001 From: JC Brand Date: Fri, 17 Jan 2025 22:32:05 +0200 Subject: [PATCH] Add `x` element to MUC private messages --- src/headless/plugins/muc/occupant.js | 12 ++++++++ src/headless/types/plugins/muc/occupant.d.ts | 29 ++++++++++--------- .../muc-views/tests/muc-private-messages.js | 1 + src/plugins/rosterview/contactview.js | 2 +- src/types/plugins/omemo/utils.d.ts | 1 - 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/headless/plugins/muc/occupant.js b/src/headless/plugins/muc/occupant.js index 3b3b81f2bd..3a4eb00a5e 100644 --- a/src/headless/plugins/muc/occupant.js +++ b/src/headless/plugins/muc/occupant.js @@ -2,6 +2,7 @@ import { Model } from '@converse/skeletor'; import log from '../../log'; import api from '../../shared/api/index.js'; import _converse from '../../shared/_converse.js'; +import converse from '../../shared/api/public.js'; import ColorAwareModel from '../../shared/color.js'; import ModelWithMessages from '../../shared/model-with-messages.js'; import { AFFILIATIONS, ROLES } from './constants.js'; @@ -10,6 +11,8 @@ import u from '../../utils/index.js'; import { shouldCreateGroupchatMessage } from './utils'; import { sendChatState } from '../../shared/actions'; +const { Strophe, stx } = converse.env; + /** * Represents a participant in a MUC */ @@ -189,6 +192,15 @@ class MUCOccupant extends ModelWithMessages(ColorAwareModel(Model)) { attrs = await api.hook('getOutgoingMessageAttributes', this, attrs); return attrs; } + + /** + * @param {import('../chat/message').default} message - The message object + */ + async createMessageStanza(message) { + const stanza = await super.createMessageStanza(message); + stanza.cnode(stx``).root(); + return stanza; + } } export default MUCOccupant; diff --git a/src/headless/types/plugins/muc/occupant.d.ts b/src/headless/types/plugins/muc/occupant.d.ts index ffa54a5bab..c915aacdf4 100644 --- a/src/headless/types/plugins/muc/occupant.d.ts +++ b/src/headless/types/plugins/muc/occupant.d.ts @@ -18,20 +18,20 @@ declare const MUCOccupant_base: { fetchMessages(): any; afterMessagesFetched(): void; onMessage(_attrs_or_error: import("../chat/types").MessageAttributes | Error): Promise; - getUpdatedMessageAttributes(message: import("../chat").Message, attrs: import("../chat/types").MessageAttributes): object; - updateMessage(message: import("../chat").Message, attrs: import("../chat/types").MessageAttributes): void; - handleCorrection(attrs: import("../chat/types").MessageAttributes | import("./types").MUCMessageAttributes): Promise; + getUpdatedMessageAttributes(message: import("../chat/message").default, attrs: import("../chat/types").MessageAttributes): object; + updateMessage(message: import("../chat/message").default, attrs: import("../chat/types").MessageAttributes): void; + handleCorrection(attrs: import("../chat/types").MessageAttributes | import("./types").MUCMessageAttributes): Promise; queueMessage(attrs: import("../chat/types").MessageAttributes): any; msg_chain: any; getOutgoingMessageAttributes(_attrs?: import("../chat/types").MessageAttributes): Promise; - sendMessage(attrs?: any): Promise; - retractOwnMessage(message: import("../chat").Message): void; + sendMessage(attrs?: any): Promise; + retractOwnMessage(message: import("../chat/message").default): void; sendFiles(files: File[]): Promise; setEditable(attrs: any, send_time: string): void; setChatState(state: string, options?: object): any; chat_state_timeout: NodeJS.Timeout; - onMessageAdded(message: import("../chat").Message): void; - onMessageUploadChanged(message: import("../chat").Message): Promise; + onMessageAdded(message: import("../chat/message").default): void; + onMessageUploadChanged(message: import("../chat/message").default): Promise; onScrolledChanged(): void; pruneHistoryWhenScrolledDown(): void; shouldShowErrorMessage(attrs: import("../chat/types").MessageAttributes): Promise; @@ -41,8 +41,8 @@ declare const MUCOccupant_base: { getOldestMessage(): any; getMostRecentMessage(): any; getMessageReferencedByError(attrs: object): any; - findDanglingRetraction(attrs: object): import("../chat").Message | null; - getDuplicateMessage(attrs: object): import("../chat").Message; + findDanglingRetraction(attrs: object): import("../chat/message").default | null; + getDuplicateMessage(attrs: object): import("../chat/message").default; getOriginIdQueryAttrs(attrs: object): { origin_id: any; from: any; @@ -52,15 +52,15 @@ declare const MUCOccupant_base: { from: any; msgid: any; }; - sendMarkerForMessage(msg: import("../chat").Message, type?: ("received" | "displayed" | "acknowledged"), force?: boolean): Promise; - handleUnreadMessage(message: import("../chat").Message): void; - getErrorAttributesForMessage(message: import("../chat").Message, attrs: import("../chat/types").MessageAttributes): Promise; + sendMarkerForMessage(msg: import("../chat/message").default, type?: ("received" | "displayed" | "acknowledged"), force?: boolean): Promise; + handleUnreadMessage(message: import("../chat/message").default): void; + getErrorAttributesForMessage(message: import("../chat/message").default, attrs: import("../chat/types").MessageAttributes): Promise; handleErrorMessageStanza(stanza: Element): Promise; - incrementUnreadMsgsCounter(message: import("../chat").Message): void; + incrementUnreadMsgsCounter(message: import("../chat/message").default): void; clearUnreadMsgCounter(): void; handleRetraction(attrs: import("../chat/types").MessageAttributes): Promise; handleReceipt(attrs: import("../chat/types").MessageAttributes): boolean; - createMessageStanza(message: import("../chat").Message): Promise; + createMessageStanza(message: import("../chat/message").default): Promise; pruneHistory(): void; debouncedPruneHistory: import("lodash").DebouncedFunc<() => void>; isScrolledUp(): any; @@ -214,6 +214,7 @@ declare class MUCOccupant extends MUCOccupant_base { states: any[]; hidden: boolean; num_unread: number; + message_type: string; }; save(key: any, val: any, options: any): any; getMessagesCollection(): MUCMessages; diff --git a/src/plugins/muc-views/tests/muc-private-messages.js b/src/plugins/muc-views/tests/muc-private-messages.js index 9557234e39..8a4218cf2b 100644 --- a/src/plugins/muc-views/tests/muc-private-messages.js +++ b/src/plugins/muc-views/tests/muc-private-messages.js @@ -139,6 +139,7 @@ describe('MUC Private Messages', () => { + `); }) ); diff --git a/src/plugins/rosterview/contactview.js b/src/plugins/rosterview/contactview.js index c5e9ffd237..87eb18687a 100644 --- a/src/plugins/rosterview/contactview.js +++ b/src/plugins/rosterview/contactview.js @@ -1,5 +1,5 @@ import { Model } from '@converse/skeletor'; -import { _converse, converse, api, log } from '@converse/headless'; +import { _converse, converse, api } from '@converse/headless'; import { CustomElement } from 'shared/components/element.js'; import tplRequestingContact from './templates/requesting_contact.js'; import tplRosterItem from './templates/roster_item.js'; diff --git a/src/types/plugins/omemo/utils.d.ts b/src/types/plugins/omemo/utils.d.ts index ac4cccc70b..f4aa3148c0 100644 --- a/src/types/plugins/omemo/utils.d.ts +++ b/src/types/plugins/omemo/utils.d.ts @@ -25,7 +25,6 @@ export function parseEncryptedMessage(stanza: Element, attrs: (MUCMessageAttribu export function onChatBoxesInitialized(): void; export function onChatInitialized(el: any): void; export function getSessionCipher(jid: any, id: any): any; -export function addKeysToMessageStanza(stanza: any, dicts: any, iv: any): Promise; /** * Given an XML element representing a user's OMEMO bundle, parse it * and return a map.