Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
62c5245c
Commit
62c5245c
authored
8 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Measure notify_interested_services
parent
94962929
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/handlers/appservice.py
+22
-19
22 additions, 19 deletions
synapse/handlers/appservice.py
with
22 additions
and
19 deletions
synapse/handlers/appservice.py
+
22
−
19
View file @
62c5245c
...
...
@@ -17,6 +17,7 @@ from twisted.internet import defer
from
synapse.api.constants
import
EventTypes
from
synapse.appservice
import
ApplicationService
from
synapse.util.metrics
import
Measure
import
logging
...
...
@@ -42,6 +43,7 @@ class ApplicationServicesHandler(object):
self
.
appservice_api
=
hs
.
get_application_service_api
()
self
.
scheduler
=
hs
.
get_application_service_scheduler
()
self
.
started_scheduler
=
False
self
.
clock
=
hs
.
get_clock
()
@defer.inlineCallbacks
def
notify_interested_services
(
self
,
event
):
...
...
@@ -53,25 +55,26 @@ class ApplicationServicesHandler(object):
Args:
event(Event): The event to push out to interested services.
"""
# Gather interested services
services
=
yield
self
.
_get_services_for_event
(
event
)
if
len
(
services
)
==
0
:
return
# no services need notifying
# Do we know this user exists? If not, poke the user query API for
# all services which match that user regex. This needs to block as these
# user queries need to be made BEFORE pushing the event.
yield
self
.
_check_user_exists
(
event
.
sender
)
if
event
.
type
==
EventTypes
.
Member
:
yield
self
.
_check_user_exists
(
event
.
state_key
)
if
not
self
.
started_scheduler
:
self
.
scheduler
.
start
().
addErrback
(
log_failure
)
self
.
started_scheduler
=
True
# Fork off pushes to these services
for
service
in
services
:
self
.
scheduler
.
submit_event_for_as
(
service
,
event
)
with
Measure
(
self
.
clock
,
"
notify_interested_services
"
):
# Gather interested services
services
=
yield
self
.
_get_services_for_event
(
event
)
if
len
(
services
)
==
0
:
return
# no services need notifying
# Do we know this user exists? If not, poke the user query API for
# all services which match that user regex. This needs to block as these
# user queries need to be made BEFORE pushing the event.
yield
self
.
_check_user_exists
(
event
.
sender
)
if
event
.
type
==
EventTypes
.
Member
:
yield
self
.
_check_user_exists
(
event
.
state_key
)
if
not
self
.
started_scheduler
:
self
.
scheduler
.
start
().
addErrback
(
log_failure
)
self
.
started_scheduler
=
True
# Fork off pushes to these services
for
service
in
services
:
self
.
scheduler
.
submit_event_for_as
(
service
,
event
)
@defer.inlineCallbacks
def
query_user_exists
(
self
,
user_id
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment