my.instagram: better unification of like messages/reactions
This commit is contained in:
parent
9aadbb504b
commit
919c84fb5a
2 changed files with 14 additions and 6 deletions
|
@ -102,7 +102,7 @@ def _parse_message(j: Json) -> Optional[_Message]:
|
|||
tid = j['thread_key']['thread_id']
|
||||
uid = j['user_id']
|
||||
created = datetime.fromtimestamp(int(j['timestamp']) / 1_000_000)
|
||||
text: str
|
||||
text: Optional[str] = None
|
||||
if t == 'text':
|
||||
text = j['text']
|
||||
elif t == 'reel_share':
|
||||
|
@ -110,11 +110,14 @@ def _parse_message(j: Json) -> Optional[_Message]:
|
|||
# the problem is that the links are deliberately expired by instagram..
|
||||
text = j['reel_share']['text']
|
||||
elif t == 'action_log':
|
||||
# something like "X liked message" -- hardly useful?
|
||||
return None
|
||||
# for likes this ends up as 'Liked a message' or reactions
|
||||
# which isn't super useful by itself perhaps, but matches GDPR so lets us unify threads better
|
||||
text = j['action_log']['description']
|
||||
else:
|
||||
raise MessageError(id, f"{t} isn't handled yet")
|
||||
|
||||
assert text is not None, j
|
||||
|
||||
return _Message(
|
||||
id=id,
|
||||
created=created,
|
||||
|
|
|
@ -140,6 +140,9 @@ def _entities() -> Iterator[Res[Union[User, _Message]]]:
|
|||
content = None
|
||||
if 'content' in jm:
|
||||
content = _decode(jm['content'])
|
||||
if content.endswith(' to your message '):
|
||||
# ugh. for some reason these contain an extra space and that messes up message merging..
|
||||
content = content.strip()
|
||||
else:
|
||||
share = jm.get('share')
|
||||
photos = jm.get('photos')
|
||||
|
@ -149,9 +152,11 @@ def _entities() -> Iterator[Res[Union[User, _Message]]]:
|
|||
content = str(cc)
|
||||
|
||||
if content is None:
|
||||
# not sure what it means.. perhaps likes or something?
|
||||
logger.warning(f'content is None: {jm}')
|
||||
continue
|
||||
# this happens e.g. on reel shares..
|
||||
# not sure what we can do properly, GPDR has literally no other info in this case
|
||||
# on android in this case at the moment we have as content ''
|
||||
# so for consistency let's do that too
|
||||
content = ''
|
||||
|
||||
timestamp_ms = jm['timestamp_ms']
|
||||
sender_name = _decode(jm['sender_name'])
|
||||
|
|
Loading…
Add table
Reference in a new issue