Browse Source

Fixed mixed forward messages

master
Igor Zhukov 9 years ago
parent
commit
1dff028113
  1. 53
      app/js/messages_manager.js

53
app/js/messages_manager.js

@ -1748,11 +1748,6 @@ angular.module('myApp.services')
mids = mids.sort(); mids = mids.sort();
var flags = 0; var flags = 0;
var msgIDs = [];
var randomIDs = [];
var len = mids.length;
var i, mid, msgID;
var fromChannel = getMessageIDInfo(mids[0])[1];
var isChannel = AppPeersManager.isChannel(peerID); var isChannel = AppPeersManager.isChannel(peerID);
var isMegagroup = isChannel && AppPeersManager.isMegagroup(peerID); var isMegagroup = isChannel && AppPeersManager.isMegagroup(peerID);
var asChannel = isChannel && !isMegagroup ? true : false; var asChannel = isChannel && !isMegagroup ? true : false;
@ -1761,28 +1756,36 @@ angular.module('myApp.services')
flags |= 16; flags |= 16;
} }
for (i = 0; i < len; i++) { var splitted = splitMessageIDsByChannels(mids);
msgIDs.push(getMessageLocalID(mids[i])); var promises = [];
randomIDs.push([nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)]); angular.forEach(splitted.msgIDs, function (msgIDs, channelID) {
} var len = msgIDs.length;
var sentRequestOptions = {}; var randomIDs = [];
if (pendingAfterMsgs[peerID]) { for (var i = 0; i < len; i++) {
sentRequestOptions.afterMessageID = pendingAfterMsgs[peerID].messageID; randomIDs.push([nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)]);
} }
return MtpApiManager.invokeApi('messages.forwardMessages', { var sentRequestOptions = {};
flags: flags, if (pendingAfterMsgs[peerID]) {
from_peer: AppPeersManager.getInputPeerByID(-fromChannel), sentRequestOptions.afterMessageID = pendingAfterMsgs[peerID].messageID;
id: msgIDs,
random_id: randomIDs,
to_peer: AppPeersManager.getInputPeerByID(peerID),
}, sentRequestOptions).then(function (updates) {
ApiUpdatesManager.processUpdateMessage(updates);
})['finally'](function () {
if (pendingAfterMsgs[peerID] === sentRequestOptions) {
delete pendingAfterMsgs[peerID];
} }
var promise = MtpApiManager.invokeApi('messages.forwardMessages', {
flags: flags,
from_peer: AppPeersManager.getInputPeerByID(-channelID),
id: msgIDs,
random_id: randomIDs,
to_peer: AppPeersManager.getInputPeerByID(peerID),
}, sentRequestOptions).then(function (updates) {
ApiUpdatesManager.processUpdateMessage(updates);
})['finally'](function () {
if (pendingAfterMsgs[peerID] === sentRequestOptions) {
delete pendingAfterMsgs[peerID];
}
});
pendingAfterMsgs[peerID] = sentRequestOptions;
promises.push(promise);
}); });
pendingAfterMsgs[peerID] = sentRequestOptions;
return $q.all(promises);
}; };
function startBot (botID, chatID, startParam) { function startBot (botID, chatID, startParam) {

Loading…
Cancel
Save