|
|
@ -1,7 +1,7 @@ |
|
|
|
import ProgressivePreloader from "../../components/preloader"; |
|
|
|
import ProgressivePreloader from "../../components/preloader"; |
|
|
|
import { CancellablePromise, deferredPromise } from "../../helpers/cancellablePromise"; |
|
|
|
import { CancellablePromise, deferredPromise } from "../../helpers/cancellablePromise"; |
|
|
|
import { Dialog as MTDialog, DialogFilter, DialogPeer, DocumentAttribute, InputMessage, Message, MessagesDialogs, MessagesFilter, MessagesMessages, MessagesPeerDialogs, MethodDeclMap, PhotoSize, Update } from "../../layer"; |
|
|
|
import { Dialog as MTDialog, DialogFilter, DialogPeer, DocumentAttribute, InputMessage, Message, MessagesDialogs, MessagesFilter, MessagesMessages, MessagesPeerDialogs, MethodDeclMap, PhotoSize, Update } from "../../layer"; |
|
|
|
import { Modify } from "../../types"; |
|
|
|
import { InvokeApiOptions, Modify } from "../../types"; |
|
|
|
import { bigint, nextRandomInt } from "../bin_utils"; |
|
|
|
import { bigint, nextRandomInt } from "../bin_utils"; |
|
|
|
import { logger } from "../logger"; |
|
|
|
import { logger } from "../logger"; |
|
|
|
import type { ApiFileManager } from '../mtproto/apiFileManager'; |
|
|
|
import type { ApiFileManager } from '../mtproto/apiFileManager'; |
|
|
@ -1997,38 +1997,29 @@ export class AppMessagesManager { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public forwardMessages(peerID: number, mids: number[], options: Partial<{ |
|
|
|
public forwardMessages(peerID: number, mids: number[], options: Partial<{ |
|
|
|
withMyScore: boolean |
|
|
|
withMyScore: true |
|
|
|
}> = {}) { |
|
|
|
}> = {}) { |
|
|
|
peerID = appPeersManager.getPeerMigratedTo(peerID) || peerID; |
|
|
|
peerID = appPeersManager.getPeerMigratedTo(peerID) || peerID; |
|
|
|
mids = mids.sort((a, b) => a - b); |
|
|
|
mids = mids.sort((a, b) => a - b); |
|
|
|
|
|
|
|
|
|
|
|
var flags = 0; |
|
|
|
const splitted = appMessagesIDsManager.splitMessageIDsByChannels(mids); |
|
|
|
if(options.withMyScore) { |
|
|
|
const promises: Promise<void>[] = []; |
|
|
|
flags |= 256; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let splitted = appMessagesIDsManager.splitMessageIDsByChannels(mids); |
|
|
|
for(const channelID in splitted.msgIDs) { |
|
|
|
let promises: any[] = []; |
|
|
|
const msgIDs = splitted.msgIDs[channelID]; |
|
|
|
|
|
|
|
const randomIDs: [number, number][] = msgIDs.map(() => [nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)]); |
|
|
|
for(let channelID in splitted.msgIDs) { |
|
|
|
|
|
|
|
let msgIDs = splitted.msgIDs[channelID]; |
|
|
|
|
|
|
|
let len = msgIDs.length; |
|
|
|
|
|
|
|
let randomIDs = []; |
|
|
|
|
|
|
|
for(let i = 0; i < len; i++) { |
|
|
|
|
|
|
|
randomIDs.push([nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let sentRequestOptions: any = {}; |
|
|
|
const sentRequestOptions: InvokeApiOptions = {}; |
|
|
|
if(this.pendingAfterMsgs[peerID]) { |
|
|
|
if(this.pendingAfterMsgs[peerID]) { |
|
|
|
sentRequestOptions.afterMessageID = this.pendingAfterMsgs[peerID].messageID; |
|
|
|
sentRequestOptions.afterMessageID = this.pendingAfterMsgs[peerID].messageID; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let promise = apiManager.invokeApi('messages.forwardMessages', { |
|
|
|
const promise = apiManager.invokeApi('messages.forwardMessages', { |
|
|
|
flags: flags, |
|
|
|
|
|
|
|
from_peer: appPeersManager.getInputPeerByID(-channelID), |
|
|
|
from_peer: appPeersManager.getInputPeerByID(-channelID), |
|
|
|
id: msgIDs, |
|
|
|
id: msgIDs, |
|
|
|
random_id: randomIDs as any, |
|
|
|
random_id: randomIDs as any, |
|
|
|
to_peer: appPeersManager.getInputPeerByID(peerID) |
|
|
|
to_peer: appPeersManager.getInputPeerByID(peerID), |
|
|
|
|
|
|
|
with_my_score: options.withMyScore |
|
|
|
}, sentRequestOptions).then((updates) => { |
|
|
|
}, sentRequestOptions).then((updates) => { |
|
|
|
apiUpdatesManager.processUpdateMessage(updates); |
|
|
|
apiUpdatesManager.processUpdateMessage(updates); |
|
|
|
}, () => {}).then(() => { |
|
|
|
}, () => {}).then(() => { |
|
|
|