Redo jsmods loading and fb_dtsg retrieving

This commit is contained in:
Mads Marquart
2020-03-11 11:14:57 +01:00
parent 13e0eb7fcf
commit e6ec5c5194
4 changed files with 163 additions and 52 deletions

View File

@@ -373,6 +373,15 @@ class Session:
def _payload_post(self, url, data, files=None):
j = self._post(url, data, files=files)
_exception.handle_payload_error(j)
# update fb_dtsg token if received in response
if "jsmods" in j:
define = _util.get_jsmods_define(j["jsmods"]["define"])
if "DTSGInitData" in define:
self._fb_dtsg = define["DTSGInitData"]["token"]
elif "DTSGInitialData" in define:
self._fb_dtsg = define["DTSGInitialData"]["token"]
try:
return j["payload"]
except (KeyError, TypeError) as e:
@@ -436,11 +445,6 @@ class Session:
_exception.handle_payload_error(j)
# update JS token if received in response
fb_dtsg = _util.get_jsmods_require(j, 2)
if fb_dtsg is not None:
self._fb_dtsg = fb_dtsg
try:
message_ids = [
(action["message_id"], action["thread_fbid"])