mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 01:16:35 +03:00
Fix apply_difference should not end get diff for secret if not active
This commit is contained in:
parent
1af6d9a873
commit
f90cdf2ffb
|
@ -344,7 +344,8 @@ class MessageBox:
|
||||||
try:
|
try:
|
||||||
self.getting_diff_for.remove(entry)
|
self.getting_diff_for.remove(entry)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
raise RuntimeError('Called end_get_diff on an entry which was not getting diff for')
|
||||||
|
|
||||||
self.reset_deadline(entry, next_updates_deadline())
|
self.reset_deadline(entry, next_updates_deadline())
|
||||||
assert entry not in self.possible_gaps, "gaps shouldn't be created while getting difference"
|
assert entry not in self.possible_gaps, "gaps shouldn't be created while getting difference"
|
||||||
|
|
||||||
|
@ -537,25 +538,41 @@ class MessageBox:
|
||||||
diff,
|
diff,
|
||||||
chat_hashes,
|
chat_hashes,
|
||||||
):
|
):
|
||||||
|
finish = None
|
||||||
|
result = None
|
||||||
|
|
||||||
if isinstance(diff, tl.updates.DifferenceEmpty):
|
if isinstance(diff, tl.updates.DifferenceEmpty):
|
||||||
|
finish = True
|
||||||
self.date = diff.date
|
self.date = diff.date
|
||||||
self.seq = diff.seq
|
self.seq = diff.seq
|
||||||
self.end_get_diff(ENTRY_ACCOUNT)
|
result = [], [], []
|
||||||
self.end_get_diff(ENTRY_SECRET)
|
|
||||||
return [], [], []
|
|
||||||
elif isinstance(diff, tl.updates.Difference):
|
elif isinstance(diff, tl.updates.Difference):
|
||||||
self.end_get_diff(ENTRY_ACCOUNT)
|
finish = True
|
||||||
self.end_get_diff(ENTRY_SECRET)
|
|
||||||
chat_hashes.extend(diff.users, diff.chats)
|
chat_hashes.extend(diff.users, diff.chats)
|
||||||
return self.apply_difference_type(diff, chat_hashes)
|
result = self.apply_difference_type(diff, chat_hashes)
|
||||||
elif isinstance(diff, tl.updates.DifferenceSlice):
|
elif isinstance(diff, tl.updates.DifferenceSlice):
|
||||||
|
finish = False
|
||||||
chat_hashes.extend(diff.users, diff.chats)
|
chat_hashes.extend(diff.users, diff.chats)
|
||||||
return self.apply_difference_type(diff, chat_hashes)
|
result = self.apply_difference_type(diff, chat_hashes)
|
||||||
elif isinstance(diff, tl.updates.DifferenceTooLong):
|
elif isinstance(diff, tl.updates.DifferenceTooLong):
|
||||||
|
finish = True
|
||||||
self.map[ENTRY_ACCOUNT].pts = diff.pts # the deadline will be reset once the diff ends
|
self.map[ENTRY_ACCOUNT].pts = diff.pts # the deadline will be reset once the diff ends
|
||||||
self.end_get_diff(ENTRY_ACCOUNT)
|
result = [], [], []
|
||||||
self.end_get_diff(ENTRY_SECRET)
|
|
||||||
return [], [], []
|
if finish:
|
||||||
|
account = ENTRY_ACCOUNT in self.getting_diff_for
|
||||||
|
secret = ENTRY_SECRET in self.getting_diff_for
|
||||||
|
|
||||||
|
if not account and not secret:
|
||||||
|
raise RuntimeWarning('Should not be applying the difference when neither account or secret was diff was active')
|
||||||
|
|
||||||
|
# Both may be active if both expired at the same time.
|
||||||
|
if account:
|
||||||
|
self.end_get_diff(ENTRY_ACCOUNT)
|
||||||
|
if secret:
|
||||||
|
self.end_get_diff(ENTRY_SECRET)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
def apply_difference_type(
|
def apply_difference_type(
|
||||||
self,
|
self,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user