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
23792383
Commit
23792383
authored
Aug 30, 2022
by
Tijmen de Mes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed receiving messages from different account in message session
parent
ff518123
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
19 deletions
+37
-19
chatwindow.py
blink/chatwindow.py
+14
-10
messages.py
blink/messages.py
+23
-9
No files found.
blink/chatwindow.py
View file @
23792383
...
@@ -2238,8 +2238,8 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
...
@@ -2238,8 +2238,8 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
def
send_pending_imdn_messages
(
self
,
session
):
def
send_pending_imdn_messages
(
self
,
session
):
if
session
and
session
.
blink_session
in
self
.
pending_displayed_notifications
:
if
session
and
session
.
blink_session
in
self
.
pending_displayed_notifications
:
item
=
self
.
pending_displayed_notifications
.
pop
(
self
.
selected_session
.
blink_session
)
item
=
self
.
pending_displayed_notifications
.
pop
(
self
.
selected_session
.
blink_session
)
for
(
id
,
timestamp
)
in
item
:
for
(
id
,
timestamp
,
account
)
in
item
:
MessageManager
()
.
send_imdn_message
(
session
.
blink_session
,
id
,
timestamp
,
'displayed'
)
MessageManager
()
.
send_imdn_message
(
session
.
blink_session
,
id
,
timestamp
,
'displayed'
,
account
)
@
run_in_gui_thread
@
run_in_gui_thread
def
handle_notification
(
self
,
notification
):
def
handle_notification
(
self
,
notification
):
...
@@ -2414,6 +2414,7 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
...
@@ -2414,6 +2414,7 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
account
=
account_manager
.
get_account
(
uri
)
account
=
account_manager
.
get_account
(
uri
)
sender
=
ChatSender
(
message
.
sender
.
display_name
or
account
.
display_name
,
uri
,
session
.
chat_widget
.
user_icon
.
filename
)
sender
=
ChatSender
(
message
.
sender
.
display_name
or
account
.
display_name
,
uri
,
session
.
chat_widget
.
user_icon
.
filename
)
else
:
else
:
account
=
None
sender
=
ChatSender
(
message
.
sender
.
display_name
or
session
.
name
,
uri
,
session
.
icon
.
filename
)
sender
=
ChatSender
(
message
.
sender
.
display_name
or
session
.
name
,
uri
,
session
.
icon
.
filename
)
if
session
.
chat_widget
.
history_loaded
:
if
session
.
chat_widget
.
history_loaded
:
if
message
in
self
.
pending_decryption
and
not
encrypted
:
if
message
in
self
.
pending_decryption
and
not
encrypted
:
...
@@ -2427,9 +2428,9 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
...
@@ -2427,9 +2428,9 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
if
message
.
disposition
is
not
None
and
'display'
in
message
.
disposition
and
not
encrypted
:
if
message
.
disposition
is
not
None
and
'display'
in
message
.
disposition
and
not
encrypted
:
if
self
.
selected_session
.
blink_session
is
blink_session
and
not
self
.
isMinimized
()
and
self
.
isActiveWindow
():
if
self
.
selected_session
.
blink_session
is
blink_session
and
not
self
.
isMinimized
()
and
self
.
isActiveWindow
():
MessageManager
()
.
send_imdn_message
(
blink_session
,
message
.
id
,
message
.
timestamp
,
'displayed'
)
MessageManager
()
.
send_imdn_message
(
blink_session
,
message
.
id
,
message
.
timestamp
,
'displayed'
,
account
)
else
:
else
:
self
.
pending_displayed_notifications
.
setdefault
(
blink_session
,
[])
.
append
((
message
.
id
,
message
.
timestamp
))
self
.
pending_displayed_notifications
.
setdefault
(
blink_session
,
[])
.
append
((
message
.
id
,
message
.
timestamp
,
account
))
session
.
remote_composing
=
False
session
.
remote_composing
=
False
settings
=
SIPSimpleSettings
()
settings
=
SIPSimpleSettings
()
...
@@ -2492,12 +2493,15 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
...
@@ -2492,12 +2493,15 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
notification_center
=
NotificationCenter
()
notification_center
=
NotificationCenter
()
blink_message
=
BlinkMessage
(
content
,
message
.
content_type
,
id
=
message
.
message_id
,
is_secure
=
True
)
blink_message
=
BlinkMessage
(
content
,
message
.
content_type
,
id
=
message
.
message_id
,
is_secure
=
True
)
notification_center
.
post_notification
(
'BlinkMessageDidDecrypt'
,
sender
=
blink_session
,
data
=
NotificationData
(
message
=
blink_message
))
notification_center
.
post_notification
(
'BlinkMessageDidDecrypt'
,
sender
=
blink_session
,
data
=
NotificationData
(
message
=
blink_message
))
account_manager
=
AccountManager
()
account
=
account_manager
.
get_account
(
message
.
account_id
)
if
account_manager
.
has_account
(
message
.
account_id
)
else
None
if
message
.
state
!=
'displayed'
and
'display'
in
message
.
disposition
:
if
message
.
state
!=
'displayed'
and
'display'
in
message
.
disposition
:
if
message
.
state
!=
'delivered'
and
'positive-delivery'
in
message
.
disposition
:
if
message
.
state
!=
'delivered'
and
'positive-delivery'
in
message
.
disposition
:
MessageManager
()
.
send_imdn_message
(
blink_session
,
message
.
message_id
,
message
.
timestamp
,
'delivered'
)
MessageManager
()
.
send_imdn_message
(
blink_session
,
message
.
message_id
,
message
.
timestamp
,
'delivered'
,
account
)
if
self
.
selected_session
.
blink_session
is
blink_session
and
not
self
.
isMinimized
()
and
self
.
isActiveWindow
():
if
self
.
selected_session
.
blink_session
is
blink_session
and
not
self
.
isMinimized
()
and
self
.
isActiveWindow
():
MessageManager
()
.
send_imdn_message
(
blink_session
,
message
.
message_id
,
message
.
timestamp
,
'displayed'
)
MessageManager
()
.
send_imdn_message
(
blink_session
,
message
.
message_id
,
message
.
timestamp
,
'displayed'
,
account
)
session
.
chat_widget
.
update_message_encryption
(
message
.
message_id
,
True
)
session
.
chat_widget
.
update_message_encryption
(
message
.
message_id
,
True
)
def
_NH_PGPMessageDidNotDecrypt
(
self
,
notification
):
def
_NH_PGPMessageDidNotDecrypt
(
self
,
notification
):
...
@@ -2562,6 +2566,7 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
...
@@ -2562,6 +2566,7 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
account
=
account_manager
.
get_account
(
uri
)
account
=
account_manager
.
get_account
(
uri
)
sender
=
ChatSender
(
message
.
display_name
or
account
.
display_name
,
uri
,
session
.
chat_widget
.
user_icon
.
filename
)
sender
=
ChatSender
(
message
.
display_name
or
account
.
display_name
,
uri
,
session
.
chat_widget
.
user_icon
.
filename
)
else
:
else
:
account
=
None
sender
=
ChatSender
(
message
.
display_name
or
session
.
name
,
uri
,
session
.
icon
.
filename
)
sender
=
ChatSender
(
message
.
display_name
or
session
.
name
,
uri
,
session
.
icon
.
filename
)
session
.
chat_widget
.
add_message
(
ChatMessage
(
content
,
sender
,
message
.
direction
,
id
=
message
.
message_id
,
timestamp
=
timestamp
,
history
=
True
))
session
.
chat_widget
.
add_message
(
ChatMessage
(
content
,
sender
,
message
.
direction
,
id
=
message
.
message_id
,
timestamp
=
timestamp
,
history
=
True
))
...
@@ -2571,12 +2576,11 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
...
@@ -2571,12 +2576,11 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
session
.
chat_widget
.
update_message_status
(
id
=
message
.
message_id
,
status
=
message
.
state
)
session
.
chat_widget
.
update_message_status
(
id
=
message
.
message_id
,
status
=
message
.
state
)
elif
message
.
state
!=
'displayed'
and
'display'
in
message
.
disposition
and
not
encrypted
:
elif
message
.
state
!=
'displayed'
and
'display'
in
message
.
disposition
and
not
encrypted
:
if
message
.
state
!=
'delivered'
and
'positive-delivery'
in
message
.
disposition
:
if
message
.
state
!=
'delivered'
and
'positive-delivery'
in
message
.
disposition
:
MessageManager
()
.
send_imdn_message
(
blink_session
,
message
.
message_id
,
message
.
timestamp
,
'delivered'
)
MessageManager
()
.
send_imdn_message
(
blink_session
,
message
.
message_id
,
message
.
timestamp
,
'delivered'
,
account
)
if
self
.
selected_session
.
blink_session
is
blink_session
and
not
self
.
isMinimized
()
and
self
.
isActiveWindow
():
if
self
.
selected_session
.
blink_session
is
blink_session
and
not
self
.
isMinimized
()
and
self
.
isActiveWindow
():
MessageManager
()
.
send_imdn_message
(
blink_session
,
message
.
message_id
,
message
.
timestamp
,
'displayed'
)
MessageManager
()
.
send_imdn_message
(
blink_session
,
message
.
message_id
,
message
.
timestamp
,
'displayed'
,
account
)
else
:
else
:
self
.
pending_displayed_notifications
.
setdefault
(
blink_session
,
[])
.
append
((
message
.
message_id
,
message
.
timestamp
))
self
.
pending_displayed_notifications
.
setdefault
(
blink_session
,
[])
.
append
((
message
.
message_id
,
message
.
timestamp
,
account
))
if
'OpenPGP'
in
message
.
encryption_type
:
if
'OpenPGP'
in
message
.
encryption_type
:
session
.
chat_widget
.
update_message_encryption
(
message
.
message_id
,
True
)
session
.
chat_widget
.
update_message_encryption
(
message
.
message_id
,
True
)
session
.
chat_widget
.
history_loaded
=
True
session
.
chat_widget
.
history_loaded
=
True
...
...
blink/messages.py
View file @
23792383
...
@@ -576,8 +576,9 @@ class MessageManager(object, metaclass=Singleton):
...
@@ -576,8 +576,9 @@ class MessageManager(object, metaclass=Singleton):
return
True
return
True
return
False
return
False
def
_handle_incoming_message
(
self
,
message
,
session
):
def
_handle_incoming_message
(
self
,
message
,
session
,
account
=
None
):
notification_center
=
NotificationCenter
()
notification_center
=
NotificationCenter
()
if
account
is
session
.
account
:
notification_center
.
post_notification
(
'BlinkMessageIsParsed'
,
sender
=
session
,
data
=
message
)
notification_center
.
post_notification
(
'BlinkMessageIsParsed'
,
sender
=
session
,
data
=
message
)
if
message
is
not
None
and
'positive-delivery'
in
message
.
disposition
:
if
message
is
not
None
and
'positive-delivery'
in
message
.
disposition
:
...
@@ -797,18 +798,28 @@ class MessageManager(object, metaclass=Singleton):
...
@@ -797,18 +798,28 @@ class MessageManager(object, metaclass=Singleton):
notification_center
.
post_notification
(
'BlinkGotComposingIndication'
,
sender
=
blink_session
,
data
=
data
)
notification_center
.
post_notification
(
'BlinkGotComposingIndication'
,
sender
=
blink_session
,
data
=
data
)
return
return
if
not
content_type
.
lower
()
.
startswith
(
'text'
):
return
if
account
is
not
blink_session
.
account
:
history_message_data
=
NotificationData
(
remote_uri
=
contact
.
uri
.
uri
,
message
=
message
,
encryption
=
encryption
,
state
=
'accepted'
)
notification_center
.
post_notification
(
'BlinkGotHistoryMessage'
,
sender
=
account
,
data
=
history_message_data
)
if
encryption
==
'OpenPGP'
:
if
encryption
==
'OpenPGP'
:
if
blink_session
.
fake_streams
.
get
(
'messages'
)
.
can_decrypt
:
if
blink_session
.
fake_streams
.
get
(
'messages'
)
.
can_decrypt
:
blink_session
.
fake_streams
.
get
(
'messages'
)
.
decrypt
(
message
)
blink_session
.
fake_streams
.
get
(
'messages'
)
.
decrypt
(
message
)
else
:
else
:
self
.
_incoming_encrypted_message_queue
.
append
((
message
,
account
,
contact
))
self
.
_incoming_encrypted_message_queue
.
append
((
message
,
account
,
contact
))
if
account
is
blink_session
.
account
:
notification_center
.
post_notification
(
'BlinkMessageIsParsed'
,
sender
=
blink_session
,
data
=
message
)
notification_center
.
post_notification
(
'BlinkMessageIsParsed'
,
sender
=
blink_session
,
data
=
message
)
self
.
_add_contact_to_messages_group
(
blink_session
.
account
,
blink_session
.
contact
)
self
.
_add_contact_to_messages_group
(
blink_session
.
account
,
blink_session
.
contact
)
notification_center
.
post_notification
(
'BlinkGotMessage'
,
sender
=
blink_session
,
data
=
message
)
notification_center
.
post_notification
(
'BlinkGotMessage'
,
sender
=
blink_session
,
data
=
message
)
return
return
self
.
_handle_incoming_message
(
message
,
blink_session
)
self
.
_handle_incoming_message
(
message
,
blink_session
,
account
)
else
:
else
:
# TODO handle replicated messages
# TODO handle replicated messages
pass
pass
...
@@ -860,7 +871,7 @@ class MessageManager(object, metaclass=Singleton):
...
@@ -860,7 +871,7 @@ class MessageManager(object, metaclass=Singleton):
notification_center
=
NotificationCenter
()
notification_center
=
NotificationCenter
()
notification_center
.
post_notification
(
'BlinkMessageDidDecrypt'
,
sender
=
session
,
data
=
NotificationData
(
message
=
notification
.
data
.
message
))
notification_center
.
post_notification
(
'BlinkMessageDidDecrypt'
,
sender
=
session
,
data
=
NotificationData
(
message
=
notification
.
data
.
message
))
self
.
_handle_incoming_message
(
notification
.
data
.
message
,
session
)
self
.
_handle_incoming_message
(
notification
.
data
.
message
,
session
,
notification
.
data
.
account
)
def
_NH_PGPMessageDidNotDecrypt
(
self
,
notification
):
def
_NH_PGPMessageDidNotDecrypt
(
self
,
notification
):
session
=
notification
.
sender
session
=
notification
.
sender
...
@@ -895,11 +906,14 @@ class MessageManager(object, metaclass=Singleton):
...
@@ -895,11 +906,14 @@ class MessageManager(object, metaclass=Singleton):
outgoing_message
=
OutgoingMessage
(
session
.
account
,
session
.
contact
,
content
,
IsComposingDocument
.
content_type
,
session
=
session
)
outgoing_message
=
OutgoingMessage
(
session
.
account
,
session
.
contact
,
content
,
IsComposingDocument
.
content_type
,
session
=
session
)
self
.
_send_message
(
outgoing_message
)
self
.
_send_message
(
outgoing_message
)
def
send_imdn_message
(
self
,
session
,
id
,
timestamp
,
state
):
def
send_imdn_message
(
self
,
session
,
id
,
timestamp
,
state
,
account
=
None
):
if
not
session
.
account
.
sms
.
use_cpim
and
not
session
.
account
.
sms
.
enable_imdn
:
if
not
session
.
account
.
sms
.
use_cpim
and
not
session
.
account
.
sms
.
enable_imdn
and
account
is
None
:
return
if
account
is
not
None
and
not
account
.
sms
.
use_cpim
and
not
account
.
sms
.
enable_imdn
:
return
return
# print(f"-- Will send imdn for {id} ->
{state}")
log
.
debug
(
f
"-- Attempt to send imdn for {id}:
{state}"
)
if
state
==
'delivered'
:
if
state
==
'delivered'
:
notification
=
DeliveryNotification
(
state
)
notification
=
DeliveryNotification
(
state
)
elif
state
==
'displayed'
:
elif
state
==
'displayed'
:
...
@@ -912,7 +926,7 @@ class MessageManager(object, metaclass=Singleton):
...
@@ -912,7 +926,7 @@ class MessageManager(object, metaclass=Singleton):
recipient_uri
=
session
.
contact
.
uri
.
uri
,
recipient_uri
=
session
.
contact
.
uri
.
uri
,
notification
=
notification
)
notification
=
notification
)
outgoing_message
=
OutgoingMessage
(
session
.
account
,
session
.
contact
,
content
,
IMDNDocument
.
content_type
,
session
=
session
)
outgoing_message
=
OutgoingMessage
(
session
.
account
if
account
is
None
else
account
,
session
.
contact
,
content
,
IMDNDocument
.
content_type
,
session
=
session
)
self
.
_send_message
(
outgoing_message
)
self
.
_send_message
(
outgoing_message
)
def
send_message
(
self
,
account
,
contact
,
content
,
content_type
=
'text/plain'
,
recipients
=
None
,
courtesy_recipients
=
None
,
subject
=
None
,
timestamp
=
None
,
required
=
None
,
additional_headers
=
None
,
id
=
None
):
def
send_message
(
self
,
account
,
contact
,
content
,
content_type
=
'text/plain'
,
recipients
=
None
,
courtesy_recipients
=
None
,
subject
=
None
,
timestamp
=
None
,
required
=
None
,
additional_headers
=
None
,
id
=
None
):
...
...
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