Extend MessageReaction
when encountering unknown values
This commit is contained in:
@@ -214,7 +214,16 @@ def graphql_to_message(message):
|
|||||||
rtn.timestamp = message.get('timestamp_precise')
|
rtn.timestamp = message.get('timestamp_precise')
|
||||||
if message.get('unread') is not None:
|
if message.get('unread') is not None:
|
||||||
rtn.is_read = not message['unread']
|
rtn.is_read = not message['unread']
|
||||||
rtn.reactions = {str(r['user']['id']):MessageReaction(r['reaction']) for r in message.get('message_reactions')}
|
|
||||||
|
for r in message.get('message_reactions'):
|
||||||
|
try:
|
||||||
|
reaction = MessageReaction(r['reaction'])
|
||||||
|
except ValueError:
|
||||||
|
log.warning("Failed parsing reaction {}. Extending enum.".format(r['reaction']))
|
||||||
|
aenum.extend_enum(MessageReaction, "UNKNOWN_{}".format(r['reaction']), r['reaction'])
|
||||||
|
reaction = MessageReaction(r['reaction'])
|
||||||
|
rtn.reactions[str(r['user']['id'])] = reaction
|
||||||
|
|
||||||
if message.get('blob_attachments') is not None:
|
if message.get('blob_attachments') is not None:
|
||||||
rtn.attachments = [graphql_to_attachment(attachment) for attachment in message['blob_attachments']]
|
rtn.attachments = [graphql_to_attachment(attachment) for attachment in message['blob_attachments']]
|
||||||
# TODO: This is still missing parsing:
|
# TODO: This is still missing parsing:
|
||||||
|
Reference in New Issue
Block a user