|
|
@ -1143,7 +1143,8 @@ angular.module('myApp.services', ['myApp.i18n']) |
|
|
|
return MtpApiManager.invokeApi(method, { |
|
|
|
return MtpApiManager.invokeApi(method, { |
|
|
|
peer: inputPeer, |
|
|
|
peer: inputPeer, |
|
|
|
offset: affectedHistory.offset, |
|
|
|
offset: affectedHistory.offset, |
|
|
|
max_id: 0 |
|
|
|
max_id: 0, |
|
|
|
|
|
|
|
read_contents: true |
|
|
|
}).then(function (affectedHistory) { |
|
|
|
}).then(function (affectedHistory) { |
|
|
|
return processAffectedHistory(inputPeer, affectedHistory, method); |
|
|
|
return processAffectedHistory(inputPeer, affectedHistory, method); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -1185,7 +1186,8 @@ angular.module('myApp.services', ['myApp.i18n']) |
|
|
|
historyStorage.readPromise = MtpApiManager.invokeApi('messages.readHistory', { |
|
|
|
historyStorage.readPromise = MtpApiManager.invokeApi('messages.readHistory', { |
|
|
|
peer: inputPeer, |
|
|
|
peer: inputPeer, |
|
|
|
offset: 0, |
|
|
|
offset: 0, |
|
|
|
max_id: 0 |
|
|
|
max_id: 0, |
|
|
|
|
|
|
|
read_contents: true |
|
|
|
}).then(function (affectedHistory) { |
|
|
|
}).then(function (affectedHistory) { |
|
|
|
return processAffectedHistory(inputPeer, affectedHistory, 'messages.readHistory'); |
|
|
|
return processAffectedHistory(inputPeer, affectedHistory, 'messages.readHistory'); |
|
|
|
}).then(function () { |
|
|
|
}).then(function () { |
|
|
@ -1241,6 +1243,8 @@ angular.module('myApp.services', ['myApp.i18n']) |
|
|
|
|
|
|
|
|
|
|
|
function saveMessages (apiMessages) { |
|
|
|
function saveMessages (apiMessages) { |
|
|
|
angular.forEach(apiMessages, function (apiMessage) { |
|
|
|
angular.forEach(apiMessages, function (apiMessage) { |
|
|
|
|
|
|
|
apiMessage.unread = apiMessage.flags & 1 ? true : false; |
|
|
|
|
|
|
|
apiMessage.out = apiMessage.flags & 2 ? true : false; |
|
|
|
messagesStorage[apiMessage.id] = apiMessage; |
|
|
|
messagesStorage[apiMessage.id] = apiMessage; |
|
|
|
|
|
|
|
|
|
|
|
apiMessage.date -= serverTimeOffset; |
|
|
|
apiMessage.date -= serverTimeOffset; |
|
|
@ -1281,8 +1285,7 @@ angular.module('myApp.services', ['myApp.i18n']) |
|
|
|
id: messageID, |
|
|
|
id: messageID, |
|
|
|
from_id: fromID, |
|
|
|
from_id: fromID, |
|
|
|
to_id: AppPeersManager.getOutputPeer(peerID), |
|
|
|
to_id: AppPeersManager.getOutputPeer(peerID), |
|
|
|
out: true, |
|
|
|
flags: 3, |
|
|
|
unread: true, |
|
|
|
|
|
|
|
date: tsNow(true) + serverTimeOffset, |
|
|
|
date: tsNow(true) + serverTimeOffset, |
|
|
|
message: text, |
|
|
|
message: text, |
|
|
|
media: {_: 'messageMediaEmpty'}, |
|
|
|
media: {_: 'messageMediaEmpty'}, |
|
|
@ -1406,8 +1409,7 @@ angular.module('myApp.services', ['myApp.i18n']) |
|
|
|
id: messageID, |
|
|
|
id: messageID, |
|
|
|
from_id: fromID, |
|
|
|
from_id: fromID, |
|
|
|
to_id: AppPeersManager.getOutputPeer(peerID), |
|
|
|
to_id: AppPeersManager.getOutputPeer(peerID), |
|
|
|
out: true, |
|
|
|
flags: 3, |
|
|
|
unread: true, |
|
|
|
|
|
|
|
date: tsNow(true) + serverTimeOffset, |
|
|
|
date: tsNow(true) + serverTimeOffset, |
|
|
|
message: '', |
|
|
|
message: '', |
|
|
|
media: media, |
|
|
|
media: media, |
|
|
@ -1548,8 +1550,7 @@ angular.module('myApp.services', ['myApp.i18n']) |
|
|
|
id: messageID, |
|
|
|
id: messageID, |
|
|
|
from_id: fromID, |
|
|
|
from_id: fromID, |
|
|
|
to_id: AppPeersManager.getOutputPeer(peerID), |
|
|
|
to_id: AppPeersManager.getOutputPeer(peerID), |
|
|
|
out: true, |
|
|
|
flags: 3, |
|
|
|
unread: true, |
|
|
|
|
|
|
|
date: tsNow(true) + serverTimeOffset, |
|
|
|
date: tsNow(true) + serverTimeOffset, |
|
|
|
message: '', |
|
|
|
message: '', |
|
|
|
media: media, |
|
|
|
media: media, |
|
|
@ -2182,6 +2183,7 @@ angular.module('myApp.services', ['myApp.i18n']) |
|
|
|
id: messageID, |
|
|
|
id: messageID, |
|
|
|
from_id: message.from_id, |
|
|
|
from_id: message.from_id, |
|
|
|
to_id: message.to_id, |
|
|
|
to_id: message.to_id, |
|
|
|
|
|
|
|
flags: message.flags, |
|
|
|
out: message.out, |
|
|
|
out: message.out, |
|
|
|
unread: message.unread, |
|
|
|
unread: message.unread, |
|
|
|
date: message.date |
|
|
|
date: message.date |
|
|
@ -2937,8 +2939,7 @@ angular.module('myApp.services', ['myApp.i18n']) |
|
|
|
id: updateMessage.id, |
|
|
|
id: updateMessage.id, |
|
|
|
from_id: updateMessage.from_id, |
|
|
|
from_id: updateMessage.from_id, |
|
|
|
to_id: AppPeersManager.getOutputPeer(MtpApiManager.getUserID()), |
|
|
|
to_id: AppPeersManager.getOutputPeer(MtpApiManager.getUserID()), |
|
|
|
out: false, |
|
|
|
flags: 1, |
|
|
|
unread: true, |
|
|
|
|
|
|
|
date: updateMessage.date, |
|
|
|
date: updateMessage.date, |
|
|
|
message: updateMessage.message, |
|
|
|
message: updateMessage.message, |
|
|
|
media: {_: 'messageMediaEmpty'} |
|
|
|
media: {_: 'messageMediaEmpty'} |
|
|
@ -2961,8 +2962,7 @@ angular.module('myApp.services', ['myApp.i18n']) |
|
|
|
id: updateMessage.id, |
|
|
|
id: updateMessage.id, |
|
|
|
from_id: updateMessage.from_id, |
|
|
|
from_id: updateMessage.from_id, |
|
|
|
to_id: AppPeersManager.getOutputPeer(-updateMessage.chat_id), |
|
|
|
to_id: AppPeersManager.getOutputPeer(-updateMessage.chat_id), |
|
|
|
out: false, |
|
|
|
flags: 1, |
|
|
|
unread: true, |
|
|
|
|
|
|
|
date: updateMessage.date, |
|
|
|
date: updateMessage.date, |
|
|
|
message: updateMessage.message, |
|
|
|
message: updateMessage.message, |
|
|
|
media: {_: 'messageMediaEmpty'} |
|
|
|
media: {_: 'messageMediaEmpty'} |
|
|
|