Commit 52e55cfb authored by Tijmen de Mes's avatar Tijmen de Mes

Handle IMDN when there is no session

parent 25437290
...@@ -2414,7 +2414,11 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin): ...@@ -2414,7 +2414,11 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
def _NH_BlinkGotDispositionNotification(self, notification): def _NH_BlinkGotDispositionNotification(self, notification):
blink_session = notification.sender blink_session = notification.sender
try:
session = blink_session.items.chat session = blink_session.items.chat
except AttributeError:
return
if session is None: if session is None:
return return
data = notification.data data = notification.data
......
...@@ -744,7 +744,10 @@ class MessageManager(object, metaclass=Singleton): ...@@ -744,7 +744,10 @@ class MessageManager(object, metaclass=Singleton):
try: try:
blink_session = next(session for session in self.sessions if session.contact.settings is contact.settings) blink_session = next(session for session in self.sessions if session.contact.settings is contact.settings)
except StopIteration: except StopIteration:
blink_session = None
if content_type.lower() in self.__ignored_content_types__: if content_type.lower() in self.__ignored_content_types__:
print("Skipping session")
if content_type.lower() != IMDNDocument.content_type:
return return
else: else:
blink_session = session_manager.create_session(contact, contact_uri, [StreamDescription('messages')], account=account, connect=False) blink_session = session_manager.create_session(contact, contact_uri, [StreamDescription('messages')], account=account, connect=False)
...@@ -757,6 +760,15 @@ class MessageManager(object, metaclass=Singleton): ...@@ -757,6 +760,15 @@ class MessageManager(object, metaclass=Singleton):
blink_session.fake_streams.get('messages').enable_pgp() blink_session.fake_streams.get('messages').enable_pgp()
notification_center.post_notification('BlinkSessionWillAddStream', sender=blink_session, data=NotificationData(stream=stream)) notification_center.post_notification('BlinkSessionWillAddStream', sender=blink_session, data=NotificationData(stream=stream))
if account.sms.use_cpim and account.sms.enable_imdn and content_type.lower() == IMDNDocument.content_type:
document = IMDNDocument.parse(body)
imdn_message_id = document.message_id.value
imdn_status = document.notification.status.__str__()
imdn_datetime = document.datetime.__str__()
notification_center.post_notification('BlinkGotDispositionNotification', sender=blink_session, data=NotificationData(id=imdn_message_id, status=imdn_status))
return
elif content_type.lower() == IMDNDocument.content_type:
return
if content_type.lower() in ['text/pgp-public-key', 'text/pgp-private-key']: if content_type.lower() in ['text/pgp-public-key', 'text/pgp-private-key']:
notification_center.post_notification('PGPKeysShouldReload', sender=blink_session) notification_center.post_notification('PGPKeysShouldReload', sender=blink_session)
return return
...@@ -776,18 +788,7 @@ class MessageManager(object, metaclass=Singleton): ...@@ -776,18 +788,7 @@ class MessageManager(object, metaclass=Singleton):
return return
timestamp = str(cpim_message.timestamp) if cpim_message is not None and cpim_message.timestamp is not None else str(ISOTimestamp.now()) timestamp = str(cpim_message.timestamp) if cpim_message is not None and cpim_message.timestamp is not None else str(ISOTimestamp.now())
if account.sms.use_cpim and account.sms.enable_imdn and content_type.lower() == IMDNDocument.content_type:
# print("-- IMDN received")
document = IMDNDocument.parse(body)
imdn_message_id = document.message_id.value
imdn_status = document.notification.status.__str__()
imdn_datetime = document.datetime.__str__()
notification_center.post_notification('BlinkGotDispositionNotification', sender=blink_session, data=NotificationData(id=imdn_message_id, status=imdn_status))
return
elif content_type.lower() == IMDNDocument.content_type:
return return
message = BlinkMessage(body, content_type, sender, timestamp=timestamp, id=message_id, disposition=disposition) message = BlinkMessage(body, content_type, sender, timestamp=timestamp, id=message_id, disposition=disposition)
if encryption == 'OpenPGP': if encryption == 'OpenPGP':
......
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