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
92171f9d
Commit
92171f9d
authored
10 years ago
by
Kegan Dougal
Browse files
Options
Downloads
Patches
Plain Diff
Add stub methods, TODOs and docstrings for application services.
parent
7331d348
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/handlers/appservice.py
+22
-3
22 additions, 3 deletions
synapse/handlers/appservice.py
synapse/storage/appservice.py
+50
-2
50 additions, 2 deletions
synapse/storage/appservice.py
with
72 additions
and
5 deletions
synapse/handlers/appservice.py
+
22
−
3
View file @
92171f9d
...
@@ -42,8 +42,27 @@ class ApplicationServicesHandler(BaseHandler):
...
@@ -42,8 +42,27 @@ class ApplicationServicesHandler(BaseHandler):
"
Consult the home server admin.
"
"
Consult the home server admin.
"
)
)
# update AS entry with base URL
# store this AS
# store namespaces for this AS
defer
.
returnValue
(
"
not_implemented_yet
"
)
defer
.
returnValue
(
"
not_implemented_yet
"
)
def
unregister
(
self
,
token
):
yield
self
.
store
.
unregister_app_service
(
token
)
def
notify_interested_services
(
self
,
event
):
"""
Notifies (pushes) all application services interested in this event.
Pushing is done asynchronously, so this method won
'
t block for any
prolonged length of time.
Args:
event(Event): The event to push out to interested services.
"""
# TODO: Gather interested services
# get_services_for_event(event) <-- room IDs and user IDs
# Get a list of room aliases. Check regex.
# TODO: If unknown user: poke User Query API.
# TODO: If unknown room alias: poke Room Alias Query API.
# TODO: Fork off pushes to these services - XXX First cut, best effort
pass
This diff is collapsed.
Click to expand it.
synapse/storage/appservice.py
+
50
−
2
View file @
92171f9d
...
@@ -84,16 +84,60 @@ class ApplicationServiceStore(SQLBaseStore):
...
@@ -84,16 +84,60 @@ class ApplicationServiceStore(SQLBaseStore):
super
(
ApplicationServiceStore
,
self
).
__init__
(
hs
)
super
(
ApplicationServiceStore
,
self
).
__init__
(
hs
)
self
.
cache
=
ApplicationServiceCache
()
self
.
cache
=
ApplicationServiceCache
()
self
.
clock
=
hs
.
get_clock
()
self
.
clock
=
hs
.
get_clock
()
self
.
_populate_cache
()
def
unregister_app_service
(
self
,
token
):
"""
Unregisters this service.
This removes all AS specific regex and the base URL. The token is the
only thing preserved for future registration attempts.
"""
# TODO: DELETE FROM application_services_regex WHERE id=this service
# TODO: SET url=NULL WHERE token=token
# TODO: Update cache
pass
def
update_app_service
(
self
,
service
):
"""
Update an application service, clobbering what was previously there.
Args:
service(ApplicationService): The updated service.
"""
# NB: There is no "insert" since we provide no public-facing API to
# allocate new ASes. It relies on the server admin inserting the AS
# token into the database manually.
# TODO: UPDATE application_services, SET url WHERE token=service.token
# TODO: DELETE FROM application_services_regex WHERE id=this service
# TODO: INSERT INTO application_services_regex <new namespace regex>
# TODO: Update cache
pass
def
get_services_for_event
(
self
,
event
):
return
self
.
cache
.
get_services_for_event
(
event
)
@defer.inlineCallbacks
@defer.inlineCallbacks
def
get_app_service
(
self
,
as_token
):
def
get_app_service
(
self
,
as_token
,
from_cache
=
True
):
"""
Get the application service with the given token.
"""
Get the application service with the given token.
Args:
Args:
token (str): The application service token.
token (str): The application service token.
from_cache (bool): True to get this service from the cache, False to
check the database.
Raises:
Raises:
StoreError if there was a problem retrieving this.
StoreError if there was a problem retrieving this
service
.
"""
"""
if
from_cache
:
for
service
in
self
.
cache
.
services
:
if
service
.
token
==
as_token
:
defer
.
returnValue
(
service
)
return
defer
.
returnValue
(
None
)
return
# TODO: This should be JOINed with the application_services_regex table.
row
=
self
.
_simple_select_one
(
row
=
self
.
_simple_select_one
(
"
application_services
"
,
{
"
token
"
:
as_token
},
"
application_services
"
,
{
"
token
"
:
as_token
},
[
"
url
"
,
"
token
"
]
[
"
url
"
,
"
token
"
]
...
@@ -101,3 +145,7 @@ class ApplicationServiceStore(SQLBaseStore):
...
@@ -101,3 +145,7 @@ class ApplicationServiceStore(SQLBaseStore):
if
not
row
:
if
not
row
:
raise
StoreError
(
400
,
"
Bad application services token supplied.
"
)
raise
StoreError
(
400
,
"
Bad application services token supplied.
"
)
defer
.
returnValue
(
row
)
defer
.
returnValue
(
row
)
def
_populate_cache
(
self
):
"""
Populates the ApplicationServiceCache from the database.
"""
pass
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