|
|
|
@ -168,7 +168,7 @@ angular.module('myApp.services')
@@ -168,7 +168,7 @@ angular.module('myApp.services')
|
|
|
|
|
|
|
|
|
|
// Because we saved message without dialog present
|
|
|
|
|
if (message.mid && message.mid > dialog.read_inbox_max_id) { |
|
|
|
|
message.unread = true; |
|
|
|
|
message.pFlags.unread = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (historiesStorage[peerID] === undefined) { |
|
|
|
@ -259,7 +259,7 @@ angular.module('myApp.services')
@@ -259,7 +259,7 @@ angular.module('myApp.services')
|
|
|
|
|
dialog.top_message > maxSeenID |
|
|
|
|
) { |
|
|
|
|
var notifyPeer = message.flags & 16 ? message.from_id : peerID; |
|
|
|
|
if (message.unread && !message.out) { |
|
|
|
|
if (message.pFlags.unread && !message.pFlags.out) { |
|
|
|
|
NotificationsManager.getPeerMuted(notifyPeer).then(function (muted) { |
|
|
|
|
if (!muted) { |
|
|
|
|
notifyAboutMessage(message); |
|
|
|
@ -364,6 +364,7 @@ angular.module('myApp.services')
@@ -364,6 +364,7 @@ angular.module('myApp.services')
|
|
|
|
|
from_id: peerID, |
|
|
|
|
to_id: AppPeersManager.getOutputPeer(peerID), |
|
|
|
|
flags: 0, |
|
|
|
|
pFlags: {}, |
|
|
|
|
date: tsNow(true) + serverTimeOffset, |
|
|
|
|
action: { |
|
|
|
|
_: 'messageActionBotIntro', |
|
|
|
@ -499,7 +500,7 @@ angular.module('myApp.services')
@@ -499,7 +500,7 @@ angular.module('myApp.services')
|
|
|
|
|
var i, message; |
|
|
|
|
for (i = result.history.length - 1; i >= 0; i--) { |
|
|
|
|
message = messagesStorage[result.history[i]]; |
|
|
|
|
if (message && !message.out && message.unread) { |
|
|
|
|
if (message && !message.pFlags.out && message.pFlags.unread) { |
|
|
|
|
result.unreadOffset = i + 1; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -641,7 +642,7 @@ angular.module('myApp.services')
@@ -641,7 +642,7 @@ angular.module('myApp.services')
|
|
|
|
|
function mergeReplyKeyboard (historyStorage, message) { |
|
|
|
|
// console.log('merge', message.mid, message.reply_markup, historyStorage.reply_markup);
|
|
|
|
|
if (!message.reply_markup && |
|
|
|
|
!message.out && |
|
|
|
|
!message.pFlags.out && |
|
|
|
|
!message.action) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
@ -657,7 +658,7 @@ angular.module('myApp.services')
@@ -657,7 +658,7 @@ angular.module('myApp.services')
|
|
|
|
|
} |
|
|
|
|
if (historyStorage.maxOutID && |
|
|
|
|
message.mid < historyStorage.maxOutID && |
|
|
|
|
messageReplyMarkup.pFlags.one_time) { |
|
|
|
|
messageReplyMarkup.pFlags.single_use) { |
|
|
|
|
messageReplyMarkup.pFlags.hidden = true; |
|
|
|
|
} |
|
|
|
|
messageReplyMarkup = angular.extend({ |
|
|
|
@ -671,9 +672,9 @@ angular.module('myApp.services')
@@ -671,9 +672,9 @@ angular.module('myApp.services')
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (message.out) { |
|
|
|
|
if (message.pFlags.out) { |
|
|
|
|
if (lastReplyMarkup) { |
|
|
|
|
if (lastReplyMarkup.pFlags.one_time && |
|
|
|
|
if (lastReplyMarkup.pFlags.single_use && |
|
|
|
|
!lastReplyMarkup.pFlags.hidden && |
|
|
|
|
(message.mid > lastReplyMarkup.mid || message.mid < 0) && |
|
|
|
|
message.message) { |
|
|
|
@ -786,8 +787,13 @@ angular.module('myApp.services')
@@ -786,8 +787,13 @@ angular.module('myApp.services')
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var flags = 0; |
|
|
|
|
if (AppPeersManager.isChannel(peerID)) { |
|
|
|
|
flags |= 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return MtpApiManager.invokeApi('messages.search', { |
|
|
|
|
flags: 0, |
|
|
|
|
flags: flags, |
|
|
|
|
peer: inputPeer, |
|
|
|
|
q: query || '', |
|
|
|
|
filter: inputFilter || {_: 'inputMessagesFilterEmpty'}, |
|
|
|
@ -842,7 +848,7 @@ angular.module('myApp.services')
@@ -842,7 +848,7 @@ angular.module('myApp.services')
|
|
|
|
|
if (channel.pFlags.editor) { |
|
|
|
|
angular.forEach(msgIDs, function (msgID, i) { |
|
|
|
|
var message = getMessage(splitted.mids[channelID][i]); |
|
|
|
|
if (message.out) { |
|
|
|
|
if (message.pFlags.out) { |
|
|
|
|
goodMsgIDs.push(msgID); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -888,28 +894,6 @@ angular.module('myApp.services')
@@ -888,28 +894,6 @@ angular.module('myApp.services')
|
|
|
|
|
return $q.all(promises); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function processAffectedHistory (inputPeer, affectedHistory, method) { |
|
|
|
|
ApiUpdatesManager.processUpdateMessage({ |
|
|
|
|
_: 'updateShort', |
|
|
|
|
update: { |
|
|
|
|
_: 'updatePts', |
|
|
|
|
pts: affectedHistory.pts, |
|
|
|
|
pts_count: affectedHistory.pts_count |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
if (!affectedHistory.offset) { |
|
|
|
|
return $q.when(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return MtpApiManager.invokeApi(method, { |
|
|
|
|
peer: inputPeer, |
|
|
|
|
offset: affectedHistory.offset, |
|
|
|
|
max_id: 0 |
|
|
|
|
}).then(function (affectedHistory) { |
|
|
|
|
return processAffectedHistory(inputPeer, affectedHistory, method); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function readHistory (inputPeer) { |
|
|
|
|
// console.trace('start read');
|
|
|
|
|
var peerID = AppPeersManager.getPeerID(inputPeer), |
|
|
|
@ -929,7 +913,7 @@ angular.module('myApp.services')
@@ -929,7 +913,7 @@ angular.module('myApp.services')
|
|
|
|
|
for (i = historyStorage.history.length; i >= 0; i--) { |
|
|
|
|
messageID = historyStorage.history[i]; |
|
|
|
|
message = messagesStorage[messageID]; |
|
|
|
|
if (message && !message.out && message.unread) { |
|
|
|
|
if (message && !message.pFlags.out && message.pFlags.unread) { |
|
|
|
|
foundUnread = true; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -952,10 +936,7 @@ angular.module('myApp.services')
@@ -952,10 +936,7 @@ angular.module('myApp.services')
|
|
|
|
|
} else { |
|
|
|
|
apiPromise = MtpApiManager.invokeApi('messages.readHistory', { |
|
|
|
|
peer: inputPeer, |
|
|
|
|
offset: 0, |
|
|
|
|
max_id: 0 |
|
|
|
|
}).then(function (affectedHistory) { |
|
|
|
|
return processAffectedHistory(inputPeer, affectedHistory, 'messages.readHistory'); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -978,13 +959,13 @@ angular.module('myApp.services')
@@ -978,13 +959,13 @@ angular.module('myApp.services')
|
|
|
|
|
for (i = 0; i < historyStorage.history.length; i++) { |
|
|
|
|
messageID = historyStorage.history[i]; |
|
|
|
|
message = messagesStorage[messageID]; |
|
|
|
|
if (message && !message.out) { |
|
|
|
|
message.unread = false; |
|
|
|
|
if (message && !message.pFlags.out) { |
|
|
|
|
message.pFlags.unread = false; |
|
|
|
|
if (messagesForHistory[messageID]) { |
|
|
|
|
messagesForHistory[messageID].unread = false; |
|
|
|
|
messagesForHistory[messageID].pFlags.unread = false; |
|
|
|
|
} |
|
|
|
|
if (messagesForDialogs[messageID]) { |
|
|
|
|
messagesForDialogs[messageID].unread = false; |
|
|
|
|
messagesForDialogs[messageID].pFlags.unread = false; |
|
|
|
|
} |
|
|
|
|
NotificationsManager.cancel('msg' + messageID); |
|
|
|
|
} |
|
|
|
@ -1012,17 +993,29 @@ angular.module('myApp.services')
@@ -1012,17 +993,29 @@ angular.module('myApp.services')
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function flushHistory (inputPeer) { |
|
|
|
|
// console.log('start flush');
|
|
|
|
|
var peerID = AppPeersManager.getPeerID(inputPeer), |
|
|
|
|
historyStorage = historiesStorage[peerID]; |
|
|
|
|
|
|
|
|
|
function doFlushHistory (inputPeer) { |
|
|
|
|
return MtpApiManager.invokeApi('messages.deleteHistory', { |
|
|
|
|
peer: inputPeer, |
|
|
|
|
offset: 0 |
|
|
|
|
max_id: 0 |
|
|
|
|
}).then(function (affectedHistory) { |
|
|
|
|
return processAffectedHistory(inputPeer, affectedHistory, 'messages.deleteHistory'); |
|
|
|
|
}).then(function () { |
|
|
|
|
ApiUpdatesManager.processUpdateMessage({ |
|
|
|
|
_: 'updateShort', |
|
|
|
|
update: { |
|
|
|
|
_: 'updatePts', |
|
|
|
|
pts: affectedHistory.pts, |
|
|
|
|
pts_count: affectedHistory.pts_count |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
if (!affectedHistory.offset) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return doFlushHistory(inputPeer); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function flushHistory (inputPeer) { |
|
|
|
|
var peerID = AppPeersManager.getPeerID(inputPeer); |
|
|
|
|
return doFlushHistory(inputPeer).then(function () { |
|
|
|
|
var foundDialog = getDialogByPeerID(peerID); |
|
|
|
|
if (foundDialog[0]) { |
|
|
|
|
dialogsStorage.dialogs.splice(foundDialog[1], 1); |
|
|
|
@ -1034,11 +1027,18 @@ angular.module('myApp.services')
@@ -1034,11 +1027,18 @@ angular.module('myApp.services')
|
|
|
|
|
|
|
|
|
|
function saveMessages (apiMessages) { |
|
|
|
|
angular.forEach(apiMessages, function (apiMessage) { |
|
|
|
|
if (apiMessage.pFlags === undefined) { |
|
|
|
|
apiMessage.pFlags = {}; |
|
|
|
|
} |
|
|
|
|
if (!apiMessage.pFlags.out) { |
|
|
|
|
apiMessage.pFlags.out = false; |
|
|
|
|
} |
|
|
|
|
if (!apiMessage.pFlags.unread) { |
|
|
|
|
apiMessage.pFlags.unread = false; |
|
|
|
|
} |
|
|
|
|
if (apiMessage._ == 'messageEmpty') { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
apiMessage.out = apiMessage.flags & 2 ? true : false; |
|
|
|
|
apiMessage.media_unread = apiMessage.flags & 32 ? true : false; |
|
|
|
|
|
|
|
|
|
var toPeerID = AppPeersManager.getPeerID(apiMessage.to_id); |
|
|
|
|
var isChannel = apiMessage.to_id._ == 'peerChannel'; |
|
|
|
@ -1048,11 +1048,11 @@ angular.module('myApp.services')
@@ -1048,11 +1048,11 @@ angular.module('myApp.services')
|
|
|
|
|
apiMessage.mid = mid; |
|
|
|
|
messagesStorage[mid] = apiMessage; |
|
|
|
|
|
|
|
|
|
if (channelID && !apiMessage.out) { |
|
|
|
|
if (channelID && !apiMessage.pFlags.out) { |
|
|
|
|
var dialog = getDialogByPeerID(toPeerID)[0]; |
|
|
|
|
apiMessage.unread = dialog ? mid > dialog.read_inbox_max_id : true; |
|
|
|
|
apiMessage.pFlags.unread = dialog ? mid > dialog.read_inbox_max_id : true; |
|
|
|
|
} else { |
|
|
|
|
apiMessage.unread = apiMessage.flags & 1 ? true : false; |
|
|
|
|
apiMessage.pFlags.unread = apiMessage.flags & 1 ? true : false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (apiMessage.reply_to_msg_id) { |
|
|
|
@ -1112,13 +1112,6 @@ angular.module('myApp.services')
@@ -1112,13 +1112,6 @@ angular.module('myApp.services')
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (apiMessage.reply_markup) { |
|
|
|
|
apiMessage.reply_markup.pFlags = { |
|
|
|
|
resize: (apiMessage.reply_markup.flags & 1) > 0, |
|
|
|
|
one_time: (apiMessage.reply_markup.flags & 2) > 0, |
|
|
|
|
selective: (apiMessage.reply_markup.flags & 4) > 0 |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (apiMessage.message && apiMessage.message.length) { |
|
|
|
|
var myEntities = RichTextProcessor.parseEntities(apiMessage.message); |
|
|
|
@ -1139,6 +1132,7 @@ angular.module('myApp.services')
@@ -1139,6 +1132,7 @@ angular.module('myApp.services')
|
|
|
|
|
historyStorage = historiesStorage[peerID], |
|
|
|
|
inputPeer = AppPeersManager.getInputPeerByID(peerID), |
|
|
|
|
flags = 0, |
|
|
|
|
pFlags = {}, |
|
|
|
|
replyToMsgID = options.replyToMsgID, |
|
|
|
|
isChannel = AppPeersManager.isChannel(peerID), |
|
|
|
|
asChannel = isChannel ? true : false, |
|
|
|
@ -1154,8 +1148,10 @@ angular.module('myApp.services')
@@ -1154,8 +1148,10 @@ angular.module('myApp.services')
|
|
|
|
|
var fromID = AppUsersManager.getSelf().id; |
|
|
|
|
if (peerID != fromID) { |
|
|
|
|
flags |= 2; |
|
|
|
|
pFlags.out = true; |
|
|
|
|
if (!isChannel && !AppUsersManager.isBot(peerID)) { |
|
|
|
|
flags |= 1; |
|
|
|
|
pFlags.unread = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (replyToMsgID) { |
|
|
|
@ -1172,6 +1168,7 @@ angular.module('myApp.services')
@@ -1172,6 +1168,7 @@ angular.module('myApp.services')
|
|
|
|
|
from_id: fromID, |
|
|
|
|
to_id: AppPeersManager.getOutputPeer(peerID), |
|
|
|
|
flags: flags, |
|
|
|
|
pFlags: pFlags, |
|
|
|
|
date: tsNow(true) + serverTimeOffset, |
|
|
|
|
message: text, |
|
|
|
|
random_id: randomIDS, |
|
|
|
@ -1276,6 +1273,7 @@ angular.module('myApp.services')
@@ -1276,6 +1273,7 @@ angular.module('myApp.services')
|
|
|
|
|
historyStorage = historiesStorage[peerID], |
|
|
|
|
inputPeer = AppPeersManager.getInputPeerByID(peerID), |
|
|
|
|
flags = 0, |
|
|
|
|
pFlags = {}, |
|
|
|
|
replyToMsgID = options.replyToMsgID, |
|
|
|
|
isChannel = AppPeersManager.isChannel(peerID), |
|
|
|
|
asChannel = isChannel ? true : false, |
|
|
|
@ -1305,8 +1303,10 @@ angular.module('myApp.services')
@@ -1305,8 +1303,10 @@ angular.module('myApp.services')
|
|
|
|
|
var fromID = AppUsersManager.getSelf().id; |
|
|
|
|
if (peerID != fromID) { |
|
|
|
|
flags |= 2; |
|
|
|
|
pFlags.out = true; |
|
|
|
|
if (!isChannel && !AppUsersManager.isBot(peerID)) { |
|
|
|
|
flags |= 1; |
|
|
|
|
pFlags.unread = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (replyToMsgID) { |
|
|
|
@ -1331,6 +1331,7 @@ angular.module('myApp.services')
@@ -1331,6 +1331,7 @@ angular.module('myApp.services')
|
|
|
|
|
from_id: fromID, |
|
|
|
|
to_id: AppPeersManager.getOutputPeer(peerID), |
|
|
|
|
flags: flags, |
|
|
|
|
pFlags: pFlags, |
|
|
|
|
date: tsNow(true) + serverTimeOffset, |
|
|
|
|
message: '', |
|
|
|
|
media: media, |
|
|
|
@ -1494,10 +1495,13 @@ angular.module('myApp.services')
@@ -1494,10 +1495,13 @@ angular.module('myApp.services')
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var flags = 0; |
|
|
|
|
var pFlags = {}; |
|
|
|
|
if (peerID != fromID) { |
|
|
|
|
flags |= 2; |
|
|
|
|
pFlags.out = true; |
|
|
|
|
if (!AppUsersManager.isBot(peerID)) { |
|
|
|
|
flags |= 1; |
|
|
|
|
pFlags.unread = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (replyToMsgID) { |
|
|
|
@ -1515,6 +1519,7 @@ angular.module('myApp.services')
@@ -1515,6 +1519,7 @@ angular.module('myApp.services')
|
|
|
|
|
from_id: fromID, |
|
|
|
|
to_id: AppPeersManager.getOutputPeer(peerID), |
|
|
|
|
flags: flags, |
|
|
|
|
pFlags: pFlags, |
|
|
|
|
date: tsNow(true) + serverTimeOffset, |
|
|
|
|
message: '', |
|
|
|
|
media: media, |
|
|
|
@ -1621,36 +1626,37 @@ angular.module('myApp.services')
@@ -1621,36 +1626,37 @@ angular.module('myApp.services')
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function startBot (botID, chatID, startParam) { |
|
|
|
|
var peerID = chatID ? -chatID : botID; |
|
|
|
|
if (startParam) { |
|
|
|
|
var randomID = bigint(nextRandomInt(0xFFFFFFFF)).shiftLeft(32).add(bigint(nextRandomInt(0xFFFFFFFF))).toString(); |
|
|
|
|
|
|
|
|
|
return MtpApiManager.invokeApi('messages.startBot', { |
|
|
|
|
bot: AppUsersManager.getUserInput(botID), |
|
|
|
|
chat_id: AppChatsManager.getChatInput(chatID), |
|
|
|
|
peer: AppPeersManager.getInputPeerByID(peerID), |
|
|
|
|
random_id: randomID, |
|
|
|
|
start_param: startParam |
|
|
|
|
}).then(function (updates) { |
|
|
|
|
ApiUpdatesManager.processUpdateMessage(updates); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var peerID = chatID ? -chatID : botID; |
|
|
|
|
var inputPeer = AppPeersManager.getInputPeerByID(peerID); |
|
|
|
|
|
|
|
|
|
if (chatID) { |
|
|
|
|
return MtpApiManager.invokeApi('messages.addChatUser', { |
|
|
|
|
chat_id: AppChatsManager.getChatInput(chatID), |
|
|
|
|
user_id: AppUsersManager.getUserInput(botID) |
|
|
|
|
}).then(function (updates) { |
|
|
|
|
ApiUpdatesManager.processUpdateMessage(updates); |
|
|
|
|
sendText(peerID, '/start@' + bot.username); |
|
|
|
|
}, function (error) { |
|
|
|
|
if (error && error.type == 'USER_ALREADY_PARTICIPANT') { |
|
|
|
|
var bot = AppUsersManager.getUser(botID); |
|
|
|
|
sendText(-chatID, '/start@' + bot.username); |
|
|
|
|
sendText(peerID, '/start@' + bot.username); |
|
|
|
|
error.handled = true; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return sendText(botID, '/start'); |
|
|
|
|
return sendText(peerID, '/start'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function cancelPendingMessage (randomID) { |
|
|
|
@ -1777,7 +1783,7 @@ angular.module('myApp.services')
@@ -1777,7 +1783,7 @@ angular.module('myApp.services')
|
|
|
|
|
|
|
|
|
|
if (toID < 0) { |
|
|
|
|
return toID; |
|
|
|
|
} else if (message.out || message.flags & 2) { |
|
|
|
|
} else if (message.pFlags && message.pFlags.out || message.flags & 2) { |
|
|
|
|
return toID; |
|
|
|
|
} |
|
|
|
|
return message.from_id; |
|
|
|
@ -1796,7 +1802,7 @@ angular.module('myApp.services')
@@ -1796,7 +1802,7 @@ angular.module('myApp.services')
|
|
|
|
|
|
|
|
|
|
if (!message || !message.to_id) { |
|
|
|
|
if (dialog && dialog.peerID) { |
|
|
|
|
message = {_: 'message', to_id: AppPeersManager.getOutputPeer(dialog.peerID), deleted: true, date: tsNow(true)}; |
|
|
|
|
message = {_: 'message', to_id: AppPeersManager.getOutputPeer(dialog.peerID), deleted: true, date: tsNow(true), pFlags: {}}; |
|
|
|
|
message.deleted = true; |
|
|
|
|
} else { |
|
|
|
|
return message; |
|
|
|
@ -2316,7 +2322,7 @@ angular.module('myApp.services')
@@ -2316,7 +2322,7 @@ angular.module('myApp.services')
|
|
|
|
|
MtpApiFileManager.downloadSmallFile(notificationPhoto.location, notificationPhoto.size).then(function (blob) { |
|
|
|
|
notification.image = FileManager.getUrl(blob, 'image/jpeg'); |
|
|
|
|
|
|
|
|
|
if (message.unread) { |
|
|
|
|
if (message.pFlags.unread) { |
|
|
|
|
NotificationsManager.notify(notification); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -2379,11 +2385,11 @@ angular.module('myApp.services')
@@ -2379,11 +2385,11 @@ angular.module('myApp.services')
|
|
|
|
|
notifyPeerToHandle.isMutedPromise.then(function (muted) { |
|
|
|
|
var topMessage = notifyPeerToHandle.top_message; |
|
|
|
|
if (muted || |
|
|
|
|
!topMessage.unread) { |
|
|
|
|
!topMessage.pFlags.unread) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
setTimeout(function () { |
|
|
|
|
if (topMessage.unread) { |
|
|
|
|
if (topMessage.pFlags.unread) { |
|
|
|
|
notifyAboutMessage(topMessage, { |
|
|
|
|
fwd_count: notifyPeerToHandle.fwd_count |
|
|
|
|
}); |
|
|
|
@ -2451,7 +2457,7 @@ angular.module('myApp.services')
@@ -2451,7 +2457,7 @@ angular.module('myApp.services')
|
|
|
|
|
$rootScope.$broadcast('history_reply_markup', {peerID: peerID}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!message.out && message.from_id) { |
|
|
|
|
if (!message.pFlags.out && message.from_id) { |
|
|
|
|
AppUsersManager.forceUserOnline(message.from_id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2477,7 +2483,7 @@ angular.module('myApp.services')
@@ -2477,7 +2483,7 @@ angular.module('myApp.services')
|
|
|
|
|
|
|
|
|
|
var foundDialog = getDialogByPeerID(peerID); |
|
|
|
|
var dialog; |
|
|
|
|
var inboxUnread = !message.out && message.unread; |
|
|
|
|
var inboxUnread = !message.pFlags.out && message.pFlags.unread; |
|
|
|
|
|
|
|
|
|
if (foundDialog.length) { |
|
|
|
|
dialog = foundDialog[0]; |
|
|
|
@ -2555,25 +2561,25 @@ angular.module('myApp.services')
@@ -2555,25 +2561,25 @@ angular.module('myApp.services')
|
|
|
|
|
} |
|
|
|
|
message = messagesStorage[messageID]; |
|
|
|
|
|
|
|
|
|
if (message.out != isOut) { |
|
|
|
|
if (message.pFlags.out != isOut) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (!message.unread) { |
|
|
|
|
if (!message.pFlags.unread) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
// console.log('read', messageID, message.unread, message);
|
|
|
|
|
if (message && message.unread) { |
|
|
|
|
message.unread = false; |
|
|
|
|
// console.log('read', messageID, message.pFlags.unread, message);
|
|
|
|
|
if (message && message.pFlags.unread) { |
|
|
|
|
message.pFlags.unread = false; |
|
|
|
|
if (messagesForHistory[messageID]) { |
|
|
|
|
messagesForHistory[messageID].unread = false; |
|
|
|
|
messagesForHistory[messageID].pFlags.unread = false; |
|
|
|
|
if (!foundAffected) { |
|
|
|
|
foundAffected = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (messagesForDialogs[messageID]) { |
|
|
|
|
messagesForDialogs[messageID].unread = false; |
|
|
|
|
messagesForDialogs[messageID].pFlags.unread = false; |
|
|
|
|
} |
|
|
|
|
if (!message.out) { |
|
|
|
|
if (!message.pFlags.out) { |
|
|
|
|
if (foundDialog) { |
|
|
|
|
newUnreadCount = --foundDialog[0].unread_count; |
|
|
|
|
} |
|
|
|
@ -2597,10 +2603,10 @@ angular.module('myApp.services')
@@ -2597,10 +2603,10 @@ angular.module('myApp.services')
|
|
|
|
|
for (i = 0; i < len; i++) { |
|
|
|
|
messageID = messages[i]; |
|
|
|
|
if (message = messagesStorage[messageID]) { |
|
|
|
|
delete message.media_unread; |
|
|
|
|
delete message.pFlags.media_unread; |
|
|
|
|
} |
|
|
|
|
if (historyMessage = messagesForHistory[messageID]) { |
|
|
|
|
delete historyMessage.media_unread; |
|
|
|
|
delete historyMessage.pFlags.media_unread; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
@ -2619,8 +2625,8 @@ angular.module('myApp.services')
@@ -2619,8 +2625,8 @@ angular.module('myApp.services')
|
|
|
|
|
peerID = getMessagePeer(message); |
|
|
|
|
history = historiesUpdated[peerID] || (historiesUpdated[peerID] = {count: 0, unread: 0, msgs: {}}); |
|
|
|
|
|
|
|
|
|
if (!message.out && message.unread) { |
|
|
|
|
history.unread++; |
|
|
|
|
if (!message.pFlags.out && message.pFlags.unread) { |
|
|
|
|
history.pFlags.unread++; |
|
|
|
|
NotificationsManager.cancel('msg' + messageID); |
|
|
|
|
} |
|
|
|
|
history.count++; |
|
|
|
@ -2641,8 +2647,7 @@ angular.module('myApp.services')
@@ -2641,8 +2647,7 @@ angular.module('myApp.services')
|
|
|
|
|
from_id: message.from_id, |
|
|
|
|
to_id: message.to_id, |
|
|
|
|
flags: message.flags, |
|
|
|
|
out: message.out, |
|
|
|
|
unread: message.unread, |
|
|
|
|
pFlags: message.pFlags, |
|
|
|
|
date: message.date |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
@ -2651,8 +2656,8 @@ angular.module('myApp.services')
@@ -2651,8 +2656,8 @@ angular.module('myApp.services')
|
|
|
|
|
angular.forEach(historiesUpdated, function (updatedData, peerID) { |
|
|
|
|
var foundDialog = getDialogByPeerID(peerID); |
|
|
|
|
if (foundDialog) { |
|
|
|
|
if (updatedData.unread) { |
|
|
|
|
foundDialog[0].unread_count -= updatedData.unread; |
|
|
|
|
if (updatedData.pFlags.unread) { |
|
|
|
|
foundDialog[0].unread_count -= updatedData.pFlags.unread; |
|
|
|
|
|
|
|
|
|
$rootScope.$broadcast('dialog_unread', {peerID: peerID, count: foundDialog[0].unread_count}); |
|
|
|
|
} |
|
|
|
|