From 4e6176e8c8df7f0b6b965fb5ca43b0f3d73a6ea7 Mon Sep 17 00:00:00 2001 From: morethanwords Date: Sun, 12 Dec 2021 03:12:51 +0400 Subject: [PATCH] Fix forwarding changelog --- src/components/chat/contextMenu.ts | 4 ++-- src/lib/appManagers/appMessagesManager.ts | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/components/chat/contextMenu.ts b/src/components/chat/contextMenu.ts index 551ddaae..fcbbaf37 100644 --- a/src/components/chat/contextMenu.ts +++ b/src/components/chat/contextMenu.ts @@ -311,8 +311,8 @@ export default class ChatContextMenu { }, { icon: 'forward', text: 'Forward', - onClick: this.onForwardClick, - verify: () => this.chat.type !== 'scheduled' && !this.message.pFlags.is_outgoing && this.message._ !== 'messageService' + onClick: this.onForwardClick, // let forward the message if it's outgoing but not ours (like a changelog) + verify: () => this.chat.type !== 'scheduled' && (!this.message.pFlags.is_outgoing || !this.message.pFlags.out) && this.message._ !== 'messageService' }, { icon: 'forward', text: 'Message.Context.Selection.Forward', diff --git a/src/lib/appManagers/appMessagesManager.ts b/src/lib/appManagers/appMessagesManager.ts index 5fb002ed..f51a8da9 100644 --- a/src/lib/appManagers/appMessagesManager.ts +++ b/src/lib/appManagers/appMessagesManager.ts @@ -1900,6 +1900,24 @@ export class AppMessagesManager { peerId = appPeersManager.getPeerMigratedTo(peerId) || peerId; mids = mids.slice().sort((a, b) => a - b); + for(let i = 0, length = mids.length; i < length; ++i) { + const mid = mids[i]; + const originalMessage: Message.message = this.getMessageByPeer(fromPeerId, mid); + if(originalMessage.pFlags.is_outgoing) { // this can happen when forwarding a changelog + this.sendText(peerId, originalMessage.message, { + entities: originalMessage.entities, + scheduleDate: options.scheduleDate, + silent: options.silent + }); + + mids.splice(i--, 1); + } + } + + if(!mids.length) { + return Promise.resolve(); + } + if(options.dropCaptions) { options.dropAuthor = true; }