Browse Source

Support following messages by 'Forwarded from'

master
Eduard Kuzmenko 4 years ago
parent
commit
19afdd3179
  1. 19
      src/components/chat/bubbles.ts
  2. 2
      src/components/chat/messageRender.ts
  3. 17
      src/lib/appManagers/appMessagesManager.ts

19
src/components/chat/bubbles.ts

@ -817,8 +817,17 @@ export default class ChatBubbles {
} else if(target.classList.contains('name')) { } else if(target.classList.contains('name')) {
const peerId = +target.dataset.peerId; const peerId = +target.dataset.peerId;
if(peerId) { const savedFrom = target.dataset.savedFrom;
this.chat.appImManager.setInnerPeer(peerId); if(savedFrom) {
const splitted = savedFrom.split('_');
const peerId = +splitted[0];
const msgId = +splitted[1];
this.chat.appImManager.setInnerPeer(peerId, msgId);
} else {
if(peerId) {
this.chat.appImManager.setInnerPeer(peerId);
}
} }
return; return;
@ -2357,6 +2366,10 @@ export default class ChatBubbles {
/* const fromTitle = message.fromId == this.myID || appPeersManager.isBroadcast(message.fwdFromId || message.fromId) ? '' : `<div class="name" data-peer-id="${message.fromId}" style="color: ${appPeersManager.getPeerColorByID(message.fromId, false)};">${appPeersManager.getPeerTitle(message.fromId)}</div>`; /* const fromTitle = message.fromId == this.myID || appPeersManager.isBroadcast(message.fwdFromId || message.fromId) ? '' : `<div class="name" data-peer-id="${message.fromId}" style="color: ${appPeersManager.getPeerColorByID(message.fromId, false)};">${appPeersManager.getPeerTitle(message.fromId)}</div>`;
nameDiv.innerHTML = fromTitle + 'Forwarded from ' + title; */ nameDiv.innerHTML = fromTitle + 'Forwarded from ' + title; */
nameDiv.innerHTML = 'Forwarded from ' + title; nameDiv.innerHTML = 'Forwarded from ' + title;
if(savedFrom) {
nameDiv.dataset.savedFrom = savedFrom;
}
} }
nameContainer.append(nameDiv); nameContainer.append(nameDiv);
@ -2418,7 +2431,7 @@ export default class ChatBubbles {
bubble.classList.add('is-thread-starter', 'is-group-last'); bubble.classList.add('is-thread-starter', 'is-group-last');
} }
if(savedFrom && this.peerId !== REPLIES_PEER_ID) { if(savedFrom && this.peerId === rootScope.myId && this.peerId !== REPLIES_PEER_ID) {
const goto = document.createElement('div'); const goto = document.createElement('div');
goto.classList.add('bubble-beside-button', 'goto-original', 'tgico-arrow_next'); goto.classList.add('bubble-beside-button', 'goto-original', 'tgico-arrow_next');
bubbleContainer.append(goto); bubbleContainer.append(goto);

2
src/components/chat/messageRender.ts

@ -20,7 +20,7 @@ export namespace MessageRender {
bubble.classList.add('channel-post'); bubble.classList.add('channel-post');
time = formatNumber(message.views, 1) + ' <i class="tgico-channelviews time-icon"></i> ' + (postAuthor ? RichTextProcessor.wrapEmojiText(postAuthor) + ', ' : '') + time; time = formatNumber(message.views, 1) + ' <i class="tgico-channelviews time-icon"></i> ' + (postAuthor ? RichTextProcessor.wrapEmojiText(postAuthor) + ', ' : '') + time;
if(!message.savedFrom) { if(chat.peerId !== chat.appImManager.myId) {
const forward = document.createElement('div'); const forward = document.createElement('div');
forward.classList.add('bubble-beside-button', 'forward'); forward.classList.add('bubble-beside-button', 'forward');
forward.innerHTML = ` forward.innerHTML = `

17
src/lib/appManagers/appMessagesManager.ts

@ -6,7 +6,7 @@ import { createPosterForVideo } from "../../helpers/files";
import { copy, defineNotNumerableProperties, getObjectKeysAndSort } from "../../helpers/object"; import { copy, defineNotNumerableProperties, getObjectKeysAndSort } from "../../helpers/object";
import { randomLong } from "../../helpers/random"; import { randomLong } from "../../helpers/random";
import { splitStringByLength, limitSymbols } from "../../helpers/string"; import { splitStringByLength, limitSymbols } from "../../helpers/string";
import { Dialog as MTDialog, DialogPeer, DocumentAttribute, InputMedia, InputMessage, InputNotifyPeer, InputPeerNotifySettings, InputSingleMedia, Message, MessageAction, MessageEntity, MessageMedia, MessageReplies, MessageReplyHeader, MessagesDialogs, MessagesFilter, MessagesMessages, MessagesPeerDialogs, MethodDeclMap, NotifyPeer, PhotoSize, SendMessageAction, Update } from "../../layer"; import { Dialog as MTDialog, DialogPeer, DocumentAttribute, InputMedia, InputMessage, InputNotifyPeer, InputPeerNotifySettings, InputSingleMedia, Message, MessageAction, MessageEntity, MessageFwdHeader, MessageMedia, MessageReplies, MessageReplyHeader, MessagesDialogs, MessagesFilter, MessagesMessages, MessagesPeerDialogs, MethodDeclMap, NotifyPeer, PhotoSize, SendMessageAction, Update } from "../../layer";
import { InvokeApiOptions } from "../../types"; import { InvokeApiOptions } from "../../types";
import { langPack } from "../langPack"; import { langPack } from "../langPack";
import { logger, LogLevels } from "../logger"; import { logger, LogLevels } from "../logger";
@ -19,7 +19,6 @@ import serverTimeManager from "../mtproto/serverTimeManager";
import { RichTextProcessor } from "../richtextprocessor"; import { RichTextProcessor } from "../richtextprocessor";
import rootScope from "../rootScope"; import rootScope from "../rootScope";
import searchIndexManager from '../searchIndexManager'; import searchIndexManager from '../searchIndexManager';
import sessionStorage from '../sessionStorage';
import DialogsStorage from "../storages/dialogs"; import DialogsStorage from "../storages/dialogs";
import FiltersStorage from "../storages/filters"; import FiltersStorage from "../storages/filters";
//import { telegramMeWebService } from "../mtproto/mtproto"; //import { telegramMeWebService } from "../mtproto/mtproto";
@ -2140,13 +2139,17 @@ export class AppMessagesManager {
message.fromId = message.pFlags.post || !message.from_id ? peerId : appPeersManager.getPeerId(message.from_id); message.fromId = message.pFlags.post || !message.from_id ? peerId : appPeersManager.getPeerId(message.from_id);
} }
const fwdHeader = message.fwd_from; const fwdHeader = message.fwd_from as MessageFwdHeader;
if(fwdHeader) { if(fwdHeader) {
//if(peerId == myID) { //if(peerId == myID) {
if(fwdHeader.saved_from_peer && fwdHeader.saved_from_msg_id) { if(fwdHeader.saved_from_msg_id) fwdHeader.saved_from_msg_id = this.generateMessageId(fwdHeader.saved_from_msg_id);
const savedFromPeerId = appPeersManager.getPeerId(fwdHeader.saved_from_peer); if(fwdHeader.channel_post) fwdHeader.channel_post = this.generateMessageId(fwdHeader.channel_post);
//const savedFromMid = fwdHeader.saved_from_msg_id;
const savedFromMid = fwdHeader.saved_from_msg_id = this.generateMessageId(fwdHeader.saved_from_msg_id); const peer = fwdHeader.saved_from_peer || fwdHeader.from_id;
const msgId = fwdHeader.saved_from_msg_id || fwdHeader.channel_post;
if(peer && msgId) {
const savedFromPeerId = appPeersManager.getPeerId(peer);
const savedFromMid = this.generateMessageId(msgId);
message.savedFrom = savedFromPeerId + '_' + savedFromMid; message.savedFrom = savedFromPeerId + '_' + savedFromMid;
} }

Loading…
Cancel
Save