Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vmj-qt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
vmj-qt
Commits
a30c11cf
Commit
a30c11cf
authored
Aug 15, 2022
by
Tijmen de Mes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added encryption status for messages in history
parent
213a5431
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
history.py
blink/history.py
+29
-0
No files found.
blink/history.py
View file @
a30c11cf
...
...
@@ -55,6 +55,8 @@ class HistoryManager(object, metaclass=Singleton):
notification_center
.
add_observer
(
self
,
name
=
'BlinkMessageIsPending'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkMessageDidSucceed'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkMessageDidFail'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkMessageDidEncrypt'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkMessageDidDecrypt'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkGotDispositionNotification'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkDidSendDispositionNotification'
)
...
...
@@ -157,6 +159,12 @@ class HistoryManager(object, metaclass=Singleton):
data
=
notification
.
data
self
.
message_history
.
update
(
data
.
id
,
'failed'
)
def
_NH_BlinkMessageDidDecrypt
(
self
,
notification
):
self
.
message_history
.
update_encryption
(
notification
)
def
_NH_BlinkMessageDidEncrypt
(
self
,
notification
):
self
.
message_history
.
update_encryption
(
notification
)
def
_NH_BlinkGotDispositionNotification
(
self
,
notification
):
data
=
notification
.
data
self
.
message_history
.
update
(
data
.
id
,
data
.
status
)
...
...
@@ -333,6 +341,10 @@ class MessageHistory(object, metaclass=Singleton):
optional_fields
[
'encryption_type'
]
=
str
([
'{0.encryption} ({0.encryption_cipher}'
.
format
(
chat_info
)])
elif
chat_info
.
transport
==
'tls'
:
optional_fields
[
'encryption_type'
]
=
str
([
'TLS'
])
else
:
message_info
=
session
.
info
.
streams
.
messages
if
message_info
.
encryption
is
not
None
and
message
.
is_secure
:
optional_fields
[
'encryption_type'
]
=
str
([
f
'{message_info.encryption}'
])
try
:
Message
(
remote_uri
=
remote_uri
,
display_name
=
display_name
,
...
...
@@ -364,6 +376,23 @@ class MessageHistory(object, metaclass=Singleton):
# print(f'-- Updating {id} {message.state} -> {state}')
message
.
state
=
state
@
run_in_thread
(
'db'
)
def
update_encryption
(
self
,
notification
):
message
=
notification
.
data
.
message
session
=
notification
.
sender
message_info
=
session
.
info
.
streams
.
messages
if
message_info
.
encryption
is
not
None
and
message
.
is_secure
:
try
:
db_message
=
Message
.
selectBy
(
message_id
=
message
.
id
)[
0
]
except
IndexError
:
pass
else
:
encryption_type
=
str
([
f
'{message_info.encryption}'
])
if
db_message
.
encryption_type
!=
encryption_type
:
# print(f'-- Updating {message.id} encryption {db_message.encryption_type} -> {encryption_type}')
db_message
.
encryption_type
=
encryption_type
@
run_in_thread
(
'db'
)
def
load
(
self
,
uri
,
session
):
# print('-- Loading messages')
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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