fix FetchUnread
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -24,7 +24,8 @@ develop-eggs
|
|||||||
# Sphinx documentation
|
# Sphinx documentation
|
||||||
docs/_build/
|
docs/_build/
|
||||||
|
|
||||||
# Data for tests
|
# Scripts and data for tests
|
||||||
|
my_tests.py
|
||||||
my_test_data.json
|
my_test_data.json
|
||||||
my_data.json
|
my_data.json
|
||||||
tests.data
|
tests.data
|
@@ -797,17 +797,31 @@ class Client(object):
|
|||||||
:raises: FBchatException if request failed
|
:raises: FBchatException if request failed
|
||||||
"""
|
"""
|
||||||
form = {
|
form = {
|
||||||
'client': 'mercury_sync',
|
|
||||||
'folders[0]': 'inbox',
|
'folders[0]': 'inbox',
|
||||||
|
'client': 'mercury',
|
||||||
'last_action_timestamp': now() - 60*1000
|
'last_action_timestamp': now() - 60*1000
|
||||||
# 'last_action_timestamp': 0
|
# 'last_action_timestamp': 0
|
||||||
}
|
}
|
||||||
|
|
||||||
j = self._post(self.req_url.THREAD_SYNC, form, fix_request=True, as_json=True)
|
j = self._post(self.req_url.UNREAD_THREADS, form, fix_request=True, as_json=True)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"message_counts": j['payload']['message_counts'],
|
"unread_threads": j['payload']['unread_thread_fbids']
|
||||||
"unseen_threads": j['payload']['unseen_thread_ids']
|
}
|
||||||
|
|
||||||
|
def fetchUnseen(self):
|
||||||
|
"""
|
||||||
|
.. todo::
|
||||||
|
Documenting this
|
||||||
|
|
||||||
|
:raises: FBchatException if request failed
|
||||||
|
"""
|
||||||
|
form = {}
|
||||||
|
|
||||||
|
j = self._post(self.req_url.UNSEEN_THREADS, form, fix_request=True, as_json=True)
|
||||||
|
|
||||||
|
return {
|
||||||
|
"unseen_threads": j['payload']['unseen_thread_fbids']
|
||||||
}
|
}
|
||||||
|
|
||||||
def fetchImageUrl(self, image_id):
|
def fetchImageUrl(self, image_id):
|
||||||
@@ -1230,28 +1244,29 @@ class Client(object):
|
|||||||
END SEND METHODS
|
END SEND METHODS
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def markAsDelivered(self, userID, threadID):
|
def markAsDelivered(self, threadID, messageID):
|
||||||
"""
|
"""
|
||||||
.. todo::
|
.. todo::
|
||||||
Documenting this
|
Documenting this
|
||||||
"""
|
"""
|
||||||
data = {
|
data = {
|
||||||
"message_ids[0]": threadID,
|
"message_ids[0]": messageID,
|
||||||
"thread_ids[%s][0]" % userID: threadID
|
"thread_ids[%s][0]" % threadID: messageID
|
||||||
}
|
}
|
||||||
|
|
||||||
r = self._post(self.req_url.DELIVERED, data)
|
r = self._post(self.req_url.DELIVERED, data)
|
||||||
return r.ok
|
return r.ok
|
||||||
|
|
||||||
def markAsRead(self, userID):
|
def markAsRead(self, threadID):
|
||||||
"""
|
"""
|
||||||
.. todo::
|
.. todo::
|
||||||
Documenting this
|
Documenting this
|
||||||
"""
|
"""
|
||||||
data = {
|
data = {
|
||||||
|
"ids[%s]" % threadID: True,
|
||||||
"watermarkTimestamp": now(),
|
"watermarkTimestamp": now(),
|
||||||
"shouldSendReadReceipt": True,
|
"shouldSendReadReceipt": True,
|
||||||
"ids[%s]" % userID: True
|
"commerce_last_message_type": "",
|
||||||
}
|
}
|
||||||
|
|
||||||
r = self._post(self.req_url.READ_STATUS, data)
|
r = self._post(self.req_url.READ_STATUS, data)
|
||||||
|
@@ -87,7 +87,8 @@ class ReqUrl(object):
|
|||||||
SEARCH = "https://www.facebook.com/ajax/typeahead/search.php"
|
SEARCH = "https://www.facebook.com/ajax/typeahead/search.php"
|
||||||
LOGIN = "https://m.facebook.com/login.php?login_attempt=1"
|
LOGIN = "https://m.facebook.com/login.php?login_attempt=1"
|
||||||
SEND = "https://www.facebook.com/messaging/send/"
|
SEND = "https://www.facebook.com/messaging/send/"
|
||||||
THREAD_SYNC = "https://www.facebook.com/ajax/mercury/thread_sync.php"
|
UNREAD_THREADS = "https://www.facebook.com/ajax/mercury/unread_threads.php"
|
||||||
|
UNSEEN_THREADS = "https://www.facebook.com/mercury/unseen_thread_ids/"
|
||||||
THREADS = "https://www.facebook.com/ajax/mercury/threadlist_info.php"
|
THREADS = "https://www.facebook.com/ajax/mercury/threadlist_info.php"
|
||||||
MESSAGES = "https://www.facebook.com/ajax/mercury/thread_info.php"
|
MESSAGES = "https://www.facebook.com/ajax/mercury/thread_info.php"
|
||||||
READ_STATUS = "https://www.facebook.com/ajax/mercury/change_read_status.php"
|
READ_STATUS = "https://www.facebook.com/ajax/mercury/change_read_status.php"
|
||||||
|
Reference in New Issue
Block a user