Add stub functions and work out execution flow to implement AS event stream polling.

This commit is contained in:
Kegan Dougal 2015-02-25 15:00:59 +00:00
parent 255f989c7b
commit 2d20466f9a
4 changed files with 65 additions and 12 deletions

View file

@ -17,6 +17,7 @@ from twisted.internet import defer
from synapse.api.errors import StoreError
from synapse.appservice import ApplicationService
from synapse.storage.roommember import RoomsForUser
from ._base import SQLBaseStore
@ -150,6 +151,16 @@ class ApplicationServiceStore(SQLBaseStore):
yield self.cache_defer # make sure the cache is ready
defer.returnValue(self.services_cache)
@defer.inlineCallbacks
def get_app_service_by_user_id(self, user_id):
yield self.cache_defer # make sure the cache is ready
for service in self.services_cache:
if service.sender == user_id:
defer.returnValue(service)
return
defer.returnValue(None)
@defer.inlineCallbacks
def get_app_service_by_token(self, token, from_cache=True):
"""Get the application service with the given token.
@ -173,6 +184,14 @@ class ApplicationServiceStore(SQLBaseStore):
# TODO: The from_cache=False impl
# TODO: This should be JOINed with the application_services_regex table.
@defer.inlineCallbacks
def get_app_service_rooms(self, service):
logger.info("get_app_service_rooms -> %s", service)
# TODO stub
yield self.cache_defer
defer.returnValue([RoomsForUser("!foo:bar", service.sender, "join")])
@defer.inlineCallbacks
def _populate_cache(self):
"""Populates the ApplicationServiceCache from the database."""