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
4ba1c646
Commit
4ba1c646
authored
May 20, 2022
by
Tijmen de Mes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent DNS lookup for each message
parent
e92a48fd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
34 deletions
+43
-34
messages.py
blink/messages.py
+43
-34
No files found.
blink/messages.py
View file @
4ba1c646
...
@@ -61,9 +61,49 @@ class OutgoingMessage(object):
...
@@ -61,9 +61,49 @@ class OutgoingMessage(object):
notification_center
.
add_observer
(
self
,
sender
=
self
.
lookup
)
notification_center
.
add_observer
(
self
,
sender
=
self
.
lookup
)
self
.
lookup
.
lookup_sip_proxy
(
uri
,
settings
.
sip
.
transport_list
,
tls_name
=
self
.
account
.
sip
.
tls_name
or
uri
.
host
)
self
.
lookup
.
lookup_sip_proxy
(
uri
,
settings
.
sip
.
transport_list
,
tls_name
=
self
.
account
.
sip
.
tls_name
or
uri
.
host
)
def
_send
(
self
):
if
self
.
session
.
routes
:
from_uri
=
self
.
account
.
uri
content
=
self
.
content
if
isinstance
(
self
.
content
,
bytes
)
else
self
.
content
.
encode
()
additional_sip_headers
=
[]
if
self
.
account
.
sms
.
use_cpim
:
ns
=
CPIMNamespace
(
'urn:ietf:params:imdn'
,
'imdn'
)
additional_headers
=
[
CPIMHeader
(
'Message-ID'
,
ns
,
self
.
id
)]
if
self
.
account
.
sms
.
enable_imdn
and
self
.
content_type
not
in
self
.
__disabled_imdn_content_types__
:
additional_headers
.
append
(
CPIMHeader
(
'Disposition-Notification'
,
ns
,
'positive-delivery, display'
))
payload
=
CPIMPayload
(
content
,
self
.
content_type
,
charset
=
'utf-8'
,
sender
=
ChatIdentity
(
from_uri
,
self
.
account
.
display_name
),
recipients
=
[
ChatIdentity
(
self
.
sip_uri
,
None
)],
timestamp
=
str
(
self
.
timestamp
),
additional_headers
=
additional_headers
)
payload
,
content_type
=
payload
.
encode
()
else
:
payload
=
content
content_type
=
self
.
content_type
route
=
self
.
session
.
routes
[
0
]
message_request
=
Message
(
FromHeader
(
from_uri
,
self
.
account
.
display_name
),
ToHeader
(
self
.
sip_uri
),
RouteHeader
(
route
.
uri
),
content_type
,
payload
,
credentials
=
self
.
account
.
credentials
,
extra_headers
=
additional_sip_headers
)
notification_center
=
NotificationCenter
()
notification_center
.
add_observer
(
self
,
sender
=
message_request
)
message_request
.
send
()
else
:
pass
# TODO
def
send
(
self
,
session
):
def
send
(
self
,
session
):
self
.
session
=
session
self
.
session
=
session
self
.
_lookup
()
if
self
.
session
.
routes
:
self
.
_send
()
else
:
self
.
_lookup
()
@
run_in_gui_thread
@
run_in_gui_thread
def
handle_notification
(
self
,
notification
):
def
handle_notification
(
self
,
notification
):
...
@@ -74,39 +114,8 @@ class OutgoingMessage(object):
...
@@ -74,39 +114,8 @@ class OutgoingMessage(object):
notification
.
center
.
remove_observer
(
self
,
sender
=
notification
.
sender
)
notification
.
center
.
remove_observer
(
self
,
sender
=
notification
.
sender
)
if
notification
.
sender
is
self
.
lookup
:
if
notification
.
sender
is
self
.
lookup
:
routes
=
notification
.
data
.
result
routes
=
notification
.
data
.
result
if
routes
:
self
.
session
.
routes
=
routes
from_uri
=
self
.
account
.
uri
self
.
_send
()
content
=
self
.
content
if
isinstance
(
self
.
content
,
bytes
)
else
self
.
content
.
encode
()
ns
=
CPIMNamespace
(
'urn:ietf:params:imdn'
,
'imdn'
)
additional_headers
=
[
CPIMHeader
(
'Message-ID'
,
ns
,
self
.
id
)]
additional_sip_headers
=
[]
if
self
.
account
.
sms
.
use_cpim
:
payload
=
CPIMPayload
(
content
,
self
.
content_type
,
charset
=
'utf-8'
,
sender
=
ChatIdentity
(
from_uri
,
self
.
account
.
display_name
),
recipients
=
[
ChatIdentity
(
self
.
sip_uri
,
None
)],
timestamp
=
self
.
timestamp
if
self
.
timestamp
is
not
None
else
str
(
ISOTimestamp
.
now
()),
additional_headers
=
additional_headers
)
payload
,
content_type
=
payload
.
encode
()
else
:
payload
=
content
content_type
=
self
.
content_type
route
=
routes
[
0
]
message_request
=
Message
(
FromHeader
(
from_uri
,
self
.
account
.
display_name
),
ToHeader
(
self
.
sip_uri
),
RouteHeader
(
route
.
uri
),
content_type
,
payload
,
credentials
=
self
.
account
.
credentials
,
extra_headers
=
additional_sip_headers
)
notification_center
=
NotificationCenter
()
notification_center
.
add_observer
(
self
,
sender
=
message_request
)
message_request
.
send
()
else
:
pass
# TODO
def
_NH_DNSLookupDidFail
(
self
,
notification
):
def
_NH_DNSLookupDidFail
(
self
,
notification
):
notification
.
center
.
remove_observer
(
self
,
sender
=
notification
.
sender
)
notification
.
center
.
remove_observer
(
self
,
sender
=
notification
.
sender
)
...
...
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