Merge remote-tracking branch '2FWAH/fix-ontyping'

This commit is contained in:
Mads Marquart
2018-06-05 12:51:43 +02:00
2 changed files with 10 additions and 7 deletions

View File

@@ -1529,13 +1529,18 @@ class Client(object):
self.onInbox(unseen=m["unseen"], unread=m["unread"], recent_unread=m["recent_unread"], msg=m) self.onInbox(unseen=m["unseen"], unread=m["unread"], recent_unread=m["recent_unread"], msg=m)
# Typing # Typing
elif mtype == "typ": elif mtype == "typ" or mtype == "ttyp":
author_id = str(m.get("from")) author_id = str(m.get("from"))
thread_id = str(m.get("to")) thread_id = m.get("thread_fbid")
if thread_id == self.uid: if thread_id:
thread_type = ThreadType.USER
else:
thread_type = ThreadType.GROUP thread_type = ThreadType.GROUP
thread_id = str(thread_id)
else:
thread_type = ThreadType.USER
if author_id == self.uid:
thread_id = m.get("to")
else:
thread_id = author_id
typing_status = TypingStatus(m.get("st")) typing_status = TypingStatus(m.get("st"))
self.onTyping(author_id=author_id, status=typing_status, thread_id=thread_id, thread_type=thread_type, msg=m) self.onTyping(author_id=author_id, status=typing_status, thread_id=thread_id, thread_type=thread_type, msg=m)

View File

@@ -103,10 +103,8 @@ def test_change_color_invalid(client):
client.changeThreadColor(InvalidColor()) client.changeThreadColor(InvalidColor())
@pytest.mark.xfail(reason="Apparently onTyping is broken")
@pytest.mark.parametrize("status", TypingStatus) @pytest.mark.parametrize("status", TypingStatus)
def test_typing_status(client, catch_event, compare, status): def test_typing_status(client, catch_event, compare, status):
with catch_event("onTyping") as x: with catch_event("onTyping") as x:
client.setTypingStatus(status) client.setTypingStatus(status)
# x.wait(40)
assert compare(x, status=status) assert compare(x, status=status)