Browse Source

Fixed mixed forward messages

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

21
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,17 +1756,21 @@ 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 = [];
angular.forEach(splitted.msgIDs, function (msgIDs, channelID) {
var len = msgIDs.length;
var randomIDs = [];
for (var i = 0; i < len; i++) {
randomIDs.push([nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)]); randomIDs.push([nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)]);
} }
var sentRequestOptions = {}; var sentRequestOptions = {};
if (pendingAfterMsgs[peerID]) { if (pendingAfterMsgs[peerID]) {
sentRequestOptions.afterMessageID = pendingAfterMsgs[peerID].messageID; sentRequestOptions.afterMessageID = pendingAfterMsgs[peerID].messageID;
} }
return MtpApiManager.invokeApi('messages.forwardMessages', { var promise = MtpApiManager.invokeApi('messages.forwardMessages', {
flags: flags, flags: flags,
from_peer: AppPeersManager.getInputPeerByID(-fromChannel), from_peer: AppPeersManager.getInputPeerByID(-channelID),
id: msgIDs, id: msgIDs,
random_id: randomIDs, random_id: randomIDs,
to_peer: AppPeersManager.getInputPeerByID(peerID), to_peer: AppPeersManager.getInputPeerByID(peerID),
@ -1783,6 +1782,10 @@ angular.module('myApp.services')
} }
}); });
pendingAfterMsgs[peerID] = sentRequestOptions; pendingAfterMsgs[peerID] = sentRequestOptions;
promises.push(promise);
});
return $q.all(promises);
}; };
function startBot (botID, chatID, startParam) { function startBot (botID, chatID, startParam) {

Loading…
Cancel
Save