fix channel type check and parsing payload
This commit is contained in:
parent
49fd79e882
commit
07ea679ecd
1 changed files with 10 additions and 9 deletions
|
@ -252,22 +252,23 @@ def on_message(ws, message):
|
||||||
|
|
||||||
if 'data' in msg:
|
if 'data' in msg:
|
||||||
|
|
||||||
if msg['meta']['type'] == "message":
|
if 'channel_type' in msg['meta']:
|
||||||
|
|
||||||
# TODO: bypassed other channel types for now
|
# TODO: bypassed other channel types for now
|
||||||
if msg['meta']['channel_type'] != 'io.pnut.core.chat':
|
if msg['meta']['channel_type'] != 'io.pnut.core.chat':
|
||||||
return
|
return
|
||||||
|
|
||||||
pmsg = pnutpy.models.Message.from_response_data(msg['data'])
|
for d_item in msg['data']:
|
||||||
|
pmsg = pnutpy.models.Message.from_response_data(d_item)
|
||||||
|
|
||||||
if 'is_deleted' in msg['meta']:
|
if 'is_deleted' in msg['meta']:
|
||||||
if msg['meta']['is_deleted']:
|
if msg['meta']['is_deleted']:
|
||||||
logger.debug("message: delete")
|
logger.debug("message: delete")
|
||||||
delete_message(pmsg)
|
delete_message(pmsg)
|
||||||
|
else:
|
||||||
|
logger.debug("uh whut?")
|
||||||
else:
|
else:
|
||||||
logger.debug("uh whut?")
|
new_message(pmsg)
|
||||||
else:
|
|
||||||
new_message(pmsg)
|
|
||||||
|
|
||||||
def on_error(ws, error):
|
def on_error(ws, error):
|
||||||
logger.error("on_error: !!! ERROR !!!")
|
logger.error("on_error: !!! ERROR !!!")
|
||||||
|
|
Loading…
Reference in a new issue