Commit 831e5aa5 authored by Tijmen de Mes's avatar Tijmen de Mes

Send public key to session contact on first message

parent 53b7985e
...@@ -326,6 +326,7 @@ class OutgoingMessage(object): ...@@ -326,6 +326,7 @@ class OutgoingMessage(object):
self.timestamp = timestamp if timestamp is not None else ISOTimestamp.now() self.timestamp = timestamp if timestamp is not None else ISOTimestamp.now()
self.sip_uri = SIPURI.parse('sip:%s' % self.uri) self.sip_uri = SIPURI.parse('sip:%s' % self.uri)
self.session = session self.session = session
self.contact = contact
@property @property
def message(self): def message(self):
...@@ -381,7 +382,6 @@ class OutgoingMessage(object): ...@@ -381,7 +382,6 @@ class OutgoingMessage(object):
payload, payload,
credentials=self.account.credentials, credentials=self.account.credentials,
extra_headers=additional_sip_headers) extra_headers=additional_sip_headers)
notification_center = NotificationCenter()
notification_center.add_observer(self, sender=message_request) notification_center.add_observer(self, sender=message_request)
message_request.send() message_request.send()
else: else:
...@@ -418,6 +418,14 @@ class OutgoingMessage(object): ...@@ -418,6 +418,14 @@ class OutgoingMessage(object):
self._send(routes) self._send(routes)
return return
self.session.routes = routes self.session.routes = routes
# 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':
stream = self.session.fake_streams.get('messages')
if self.account.sms.enable_pgp and stream.can_encrypt:
public_key = stream.public_key
public_key_message = OutgoingMessage(self.account, self.contact, str(public_key), 'text/pgp-public-key', session=self.session)
public_key_message.send()
self._send() self._send()
def _NH_DNSLookupDidFail(self, notification): def _NH_DNSLookupDidFail(self, notification):
......
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