Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Commit

Permalink
Improved mtproto and handling updates
Browse files Browse the repository at this point in the history
  • Loading branch information
zhukov committed Aug 30, 2017
1 parent d712a0e commit 623d753
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
4 changes: 3 additions & 1 deletion app/js/lib/mtproto.js
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,9 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
break
}
case 'msg_new_detailed_info':
// this.ackMessage(message.answer_msg_id)
if (this.pendingAcks.indexOf(message.answer_msg_id)) {
break
}
this.reqResendMessage(message.answer_msg_id)
break

Expand Down
22 changes: 15 additions & 7 deletions app/js/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -3095,6 +3095,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
curState.pendingPtsUpdates.sort(function (a, b) {
return a.pts - b.pts
})
// console.log(dT(), 'pop update', channelID, curState.pendingPtsUpdates)

var curPts = curState.pts
var goodPts = false
Expand Down Expand Up @@ -3387,7 +3388,11 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
}

if (update._ == 'updateChannelTooLong') {
getChannelDifference(channelID)
if (!curState.lastPtsUpdateTime ||
curState.lastPtsUpdateTime < tsNow() - 10000) {
// console.trace(dT(), 'channel too long, get diff', channelID, update)
getChannelDifference(channelID)
}
return false
}

Expand All @@ -3398,12 +3403,13 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
var message = update.message
var toPeerID = AppPeersManager.getPeerID(message.to_id)
var fwdHeader = message.fwd_from || {}
if (message.from_id && !AppUsersManager.hasUser(message.from_id, message.pFlags.post) ||
fwdHeader.from_id && !AppUsersManager.hasUser(fwdHeader.from_id, !!fwdHeader.channel_id) ||
fwdHeader.channel_id && !AppChatsManager.hasChat(fwdHeader.channel_id, true) ||
toPeerID > 0 && !AppUsersManager.hasUser(toPeerID) ||
toPeerID < 0 && !AppChatsManager.hasChat(-toPeerID)) {
console.warn(dT(), 'Not enough data for message update', message)
var reason = false
if (message.from_id && !AppUsersManager.hasUser(message.from_id, message.pFlags.post/* || channelID*/) && (reason = 'author') ||
fwdHeader.from_id && !AppUsersManager.hasUser(fwdHeader.from_id, !!fwdHeader.channel_id) && (reason = 'fwdAuthor') ||
fwdHeader.channel_id && !AppChatsManager.hasChat(fwdHeader.channel_id, true) && (reason = 'fwdChannel') ||
toPeerID > 0 && !AppUsersManager.hasUser(toPeerID) && (reason = 'toPeer User') ||
toPeerID < 0 && !AppChatsManager.hasChat(-toPeerID) && (reason = 'toPeer Chat')) {
console.warn(dT(), 'Not enough data for message update', toPeerID, reason, message)
if (channelID && AppChatsManager.hasChat(channelID)) {
getChannelDifference(channelID)
} else {
Expand Down Expand Up @@ -3442,6 +3448,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
if (update.pts > curState.pts) {
curState.pts = update.pts
popPts = true

curState.lastPtsUpdateTime = tsNow()
}
else if (update.pts_count) {
// console.warn(dT(), 'Duplicate update', update)
Expand Down

0 comments on commit 623d753

Please sign in to comment.