Commit 880466ff authored by Tijmen de Mes's avatar Tijmen de Mes

Fixes for other account messages in chat session

parent 26246eb3
...@@ -2386,6 +2386,11 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin): ...@@ -2386,6 +2386,11 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
message = notification.data.message message = notification.data.message
direction = notification.data.message.direction direction = notification.data.message.direction
try:
received_account = notification.data.account
except AttributeError:
received_account = None
encrypted = False encrypted = False
if message.content_type.startswith('image/'): if message.content_type.startswith('image/'):
content = '''<img src="data:{};base64,{}" class="scaled-to-fit" />'''.format(message.content_type, message.content.decode('base64').rstrip()) content = '''<img src="data:{};base64,{}" class="scaled-to-fit" />'''.format(message.content_type, message.content.decode('base64').rstrip())
...@@ -2425,9 +2430,9 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin): ...@@ -2425,9 +2430,9 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
if direction != 'outgoing' and message.disposition is not None and 'display' in message.disposition and not encrypted: if direction != 'outgoing' and 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', account) MessageManager().send_imdn_message(blink_session, message.id, message.timestamp, 'displayed', received_account)
else: else:
self.pending_displayed_notifications.setdefault(blink_session, []).append((message.id, message.timestamp, account)) self.pending_displayed_notifications.setdefault(blink_session, []).append((message.id, message.timestamp, received_account))
session.remote_composing = False session.remote_composing = False
settings = SIPSimpleSettings() settings = SIPSimpleSettings()
...@@ -2572,6 +2577,9 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin): ...@@ -2572,6 +2577,9 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
if message.direction == "outgoing": if message.direction == "outgoing":
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 account_manager.has_account(message.account_id):
account = account_manager.get_account(message.account_id)
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', account) 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():
......
...@@ -434,13 +434,13 @@ class OutgoingMessage(object): ...@@ -434,13 +434,13 @@ class OutgoingMessage(object):
# TODO: Figure out how now to send a public when required, not always on start of the first message in the session # TODO: Figure out how now to send a public when required, not always on start of the first message in the session
if self.content_type != 'text/pgp-public-key': if self.content_type != 'text/pgp-public-key':
stream = self.session.fake_streams.get('messages') stream = self.session.fake_streams.get('messages')
if self.account.sms.enable_pgp and stream.can_encrypt: if self.session.account.sms.enable_pgp and stream.can_decrypt:
directory = os.path.join(SIPSimpleSettings().chat.keys_directory.normalized, 'private') directory = os.path.join(SIPSimpleSettings().chat.keys_directory.normalized, 'private')
filename = os.path.join(directory, f'{self.account.id}') filename = os.path.join(directory, f'{self.session.account.id}')
with open(f'{filename}.pubkey', 'rb') as f: with open(f'{filename}.pubkey', 'rb') as f:
public_key = f.read().decode() public_key = f.read().decode()
public_key_message = OutgoingMessage(self.account, self.contact, str(public_key), 'text/pgp-public-key', session=self.session) public_key_message = OutgoingMessage(self.session.account, self.contact, str(public_key), 'text/pgp-public-key', session=self.session)
public_key_message.send() public_key_message.send()
self._send() self._send()
...@@ -846,7 +846,7 @@ class MessageManager(object, metaclass=Singleton): ...@@ -846,7 +846,7 @@ class MessageManager(object, metaclass=Singleton):
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', notification_center.post_notification('BlinkGotMessage',
sender=blink_session, sender=blink_session,
data=NotificationData(message=message)) data=NotificationData(message=message, account=account))
return return
self._handle_incoming_message(message, blink_session, account) self._handle_incoming_message(message, blink_session, account)
......
Markdown is supported
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