|
|
@ -1118,15 +1118,15 @@ angular.module('myApp.services') |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var toPeerID = AppPeersManager.getPeerID(apiMessage.to_id) |
|
|
|
var peerID = getMessagePeer(apiMessage) |
|
|
|
var isChannel = apiMessage.to_id._ == 'peerChannel' |
|
|
|
var isChannel = apiMessage.to_id._ == 'peerChannel' |
|
|
|
var channelID = isChannel ? -toPeerID : 0 |
|
|
|
var channelID = isChannel ? -peerID : 0 |
|
|
|
var isBroadcast = isChannel && !AppChatsManager.isMegagroup(channelID) |
|
|
|
var isBroadcast = isChannel && !AppChatsManager.isMegagroup(channelID) |
|
|
|
|
|
|
|
|
|
|
|
var mid = AppMessagesIDsManager.getFullMessageID(apiMessage.id, channelID) |
|
|
|
var mid = AppMessagesIDsManager.getFullMessageID(apiMessage.id, channelID) |
|
|
|
apiMessage.mid = mid |
|
|
|
apiMessage.mid = mid |
|
|
|
|
|
|
|
|
|
|
|
var dialog = getDialogByPeerID(toPeerID)[0] |
|
|
|
var dialog = getDialogByPeerID(peerID)[0] |
|
|
|
if (dialog && mid > 0) { |
|
|
|
if (dialog && mid > 0) { |
|
|
|
var dialogKey = apiMessage.pFlags.out |
|
|
|
var dialogKey = apiMessage.pFlags.out |
|
|
|
? 'read_outbox_max_id' |
|
|
|
? 'read_outbox_max_id' |
|
|
@ -1137,6 +1137,7 @@ angular.module('myApp.services') |
|
|
|
else if (options.isNew) { |
|
|
|
else if (options.isNew) { |
|
|
|
apiMessage.pFlags.unread = true |
|
|
|
apiMessage.pFlags.unread = true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// console.log(dT(), 'msg unread', mid, apiMessage.pFlags.out, dialog && dialog[apiMessage.pFlags.out ? 'read_outbox_max_id' : 'read_inbox_max_id'])
|
|
|
|
|
|
|
|
|
|
|
|
if (apiMessage.reply_to_msg_id) { |
|
|
|
if (apiMessage.reply_to_msg_id) { |
|
|
|
apiMessage.reply_to_mid = AppMessagesIDsManager.getFullMessageID(apiMessage.reply_to_msg_id, channelID) |
|
|
|
apiMessage.reply_to_mid = AppMessagesIDsManager.getFullMessageID(apiMessage.reply_to_msg_id, channelID) |
|
|
@ -1150,8 +1151,8 @@ angular.module('myApp.services') |
|
|
|
fwdHeader.date -= ServerTimeManager.serverTimeOffset |
|
|
|
fwdHeader.date -= ServerTimeManager.serverTimeOffset |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
apiMessage.toID = toPeerID |
|
|
|
apiMessage.peerID = peerID |
|
|
|
apiMessage.fromID = apiMessage.pFlags.post ? toPeerID : apiMessage.from_id |
|
|
|
apiMessage.fromID = apiMessage.pFlags.post ? peerID : apiMessage.from_id |
|
|
|
apiMessage.signID = apiMessage.pFlags.post && apiMessage.from_id || |
|
|
|
apiMessage.signID = apiMessage.pFlags.post && apiMessage.from_id || |
|
|
|
fwdHeader && fwdHeader.channel_id && fwdHeader.from_id |
|
|
|
fwdHeader && fwdHeader.channel_id && fwdHeader.from_id |
|
|
|
|
|
|
|
|
|
|
@ -1483,7 +1484,7 @@ angular.module('myApp.services') |
|
|
|
apiFileName = 'document.' + file.type.split('/')[1] |
|
|
|
apiFileName = 'document.' + file.type.split('/')[1] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
console.log(attachType, apiFileName, file.type) |
|
|
|
// console.log(attachType, apiFileName, file.type)
|
|
|
|
|
|
|
|
|
|
|
|
if (historyStorage === undefined) { |
|
|
|
if (historyStorage === undefined) { |
|
|
|
historyStorage = historiesStorage[peerID] = {count: null, history: [], pending: []} |
|
|
|
historyStorage = historiesStorage[peerID] = {count: null, history: [], pending: []} |
|
|
@ -2658,6 +2659,7 @@ angular.module('myApp.services') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
saveMessages([message], {isNew: true}) |
|
|
|
saveMessages([message], {isNew: true}) |
|
|
|
|
|
|
|
// console.warn(dT(), 'message unread', message.mid, message.pFlags.unread)
|
|
|
|
|
|
|
|
|
|
|
|
if (historyStorage !== undefined) { |
|
|
|
if (historyStorage !== undefined) { |
|
|
|
var history = historyStorage.history |
|
|
|
var history = historyStorage.history |
|
|
@ -2821,6 +2823,8 @@ angular.module('myApp.services') |
|
|
|
var messageID, message |
|
|
|
var messageID, message |
|
|
|
var i |
|
|
|
var i |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.warn(dT(), 'read', peerID, isOut ? 'out' : 'in', maxID)
|
|
|
|
|
|
|
|
|
|
|
|
if (peerID > 0 && isOut) { |
|
|
|
if (peerID > 0 && isOut) { |
|
|
|
AppUsersManager.forceUserOnline(peerID) |
|
|
|
AppUsersManager.forceUserOnline(peerID) |
|
|
|
} |
|
|
|
} |
|
|
@ -2838,7 +2842,7 @@ angular.module('myApp.services') |
|
|
|
if (!message.pFlags.unread) { |
|
|
|
if (!message.pFlags.unread) { |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
// console.log('read', messageID, message.pFlags.unread, message)
|
|
|
|
// console.warn('read', messageID, message.pFlags.unread, message)
|
|
|
|
if (message && message.pFlags.unread) { |
|
|
|
if (message && message.pFlags.unread) { |
|
|
|
message.pFlags.unread = false |
|
|
|
message.pFlags.unread = false |
|
|
|
if (messagesForHistory[messageID]) { |
|
|
|
if (messagesForHistory[messageID]) { |
|
|
@ -2869,6 +2873,7 @@ angular.module('myApp.services') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (newUnreadCount !== false) { |
|
|
|
if (newUnreadCount !== false) { |
|
|
|
|
|
|
|
// console.warn(dT(), 'cnt', peerID, newUnreadCount)
|
|
|
|
$rootScope.$broadcast('dialog_unread', {peerID: peerID, count: newUnreadCount}) |
|
|
|
$rootScope.$broadcast('dialog_unread', {peerID: peerID, count: newUnreadCount}) |
|
|
|
} |
|
|
|
} |
|
|
|
if (foundAffected) { |
|
|
|
if (foundAffected) { |
|
|
|