Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Koen van der Veen
whatsapp
Commits
2a6230b6
Commit
2a6230b6
authored
3 years ago
by
Alp Deniz Ogut
Browse files
Options
Download
Email Patches
Plain Diff
Init saving read status
parent
8041ae0a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
whatsapp/constants.py
+5
-0
whatsapp/constants.py
whatsapp/helpers.py
+8
-0
whatsapp/helpers.py
whatsapp/schema.py
+54
-1
whatsapp/schema.py
with
67 additions
and
1 deletion
+67
-1
whatsapp/constants.py
+
5
-
0
View file @
2a6230b6
...
...
@@ -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'
...
...
This diff is collapsed.
Click to expand it.
whatsapp/helpers.py
+
8
-
0
View file @
2a6230b6
...
...
@@ -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
This diff is collapsed.
Click to expand it.
whatsapp/schema.py
+
54
-
1
View file @
2a6230b6
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
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets