Commit d5d21397 authored by Tijmen de Mes's avatar Tijmen de Mes

Changed got message event to allow for more arguments

parent 4b03268b
...@@ -2380,12 +2380,12 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin): ...@@ -2380,12 +2380,12 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
def _NH_BlinkGotMessage(self, notification): def _NH_BlinkGotMessage(self, notification):
blink_session = notification.sender blink_session = notification.sender
session = blink_session.items.chat session = blink_session.items.chat
message = notification.data
if session is None: if session is None:
return return
message = notification.data.message
direction = notification.data.message.direction
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())
...@@ -2421,10 +2421,10 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin): ...@@ -2421,10 +2421,10 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
self.pending_decryption.remove(message) self.pending_decryption.remove(message)
session.chat_widget.update_message_text(message.id, content) session.chat_widget.update_message_text(message.id, content)
else: else:
session.chat_widget.add_message(ChatMessage(content, sender, 'incoming', id=message.id)) session.chat_widget.add_message(ChatMessage(content, sender, direction, id=message.id))
session.chat_widget.update_message_encryption(message.id, message.is_secure) session.chat_widget.update_message_encryption(message.id, message.is_secure)
else: else:
self.render_after_load.append(ChatMessage(content, sender, 'incoming', id=message.id)) self.render_after_load.append(ChatMessage(content, sender, direction, id=message.id))
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():
......
...@@ -585,8 +585,8 @@ class MessageManager(object, metaclass=Singleton): ...@@ -585,8 +585,8 @@ class MessageManager(object, metaclass=Singleton):
print("-- Should send delivered imdn") print("-- Should send delivered imdn")
self.send_imdn_message(session, message.id, message.timestamp, 'delivered') self.send_imdn_message(session, message.id, message.timestamp, 'delivered')
notification_center.post_notification('BlinkGotMessage', sender=session, data=message)
self._add_contact_to_messages_group(session.account, session.contact) self._add_contact_to_messages_group(session.account, session.contact)
notification_center.post_notification('BlinkGotMessage', sender=session, data=NotificationData(message=message))
def _send_message(self, outgoing_message): def _send_message(self, outgoing_message):
self._outgoing_message_queue.append(outgoing_message) self._outgoing_message_queue.append(outgoing_message)
...@@ -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=message) data=NotificationData(message=message))
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