Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
ec3719b5
Commit
ec3719b5
authored
10 years ago
by
Kegan Dougal
Browse files
Options
Downloads
Patches
Plain Diff
Use ApplicationService when registering.
parent
92171f9d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
synapse/handlers/appservice.py
+5
-8
5 additions, 8 deletions
synapse/handlers/appservice.py
synapse/rest/appservice/v1/register.py
+6
-2
6 additions, 2 deletions
synapse/rest/appservice/v1/register.py
synapse/storage/appservice.py
+6
-10
6 additions, 10 deletions
synapse/storage/appservice.py
with
17 additions
and
20 deletions
synapse/handlers/appservice.py
+
5
−
8
View file @
ec3719b5
...
...
@@ -30,21 +30,18 @@ class ApplicationServicesHandler(BaseHandler):
super
(
ApplicationServicesHandler
,
self
).
__init__
(
hs
)
@defer.inlineCallbacks
def
register
(
self
,
base_url
,
token
,
namespa
ce
s
):
def
register
(
self
,
app_servi
ce
):
# check the token is recognised
try
:
app
_service
=
yield
self
.
store
.
get_app_service
(
token
)
if
not
app
_service
:
raise
StoreError
stored
_service
=
yield
self
.
store
.
get_app_service
(
app_service
.
token
)
if
not
stored
_service
:
raise
StoreError
(
404
,
"
Not found
"
)
except
StoreError
:
raise
SynapseError
(
403
,
"
Unrecognised application services token.
"
"
Consult the home server admin.
"
)
# store this AS
defer
.
returnValue
(
"
not_implemented_yet
"
)
# TODO store this AS
def
unregister
(
self
,
token
):
yield
self
.
store
.
unregister_app_service
(
token
)
...
...
This diff is collapsed.
Click to expand it.
synapse/rest/appservice/v1/register.py
+
6
−
2
View file @
ec3719b5
...
...
@@ -18,6 +18,7 @@ from twisted.internet import defer
from
base
import
AppServiceRestServlet
,
as_path_pattern
from
synapse.api.errors
import
CodeMessageException
,
SynapseError
from
synapse.storage.appservice
import
ApplicationService
import
json
import
logging
...
...
@@ -58,7 +59,10 @@ class RegisterRestServlet(AppServiceRestServlet):
self
.
_parse_namespace
(
namespaces
,
params
[
"
namespaces
"
],
"
rooms
"
)
self
.
_parse_namespace
(
namespaces
,
params
[
"
namespaces
"
],
"
aliases
"
)
hs_token
=
yield
self
.
handler
.
register
(
as_url
,
as_token
,
namespaces
)
app_service
=
ApplicationService
(
as_token
,
as_url
,
namespaces
)
yield
self
.
handler
.
register
(
app_service
)
hs_token
=
"
_not_implemented_yet
"
# TODO: Pull this from self.hs?
defer
.
returnValue
({
"
hs_token
"
:
hs_token
...
...
@@ -97,7 +101,7 @@ class UnregisterRestServlet(AppServiceRestServlet):
except
(
KeyError
,
ValueError
):
raise
SynapseError
(
400
,
"
Missing required key: as_token(str)
"
)
# TODO: pass to the appservice handler
yield
self
.
handler
.
unregister
(
as_token
)
raise
CodeMessageException
(
500
,
"
Not implemented
"
)
...
...
This diff is collapsed.
Click to expand it.
synapse/storage/appservice.py
+
6
−
10
View file @
ec3719b5
...
...
@@ -116,8 +116,7 @@ class ApplicationServiceStore(SQLBaseStore):
def
get_services_for_event
(
self
,
event
):
return
self
.
cache
.
get_services_for_event
(
event
)
@defer.inlineCallbacks
def
get_app_service
(
self
,
as_token
,
from_cache
=
True
):
def
get_app_service
(
self
,
token
,
from_cache
=
True
):
"""
Get the application service with the given token.
Args:
...
...
@@ -130,21 +129,18 @@ class ApplicationServiceStore(SQLBaseStore):
if
from_cache
:
for
service
in
self
.
cache
.
services
:
if
service
.
token
==
as_token
:
defer
.
returnValue
(
service
)
return
defer
.
returnValue
(
None
)
return
if
service
.
token
==
token
:
return
service
return
None
# TODO: This should be JOINed with the application_services_regex table.
row
=
self
.
_simple_select_one
(
"
application_services
"
,
{
"
token
"
:
as_
token
},
"
application_services
"
,
{
"
token
"
:
token
},
[
"
url
"
,
"
token
"
]
)
if
not
row
:
raise
StoreError
(
400
,
"
Bad application services token supplied.
"
)
defer
.
returnValue
(
row
)
return
row
def
_populate_cache
(
self
):
"""
Populates the ApplicationServiceCache from the database.
"""
...
...
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