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
434bbf2c
Commit
434bbf2c
authored
8 years ago
by
Paul "LeoNerd" Evans
Browse files
Options
Downloads
Patches
Plain Diff
Filter 3PU lookups by only ASes that declare knowledge of that protocol
parent
d5bf7a4a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
synapse/appservice/__init__.py
+8
-1
8 additions, 1 deletion
synapse/appservice/__init__.py
synapse/config/appservice.py
+10
-0
10 additions, 0 deletions
synapse/config/appservice.py
synapse/handlers/appservice.py
+4
-2
4 additions, 2 deletions
synapse/handlers/appservice.py
with
22 additions
and
3 deletions
synapse/appservice/__init__.py
+
8
−
1
View file @
434bbf2c
...
...
@@ -81,13 +81,17 @@ class ApplicationService(object):
NS_LIST
=
[
NS_USERS
,
NS_ALIASES
,
NS_ROOMS
]
def
__init__
(
self
,
token
,
url
=
None
,
namespaces
=
None
,
hs_token
=
None
,
sender
=
None
,
id
=
None
):
sender
=
None
,
id
=
None
,
protocols
=
None
):
self
.
token
=
token
self
.
url
=
url
self
.
hs_token
=
hs_token
self
.
sender
=
sender
self
.
namespaces
=
self
.
_check_namespaces
(
namespaces
)
self
.
id
=
id
if
protocols
:
self
.
protocols
=
set
(
protocols
)
else
:
self
.
protocols
=
set
()
def
_check_namespaces
(
self
,
namespaces
):
# Sanity check that it is of the form:
...
...
@@ -219,6 +223,9 @@ class ApplicationService(object):
or
user_id
==
self
.
sender
)
def
is_interested_in_protocol
(
self
,
protocol
):
return
protocol
in
self
.
protocols
def
is_exclusive_alias
(
self
,
alias
):
return
self
.
_is_exclusive
(
ApplicationService
.
NS_ALIASES
,
alias
)
...
...
This diff is collapsed.
Click to expand it.
synapse/config/appservice.py
+
10
−
0
View file @
434bbf2c
...
...
@@ -122,6 +122,15 @@ def _load_appservice(hostname, as_info, config_filename):
raise
ValueError
(
"
Missing/bad type
'
exclusive
'
key in %s
"
,
regex_obj
)
# protocols check
protocols
=
as_info
.
get
(
"
protocols
"
)
if
protocols
:
# Because strings are lists in python
if
isinstance
(
protocols
,
str
)
or
not
isinstance
(
protocols
,
list
):
raise
KeyError
(
"
Optional
'
protocols
'
must be a list if present.
"
)
for
p
in
protocols
:
if
not
isinstance
(
p
,
str
):
raise
KeyError
(
"
Bad value for
'
protocols
'
item
"
)
return
ApplicationService
(
token
=
as_info
[
"
as_token
"
],
url
=
as_info
[
"
url
"
],
...
...
@@ -129,4 +138,5 @@ def _load_appservice(hostname, as_info, config_filename):
hs_token
=
as_info
[
"
hs_token
"
],
sender
=
user_id
,
id
=
as_info
[
"
id
"
],
protocols
=
protocols
,
)
This diff is collapsed.
Click to expand it.
synapse/handlers/appservice.py
+
4
−
2
View file @
434bbf2c
...
...
@@ -191,9 +191,11 @@ class ApplicationServicesHandler(object):
@defer.inlineCallbacks
def
_get_services_for_3pn
(
self
,
protocol
):
# TODO(paul): Filter by protocol
services
=
yield
self
.
store
.
get_app_services
()
defer
.
returnValue
(
services
)
interested_list
=
[
s
for
s
in
services
if
s
.
is_interested_in_protocol
(
protocol
)
]
defer
.
returnValue
(
interested_list
)
@defer.inlineCallbacks
def
_is_unknown_user
(
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