Few nitpicky fixes
This commit is contained in:
@@ -501,25 +501,25 @@ class Client(object):
|
|||||||
:raises: FBchatException if request failed
|
:raises: FBchatException if request failed
|
||||||
"""
|
"""
|
||||||
threads = []
|
threads = []
|
||||||
threads += self.fetchThreadList(thread_location=thread_location)
|
|
||||||
if not threads:
|
|
||||||
return []
|
|
||||||
|
|
||||||
|
last_thread_timestamp = None
|
||||||
while True:
|
while True:
|
||||||
# break if limit is exceeded
|
# break if limit is exceeded
|
||||||
if limit and len(threads) >= limit:
|
if limit and len(threads) >= limit:
|
||||||
break
|
break
|
||||||
|
|
||||||
last_thread_timestamp = threads[-1].last_message_timestamp
|
|
||||||
# fetchThreadList returns at max 20 threads before last_thread_timestamp (included)
|
# fetchThreadList returns at max 20 threads before last_thread_timestamp (included)
|
||||||
candidates = self.fetchThreadList(before=last_thread_timestamp,
|
candidates = self.fetchThreadList(before=last_thread_timestamp,
|
||||||
thread_location=thread_location
|
thread_location=thread_location
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(candidates) > 1:
|
if len(candidates) > 1:
|
||||||
threads += candidates[1:]
|
threads += candidates[1:]
|
||||||
else: # End of threads
|
else: # End of threads
|
||||||
break
|
break
|
||||||
|
|
||||||
|
last_thread_timestamp = threads[-1].last_message_timestamp
|
||||||
|
|
||||||
# FB returns a sorted list of threads
|
# FB returns a sorted list of threads
|
||||||
if (before is not None and int(last_thread_timestamp) > before) or \
|
if (before is not None and int(last_thread_timestamp) > before) or \
|
||||||
(after is not None and int(last_thread_timestamp) < after):
|
(after is not None and int(last_thread_timestamp) < after):
|
||||||
@@ -527,7 +527,7 @@ class Client(object):
|
|||||||
|
|
||||||
# Return only threads between before and after (if set)
|
# Return only threads between before and after (if set)
|
||||||
if before is not None or after is not None:
|
if before is not None or after is not None:
|
||||||
for t in list(threads):
|
for t in threads:
|
||||||
last_message_timestamp = int(t.last_message_timestamp)
|
last_message_timestamp = int(t.last_message_timestamp)
|
||||||
if (before is not None and last_message_timestamp > before) or \
|
if (before is not None and last_message_timestamp > before) or \
|
||||||
(after is not None and last_message_timestamp < after):
|
(after is not None and last_message_timestamp < after):
|
||||||
|
Reference in New Issue
Block a user