|
|
@ -9,7 +9,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
angular.module('myApp.services') |
|
|
|
angular.module('myApp.services') |
|
|
|
|
|
|
|
|
|
|
|
.service('AppMessagesManager', function ($q, $rootScope, $location, $filter, $timeout, $sce, ApiUpdatesManager, AppUsersManager, AppChatsManager, AppPeersManager, AppPhotosManager, AppVideoManager, AppDocsManager, AppStickersManager, AppAudioManager, AppWebPagesManager, MtpApiManager, MtpApiFileManager, RichTextProcessor, NotificationsManager, PeersSelectService, Storage, AppProfileManager, FileManager, TelegramMeWebService, ErrorService, StatusManager, _) { |
|
|
|
.service('AppMessagesManager', function ($q, $rootScope, $location, $filter, $timeout, $sce, ApiUpdatesManager, AppUsersManager, AppChatsManager, AppPeersManager, AppPhotosManager, AppVideoManager, AppDocsManager, AppStickersManager, AppAudioManager, AppWebPagesManager, MtpApiManager, MtpApiFileManager, RichTextProcessor, NotificationsManager, PeersSelectService, Storage, AppProfileManager, TelegramMeWebService, ErrorService, StatusManager, _) { |
|
|
|
|
|
|
|
|
|
|
|
var messagesStorage = {}; |
|
|
|
var messagesStorage = {}; |
|
|
|
var messagesForHistory = {}; |
|
|
|
var messagesForHistory = {}; |
|
|
@ -940,15 +940,14 @@ angular.module('myApp.services') |
|
|
|
|
|
|
|
|
|
|
|
function deleteMessages (messageIDs) { |
|
|
|
function deleteMessages (messageIDs) { |
|
|
|
var splitted = splitMessageIDsByChannels(messageIDs); |
|
|
|
var splitted = splitMessageIDsByChannels(messageIDs); |
|
|
|
debugger; |
|
|
|
|
|
|
|
var promises = []; |
|
|
|
var promises = []; |
|
|
|
angular.forEach(splitted.msgIDs, function (msgIDs, channelID) { |
|
|
|
angular.forEach(splitted.msgIDs, function (msgIDs, channelID) { |
|
|
|
var promise; |
|
|
|
var promise; |
|
|
|
if (channelID > 0) { |
|
|
|
if (channelID > 0) { |
|
|
|
var channel = AppChatsManager.getChat(channelID); |
|
|
|
var channel = AppChatsManager.getChat(channelID); |
|
|
|
if (!channel.pFlags.creator) { |
|
|
|
if (!channel.pFlags.creator && !(channel.pFlags.editor && channel.pFlags.megagroup)) { |
|
|
|
var goodMsgIDs = []; |
|
|
|
var goodMsgIDs = []; |
|
|
|
if (channel.pFlags.editor) { |
|
|
|
if (channel.pFlags.editor || channel.pFlags.megagroup) { |
|
|
|
angular.forEach(msgIDs, function (msgID, i) { |
|
|
|
angular.forEach(msgIDs, function (msgID, i) { |
|
|
|
var message = getMessage(splitted.mids[channelID][i]); |
|
|
|
var message = getMessage(splitted.mids[channelID][i]); |
|
|
|
if (message.pFlags.out) { |
|
|
|
if (message.pFlags.out) { |
|
|
@ -2460,15 +2459,13 @@ angular.module('myApp.services') |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
notification.message = notificationMessage; |
|
|
|
notification.message = notificationMessage; |
|
|
|
notification.image = notificationPhoto.placeholder; |
|
|
|
|
|
|
|
notification.key = 'msg' + message.mid; |
|
|
|
notification.key = 'msg' + message.mid; |
|
|
|
notification.tag = peerString; |
|
|
|
notification.tag = peerString; |
|
|
|
|
|
|
|
|
|
|
|
if (notificationPhoto.location && !notificationPhoto.location.empty) { |
|
|
|
if (notificationPhoto.location && !notificationPhoto.location.empty) { |
|
|
|
MtpApiFileManager.downloadSmallFile(notificationPhoto.location, notificationPhoto.size).then(function (blob) { |
|
|
|
MtpApiFileManager.downloadSmallFile(notificationPhoto.location, notificationPhoto.size).then(function (blob) { |
|
|
|
notification.image = FileManager.getUrl(blob, 'image/jpeg'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (message.pFlags.unread) { |
|
|
|
if (message.pFlags.unread) { |
|
|
|
|
|
|
|
notification.image = blob; |
|
|
|
NotificationsManager.notify(notification); |
|
|
|
NotificationsManager.notify(notification); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -2478,6 +2475,7 @@ angular.module('myApp.services') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (window.navigator.mozSetMessageHandler) { |
|
|
|
if (window.navigator.mozSetMessageHandler) { |
|
|
|
|
|
|
|
console.warn('set message handler'); |
|
|
|
window.navigator.mozSetMessageHandler('activity', function(activityRequest) { |
|
|
|
window.navigator.mozSetMessageHandler('activity', function(activityRequest) { |
|
|
|
var source = activityRequest.source; |
|
|
|
var source = activityRequest.source; |
|
|
|
console.log(dT(), 'Received activity', source.name, source.data); |
|
|
|
console.log(dT(), 'Received activity', source.name, source.data); |
|
|
@ -2803,8 +2801,8 @@ angular.module('myApp.services') |
|
|
|
angular.forEach(historiesUpdated, function (updatedData, peerID) { |
|
|
|
angular.forEach(historiesUpdated, function (updatedData, peerID) { |
|
|
|
var foundDialog = getDialogByPeerID(peerID); |
|
|
|
var foundDialog = getDialogByPeerID(peerID); |
|
|
|
if (foundDialog) { |
|
|
|
if (foundDialog) { |
|
|
|
if (updatedData.pFlags.unread) { |
|
|
|
if (updatedData.unread) { |
|
|
|
foundDialog[0].unread_count -= updatedData.pFlags.unread; |
|
|
|
foundDialog[0].unread_count -= updatedData.unread; |
|
|
|
|
|
|
|
|
|
|
|
$rootScope.$broadcast('dialog_unread', {peerID: peerID, count: foundDialog[0].unread_count}); |
|
|
|
$rootScope.$broadcast('dialog_unread', {peerID: peerID, count: foundDialog[0].unread_count}); |
|
|
|
} |
|
|
|
} |
|
|
|