Commit 2a6230b6 authored by Alp Deniz Ogut's avatar Alp Deniz Ogut
Browse files

Init saving read status

parent 8041ae0a
Showing with 67 additions and 1 deletion
+67 -1
......@@ -7,6 +7,7 @@ EXTENDED_MESSAGE_KEY = "extendedTextMessage"
EXTENDED_MESSAGE_TEXT_KEY = "text"
EMPTY_MESSAGE_CONTENT = "<empty message>"
MESSAGE_TYPE_KEY = "messageStubType"
MESSAGE_STATUS_KEY = "status"
GROUP_PARTICIPANT_LEAVE = "GROUP_PARTICIPANT_LEAVE"
GROUP_PARTICIPANT_PROMOTE = "GROUP_PARTICIPANT_PROMOTE"
END2END_ENCRYPTED_TYPE = "E2E_ENCRYPTED"
......@@ -23,6 +24,10 @@ PARTICIPANT_KEY = "participant"
FROM_ME_KEY = "fromMe"
MESSAGES_BATCH_SIZE = 300
# Whatsapp Messages states
STATUS_READ = "READ"
STATUS_NOT_READ = "DELIVERY_ACK"
# Internal plugin checkpoints
LOGGED_IN = 'logged_in'
GOT_CONTACTS = 'got_contacts'
......
......@@ -87,4 +87,12 @@ def process_message(message):
# incoming message
else:
msg_item._sender_id = remote_jid
# RECIPIENT READ OR NOT
if MESSAGE_STATUS_KEY in message:
if message[MESSAGE_STATUS_KEY] == STATUS_READ:
msg_item.read = True
elif message[MESSAGE_STATUS_KEY] == STATUS_NOT_READ:
msg_item.read = False
return msg_item
\ No newline at end of file
from typing import Optional
from datetime import datetime
from pymemri.data.itembase import Item
from pymemri.data.central_schema import WrittenWork
class Account(Item):
......@@ -81,4 +83,55 @@ class Account(Item):
self.ownCurrency: list = ownCurrency if ownCurrency is not None else []
self.owner: list = owner if owner is not None else []
self.trust: list = trust if trust is not None else []
self.profilePicture: list = profilePicture if profilePicture is not None else []
\ No newline at end of file
self.profilePicture: list = profilePicture if profilePicture is not None else []
class Message(WrittenWork):
description = """A single message."""
properties = WrittenWork.properties + [
"dateReceived",
"dateSent",
"externalId",
"service",
"subject",
"read",
]
edges = WrittenWork.edges + [
"message",
"messageChannel",
"photo",
"receiver",
"sender",
]
def __init__(
self,
dateReceived: datetime = None,
dateSent: datetime = None,
externalId: str = None,
service: str = None,
subject: str = None,
read: bool = None,
message: list = None,
messageChannel: list = None,
photo: list = None,
receiver: list = None,
sender: list = None,
**kwargs
):
super().__init__(**kwargs)
# Properties
self.dateReceived: Optional[datetime] = dateReceived
self.dateSent: Optional[datetime] = dateSent
self.externalId: Optional[str] = externalId
self.service: Optional[str] = service
self.subject: Optional[str] = subject
self.read: Optional[bool] = read
# Edges
self.message: list = message if message is not None else []
self.messageChannel: list = messageChannel if messageChannel is not None else []
self.photo: list = photo if photo is not None else []
self.receiver: list = receiver if receiver is not None else []
self.sender: list = sender if sender is not None else []
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment