mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 13:56:02 -04:00
Add stub methods, TODOs and docstrings for application services.
This commit is contained in:
parent
7331d34839
commit
92171f9dd1
2 changed files with 72 additions and 5 deletions
|
@ -84,16 +84,60 @@ class ApplicationServiceStore(SQLBaseStore):
|
|||
super(ApplicationServiceStore, self).__init__(hs)
|
||||
self.cache = ApplicationServiceCache()
|
||||
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
|
||||
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.
|
||||
|
||||
Args:
|
||||
token (str): The application service token.
|
||||
from_cache (bool): True to get this service from the cache, False to
|
||||
check the database.
|
||||
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(
|
||||
"application_services", {"token": as_token},
|
||||
["url", "token"]
|
||||
|
@ -101,3 +145,7 @@ class ApplicationServiceStore(SQLBaseStore):
|
|||
if not row:
|
||||
raise StoreError(400, "Bad application services token supplied.")
|
||||
defer.returnValue(row)
|
||||
|
||||
def _populate_cache(self):
|
||||
"""Populates the ApplicationServiceCache from the database."""
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue