Changed deleted
to unsent
This commit is contained in:
@@ -2366,7 +2366,7 @@ class Client(object):
|
||||
mid = i['messageID']
|
||||
ts = i['deletionTimestamp']
|
||||
author_id = str(i['senderID'])
|
||||
self.onMessageDeleted(mid=mid, author_id=author_id, thread_id=thread_id, thread_type=thread_type,
|
||||
self.onMessageUnsent(mid=mid, author_id=author_id, thread_id=thread_id, thread_type=thread_type,
|
||||
ts=ts, msg=m)
|
||||
|
||||
# New message
|
||||
@@ -2380,7 +2380,7 @@ class Client(object):
|
||||
|
||||
sticker = None
|
||||
attachments = []
|
||||
deleted = False
|
||||
unsent = False
|
||||
if delta.get('attachments'):
|
||||
try:
|
||||
for a in delta['attachments']:
|
||||
@@ -2400,8 +2400,8 @@ class Client(object):
|
||||
|
||||
elif mercury.get('extensible_attachment'):
|
||||
attachment = graphql_to_extensible_attachment(mercury['extensible_attachment'])
|
||||
if isinstance(attachment, DeletedMessage):
|
||||
deleted = True
|
||||
if isinstance(attachment, UnsentMessage):
|
||||
unsent = True
|
||||
elif attachment:
|
||||
attachments.append(attachment)
|
||||
|
||||
@@ -2422,7 +2422,7 @@ class Client(object):
|
||||
message.author = author_id
|
||||
message.timestamp = ts
|
||||
#message.reactions = {}
|
||||
message.deleted = deleted
|
||||
message.unsent = unsent
|
||||
thread_id, thread_type = getThreadIdAndThreadType(metadata)
|
||||
self.onMessage(mid=mid, author_id=author_id, message=delta.get('body', ''), message_object=message,
|
||||
thread_id=thread_id, thread_type=thread_type, ts=ts, metadata=metadata, msg=m)
|
||||
@@ -2778,19 +2778,19 @@ class Client(object):
|
||||
"""
|
||||
log.info("Marked messages as seen in threads {} at {}s".format([(x[0], x[1].name) for x in threads], seen_ts/1000))
|
||||
|
||||
def onMessageDeleted(self, mid=None, author_id=None, thread_id=None, thread_type=None, ts=None, msg=None):
|
||||
def onMessageUnsent(self, mid=None, author_id=None, thread_id=None, thread_type=None, ts=None, msg=None):
|
||||
"""
|
||||
Called when the client is listening, and someone unsends (deleted for everyone) a message
|
||||
Called when the client is listening, and someone unsends (deletes for everyone) a message
|
||||
|
||||
:param mid: ID of the deleted message
|
||||
:param author_id: The ID of the person who deleted the message
|
||||
:param mid: ID of the unsent message
|
||||
:param author_id: The ID of the person who unsent the message
|
||||
:param thread_id: Thread ID that the action was sent to. See :ref:`intro_threads`
|
||||
:param thread_type: Type of thread that the action was sent to. See :ref:`intro_threads`
|
||||
:param ts: A timestamp of the action
|
||||
:param msg: A full set of the data recieved
|
||||
:type thread_type: models.ThreadType
|
||||
"""
|
||||
log.info("{} unsended the message {} in {} ({}) at {}s".format(author_id, repr(mid), thread_id, thread_type.name, ts/1000))
|
||||
log.info("{} unsent the message {} in {} ({}) at {}s".format(author_id, repr(mid), thread_id, thread_type.name, ts/1000))
|
||||
|
||||
def onPeopleAdded(self, mid=None, added_ids=None, author_id=None, thread_id=None, ts=None, msg=None):
|
||||
"""
|
||||
|
@@ -178,7 +178,7 @@ def graphql_to_extensible_attachment(a):
|
||||
attachments=[graphql_to_subattachment(attachment) for attachment in story.get('subattachments')],
|
||||
)
|
||||
else:
|
||||
return DeletedMessage(
|
||||
return UnsentMessage(
|
||||
uid=a.get('legacy_attachment_id'),
|
||||
)
|
||||
|
||||
@@ -282,6 +282,7 @@ def graphql_to_message(message):
|
||||
rtn.uid = str(message.get('message_id'))
|
||||
rtn.author = str(message.get('message_sender').get('id'))
|
||||
rtn.timestamp = message.get('timestamp_precise')
|
||||
rtn.unsent = False
|
||||
if message.get('unread') is not None:
|
||||
rtn.is_read = not message['unread']
|
||||
rtn.reactions = {str(r['user']['id']):MessageReaction(r['reaction']) for r in message.get('message_reactions')}
|
||||
@@ -289,8 +290,8 @@ def graphql_to_message(message):
|
||||
rtn.attachments = [graphql_to_attachment(attachment) for attachment in message['blob_attachments']]
|
||||
if message.get('extensible_attachment') is not None:
|
||||
attachment = graphql_to_extensible_attachment(message['extensible_attachment'])
|
||||
if isinstance(attachment, DeletedMessage):
|
||||
rtn.deleted = True
|
||||
if isinstance(attachment, UnsentMessage):
|
||||
rtn.unsent = True
|
||||
elif attachment:
|
||||
rtn.attachments.append(attachment)
|
||||
return rtn
|
||||
|
@@ -190,8 +190,8 @@ class Message(object):
|
||||
sticker = None
|
||||
#: A list of attachments
|
||||
attachments = None
|
||||
#: Whether the message is deleted (unsended)
|
||||
deleted = None
|
||||
#: Whether the message is unsent (deleted for everyone)
|
||||
unsent = None
|
||||
|
||||
def __init__(self, text=None, mentions=None, emoji_size=None, sticker=None, attachments=None):
|
||||
"""Represents a Facebook message"""
|
||||
@@ -222,11 +222,11 @@ class Attachment(object):
|
||||
"""Represents a Facebook attachment"""
|
||||
self.uid = uid
|
||||
|
||||
class DeletedMessage(Attachment):
|
||||
class UnsentMessage(Attachment):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Represents a deleted message"""
|
||||
super(DeletedMessage, self).__init__(*args, **kwargs)
|
||||
"""Represents an unsent message attachment"""
|
||||
super(UnsentMessage, self).__init__(*args, **kwargs)
|
||||
|
||||
class Sticker(Attachment):
|
||||
#: The sticker-pack's ID
|
||||
|
Reference in New Issue
Block a user