Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mrDoctorWho/vk4xmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Smith <mrdoctorwho@helldev.net>2019-06-10 07:21:52 +0300
committerJohn Smith <mrdoctorwho@helldev.net>2019-06-10 07:21:52 +0300
commit72a074f2a04bac12c92e45b7d01990680fda3ee0 (patch)
treec992b851a8e921620492473763368475240efa1f
parent152002e6cc7b9df431182b74a74b083518148bef (diff)
Fake single conversations correctly
-rw-r--r--gateway.py4
-rw-r--r--library/longpoll.py4
2 files changed, 6 insertions, 2 deletions
diff --git a/gateway.py b/gateway.py
index 11435ce..0477db6 100644
--- a/gateway.py
+++ b/gateway.py
@@ -466,7 +466,7 @@ class VK(object):
peers = []
if not conversations:
logger.warning("no conversations for (jid: %s)", source)
- return []
+ return peers
for conversation in conversations:
if isinstance(conversation, dict):
innerConversation = conversation.get("conversation")
@@ -525,7 +525,7 @@ class VK(object):
conversations = self.method("messages.getConversations", {"count": count, "filter": filter_})
conversations = conversations.get("items")
else:
- conversations = {"unread_count": 1, "1": {"conversation": {"peer": {"id": uid}}}}
+ conversations = [{"conversation": {"peer": {"id": uid}}}]
peers = VK.getPeerIds(conversations, self.source)
return self.getMessagesBulk(peers, count=count, mid=mid)
diff --git a/library/longpoll.py b/library/longpoll.py
index 51d5de8..c8db9f0 100644
--- a/library/longpoll.py
+++ b/library/longpoll.py
@@ -110,6 +110,10 @@ def processPollResult(user, data):
mid, flags, uid, date, subject, body, attachments = evt
out = flags & FLAG_OUT
chat = (uid > MIN_CHAT_UID) # a groupchat always has uid > 2000000000
+ # there is no point to request messages if there's only a single emoji attachment
+ # we actually only need to request for new messages if there are complex attachments in it (e.g. photos)
+ if len(attachments) == 1 and "emoji" in attachments:
+ attachments = None
if not out:
if not attachments and not chat:
message = [{"out": 0, "user_id": uid, "id": mid, "date": date, "body": body}]