|
|
@ -374,7 +374,7 @@ angular.module('myApp.services') |
|
|
|
var fullMsgIDModulus = 4294967296; |
|
|
|
var fullMsgIDModulus = 4294967296; |
|
|
|
|
|
|
|
|
|
|
|
function getFullMessageID (msgID, channelID) { |
|
|
|
function getFullMessageID (msgID, channelID) { |
|
|
|
if (!channelID) { |
|
|
|
if (!channelID || msgID < 0) { |
|
|
|
return msgID; |
|
|
|
return msgID; |
|
|
|
} |
|
|
|
} |
|
|
|
msgID = getMessageLocalID(msgID); |
|
|
|
msgID = getMessageLocalID(msgID); |
|
|
@ -1020,6 +1020,8 @@ angular.module('myApp.services') |
|
|
|
inputPeer = AppPeersManager.getInputPeerByID(peerID), |
|
|
|
inputPeer = AppPeersManager.getInputPeerByID(peerID), |
|
|
|
flags = 0, |
|
|
|
flags = 0, |
|
|
|
replyToMsgID = options.replyToMsgID, |
|
|
|
replyToMsgID = options.replyToMsgID, |
|
|
|
|
|
|
|
isChannel = AppPeersManager.isChannel(peerID), |
|
|
|
|
|
|
|
asChannel = isChannel ? true : false, |
|
|
|
entities = [], |
|
|
|
entities = [], |
|
|
|
message; |
|
|
|
message; |
|
|
|
|
|
|
|
|
|
|
@ -1032,13 +1034,18 @@ angular.module('myApp.services') |
|
|
|
MtpApiManager.getUserID().then(function (fromID) { |
|
|
|
MtpApiManager.getUserID().then(function (fromID) { |
|
|
|
if (peerID != fromID) { |
|
|
|
if (peerID != fromID) { |
|
|
|
flags |= 2; |
|
|
|
flags |= 2; |
|
|
|
if (!AppUsersManager.isBot(peerID)) { |
|
|
|
if (!isChannel && !AppUsersManager.isBot(peerID)) { |
|
|
|
flags |= 1; |
|
|
|
flags |= 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (replyToMsgID) { |
|
|
|
if (replyToMsgID) { |
|
|
|
flags |= 8; |
|
|
|
flags |= 8; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (asChannel) { |
|
|
|
|
|
|
|
fromID = 0; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
flags |= 256; |
|
|
|
|
|
|
|
} |
|
|
|
message = { |
|
|
|
message = { |
|
|
|
_: 'message', |
|
|
|
_: 'message', |
|
|
|
id: messageID, |
|
|
|
id: messageID, |
|
|
@ -1082,6 +1089,9 @@ angular.module('myApp.services') |
|
|
|
if (entities.length) { |
|
|
|
if (entities.length) { |
|
|
|
flags |= 8; |
|
|
|
flags |= 8; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (asChannel) { |
|
|
|
|
|
|
|
flags |= 16; |
|
|
|
|
|
|
|
} |
|
|
|
// console.log(flags, entities);
|
|
|
|
// console.log(flags, entities);
|
|
|
|
MtpApiManager.invokeApi('messages.sendMessage', { |
|
|
|
MtpApiManager.invokeApi('messages.sendMessage', { |
|
|
|
flags: flags, |
|
|
|
flags: flags, |
|
|
@ -1107,7 +1117,7 @@ angular.module('myApp.services') |
|
|
|
random_id: randomIDS, |
|
|
|
random_id: randomIDS, |
|
|
|
id: updates.id |
|
|
|
id: updates.id |
|
|
|
}, { |
|
|
|
}, { |
|
|
|
_: 'updateNewMessage', |
|
|
|
_: isChannel ? 'updateNewChannelMessage' : 'updateNewMessage', |
|
|
|
message: message, |
|
|
|
message: message, |
|
|
|
pts: updates.pts, |
|
|
|
pts: updates.pts, |
|
|
|
pts_count: updates.pts_count |
|
|
|
pts_count: updates.pts_count |
|
|
@ -1147,6 +1157,8 @@ angular.module('myApp.services') |
|
|
|
inputPeer = AppPeersManager.getInputPeerByID(peerID), |
|
|
|
inputPeer = AppPeersManager.getInputPeerByID(peerID), |
|
|
|
flags = 0, |
|
|
|
flags = 0, |
|
|
|
replyToMsgID = options.replyToMsgID, |
|
|
|
replyToMsgID = options.replyToMsgID, |
|
|
|
|
|
|
|
isChannel = AppPeersManager.isChannel(peerID), |
|
|
|
|
|
|
|
asChannel = isChannel ? true : false, |
|
|
|
attachType, apiFileName, realFileName; |
|
|
|
attachType, apiFileName, realFileName; |
|
|
|
|
|
|
|
|
|
|
|
if (!options.isMedia) { |
|
|
|
if (!options.isMedia) { |
|
|
@ -1173,13 +1185,18 @@ angular.module('myApp.services') |
|
|
|
MtpApiManager.getUserID().then(function (fromID) { |
|
|
|
MtpApiManager.getUserID().then(function (fromID) { |
|
|
|
if (peerID != fromID) { |
|
|
|
if (peerID != fromID) { |
|
|
|
flags |= 2; |
|
|
|
flags |= 2; |
|
|
|
if (!AppUsersManager.isBot(peerID)) { |
|
|
|
if (!isChannel && !AppUsersManager.isBot(peerID)) { |
|
|
|
flags |= 1; |
|
|
|
flags |= 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (replyToMsgID) { |
|
|
|
if (replyToMsgID) { |
|
|
|
flags |= 8; |
|
|
|
flags |= 8; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (asChannel) { |
|
|
|
|
|
|
|
fromID = 0; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
flags |= 256; |
|
|
|
|
|
|
|
} |
|
|
|
var media = { |
|
|
|
var media = { |
|
|
|
_: 'messageMediaPending', |
|
|
|
_: 'messageMediaPending', |
|
|
|
type: attachType, |
|
|
|
type: attachType, |
|
|
@ -1319,7 +1336,9 @@ angular.module('myApp.services') |
|
|
|
randomIDS = bigint(randomID[0]).shiftLeft(32).add(bigint(randomID[1])).toString(), |
|
|
|
randomIDS = bigint(randomID[0]).shiftLeft(32).add(bigint(randomID[1])).toString(), |
|
|
|
historyStorage = historiesStorage[peerID], |
|
|
|
historyStorage = historiesStorage[peerID], |
|
|
|
inputPeer = AppPeersManager.getInputPeerByID(peerID), |
|
|
|
inputPeer = AppPeersManager.getInputPeerByID(peerID), |
|
|
|
replyToMsgID = options.replyToMsgID; |
|
|
|
replyToMsgID = options.replyToMsgID, |
|
|
|
|
|
|
|
isChannel = AppPeersManager.isChannel(peerID), |
|
|
|
|
|
|
|
asChannel = isChannel ? true : false; |
|
|
|
|
|
|
|
|
|
|
|
if (historyStorage === undefined) { |
|
|
|
if (historyStorage === undefined) { |
|
|
|
historyStorage = historiesStorage[peerID] = {count: null, history: [], pending: []}; |
|
|
|
historyStorage = historiesStorage[peerID] = {count: null, history: [], pending: []}; |
|
|
@ -1354,6 +1373,14 @@ angular.module('myApp.services') |
|
|
|
flags |= 1; |
|
|
|
flags |= 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (replyToMsgID) { |
|
|
|
|
|
|
|
flags |= 8; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (asChannel) { |
|
|
|
|
|
|
|
fromID = 0; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
flags |= 256; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var message = { |
|
|
|
var message = { |
|
|
|
_: 'message', |
|
|
|
_: 'message', |
|
|
@ -1365,6 +1392,7 @@ angular.module('myApp.services') |
|
|
|
message: '', |
|
|
|
message: '', |
|
|
|
media: media, |
|
|
|
media: media, |
|
|
|
random_id: randomIDS, |
|
|
|
random_id: randomIDS, |
|
|
|
|
|
|
|
reply_to_msg_id: replyToMsgID, |
|
|
|
pending: true |
|
|
|
pending: true |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -1425,14 +1453,17 @@ angular.module('myApp.services') |
|
|
|
msgIDs.push(getMessageLocalID(mids[i])); |
|
|
|
msgIDs.push(getMessageLocalID(mids[i])); |
|
|
|
randomIDs.push([nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)]); |
|
|
|
randomIDs.push([nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var sentRequestOptions = {}; |
|
|
|
|
|
|
|
if (pendingAfterMsgs[peerID]) { |
|
|
|
|
|
|
|
sentRequestOptions.afterMessageID = pendingAfterMsgs[peerID].messageID; |
|
|
|
|
|
|
|
} |
|
|
|
return MtpApiManager.invokeApi('messages.forwardMessages', { |
|
|
|
return MtpApiManager.invokeApi('messages.forwardMessages', { |
|
|
|
flags: flags, |
|
|
|
flags: flags, |
|
|
|
from_peer: AppPeersManager.getInputPeerByID(-fromChannel), |
|
|
|
from_peer: AppPeersManager.getInputPeerByID(-fromChannel), |
|
|
|
id: msgIDs, |
|
|
|
id: msgIDs, |
|
|
|
random_id: randomIDs, |
|
|
|
random_id: randomIDs, |
|
|
|
to_peer: AppPeersManager.getInputPeerByID(peerID), |
|
|
|
to_peer: AppPeersManager.getInputPeerByID(peerID), |
|
|
|
}).then(function (updates) { |
|
|
|
}, sentRequestOptions).then(function (updates) { |
|
|
|
ApiUpdatesManager.processUpdateMessage(updates); |
|
|
|
ApiUpdatesManager.processUpdateMessage(updates); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
@ -2015,6 +2046,7 @@ angular.module('myApp.services') |
|
|
|
notification.title = AppChatsManager.getChat(-peerID).title || _('conversation_unknown_chat_raw'); |
|
|
|
notification.title = AppChatsManager.getChat(-peerID).title || _('conversation_unknown_chat_raw'); |
|
|
|
|
|
|
|
|
|
|
|
if (message.from_id > 0) { |
|
|
|
if (message.from_id > 0) { |
|
|
|
|
|
|
|
var fromUser = AppUsersManager.getUser(message.from_id); |
|
|
|
notification.title = (fromUser.first_name || fromUser.last_name || _('conversation_unknown_user_raw')) + |
|
|
|
notification.title = (fromUser.first_name || fromUser.last_name || _('conversation_unknown_user_raw')) + |
|
|
|
' @ ' + |
|
|
|
' @ ' + |
|
|
|
notification.title; |
|
|
|
notification.title; |
|
|
@ -2123,12 +2155,18 @@ angular.module('myApp.services') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$rootScope.$on('apiUpdate', function (e, update) { |
|
|
|
$rootScope.$on('apiUpdate', function (e, update) { |
|
|
|
if (update._ != 'updateUserStatus') { |
|
|
|
// if (update._ != 'updateUserStatus') {
|
|
|
|
console.log('on apiUpdate', update); |
|
|
|
// console.log('on apiUpdate', update);
|
|
|
|
} |
|
|
|
// }
|
|
|
|
switch (update._) { |
|
|
|
switch (update._) { |
|
|
|
case 'updateMessageID': |
|
|
|
case 'updateMessageID': |
|
|
|
pendingByMessageID[update.id] = update.random_id; |
|
|
|
var randomID = update.random_id; |
|
|
|
|
|
|
|
var pendingData = pendingByRandomID[randomID]; |
|
|
|
|
|
|
|
if (pendingData) { |
|
|
|
|
|
|
|
var peerID = pendingData[0]; |
|
|
|
|
|
|
|
var channelID = AppPeersManager.isChannel(peerID) ? -peerID : 0; |
|
|
|
|
|
|
|
pendingByMessageID[getFullMessageID(update.id, channelID)] = randomID; |
|
|
|
|
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 'updateNewMessage': |
|
|
|
case 'updateNewMessage': |
|
|
|