Merge pull request #170 from OMGWINNING/master

Add extensible_attachment field to Message for fb share objects
This commit is contained in:
Mads Marquart
2017-06-29 16:02:27 +02:00
committed by GitHub
3 changed files with 12 additions and 4 deletions

View File

@@ -736,9 +736,10 @@ class Client(object):
if k['thread_type'] == 1:
if k['other_user_fbid'] not in participants:
raise Exception('A thread was not in participants: {}'.format(j['payload']))
participants[k['other_user_fbid']].last_message_timestamp = k['last_message_timestamp']
entries.append(participants[k['other_user_fbid']])
elif k['thread_type'] == 2:
entries.append(Group(k['thread_fbid'], participants=set([p.strip('fbid:') for p in k['participants']]), photo=k['image_src'], name=k['name']))
entries.append(Group(k['thread_fbid'], participants=set([p.strip('fbid:') for p in k['participants']]), photo=k['image_src'], name=k['name'], last_message_timestamp=k['last_message_timestamp']))
else:
raise Exception('A thread had an unknown thread type: {}'.format(k))

View File

@@ -75,7 +75,8 @@ def graphql_to_message(message):
text=message.get('message').get('text'),
mentions=[Mention(m.get('entity', {}).get('id'), offset=m.get('offset'), length=m.get('length')) for m in message.get('message').get('ranges', [])],
sticker=message.get('sticker'),
attachments=message.get('blob_attachments')
attachments=message.get('blob_attachments'),
extensible_attachment=message.get('extensible_attachment')
)
def graphql_to_user(user):

View File

@@ -13,13 +13,16 @@ class Thread(object):
photo = str
#: The name of the thread
name = str
#: Timestamp of last message
last_message_timestamp = str
def __init__(self, _type, uid, photo=None, name=None):
def __init__(self, _type, uid, photo=None, name=None, last_message_timestamp=None):
"""Represents a Facebook thread"""
self.uid = str(uid)
self.type = _type
self.photo = photo
self.name = name
self.last_message_timestamp = last_message_timestamp
def __repr__(self):
return self.__unicode__()
@@ -125,8 +128,10 @@ class Message(object):
sticker = str
#: A list of attachments
attachments = list
#: An extensible attachment, e.g. share object
extensible_attachment = dict
def __init__(self, uid, author=None, timestamp=None, is_read=None, reactions=[], text=None, mentions=[], sticker=None, attachments=[]):
def __init__(self, uid, author=None, timestamp=None, is_read=None, reactions=[], text=None, mentions=[], sticker=None, attachments=[], extensible_attachment={}):
"""Represents a Facebook message"""
self.uid = uid
self.author = author
@@ -137,6 +142,7 @@ class Message(object):
self.mentions = mentions
self.sticker = sticker
self.attachments = attachments
self.extensible_attachment = extensible_attachment
class Mention(object):