summary refs log tree commit diff
path: root/synapse/appservice
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2015-02-05 10:08:12 +0000
committerKegan Dougal <kegan@matrix.org>2015-02-05 10:08:12 +0000
commit27091f146a0ebdbfe1ae7c5cd30de51515cfbebc (patch)
treef32ff280c60ccaf599c2ef053dd5c464e53e3854 /synapse/appservice
parentImpl push_bulk function (diff)
downloadsynapse-27091f146a0ebdbfe1ae7c5cd30de51515cfbebc.tar.xz
Add hs_token column and generate a different token f.e application service.
Diffstat (limited to 'synapse/appservice')
-rw-r--r--synapse/appservice/__init__.py6
-rw-r--r--synapse/appservice/api.py8
2 files changed, 8 insertions, 6 deletions
diff --git a/synapse/appservice/__init__.py b/synapse/appservice/__init__.py
index 0c7f58574e..f7baf578f0 100644
--- a/synapse/appservice/__init__.py
+++ b/synapse/appservice/__init__.py
@@ -34,11 +34,13 @@ class ApplicationService(object):
     # values.
     NS_LIST = [NS_USERS, NS_ALIASES, NS_ROOMS]
 
-    def __init__(self, token, url=None, namespaces=None, txn_id=None):
+    def __init__(self, token, url=None, namespaces=None, hs_token=None,
+                 txn_id=None):
         self.token = token
         self.url = url
+        self.hs_token = hs_token
         self.namespaces = self._check_namespaces(namespaces)
-        self.txn_id = None
+        self.txn_id = txn_id
 
     def _check_namespaces(self, namespaces):
         # Sanity check that it is of the form:
diff --git a/synapse/appservice/api.py b/synapse/appservice/api.py
index fbf4abc526..29bb35d61b 100644
--- a/synapse/appservice/api.py
+++ b/synapse/appservice/api.py
@@ -30,7 +30,6 @@ class ApplicationServiceApi(SimpleHttpClient):
 
     def __init__(self,  hs):
         super(ApplicationServiceApi, self).__init__(hs)
-        self.hs_token = "_hs_token_"  # TODO extract hs token
 
     @defer.inlineCallbacks
     def query_user(self, service, user_id):
@@ -38,7 +37,7 @@ class ApplicationServiceApi(SimpleHttpClient):
         response = None
         try:
             response = yield self.get_json(uri, {
-                "access_token": self.hs_token
+                "access_token": service.hs_token
             })
             if response:  # just an empty json object
                 defer.returnValue(True)
@@ -54,7 +53,7 @@ class ApplicationServiceApi(SimpleHttpClient):
         response = None
         try:
             response = yield self.get_json(uri, {
-                "access_token": self.hs_token
+                "access_token": service.hs_token
             })
             if response:  # just an empty json object
                 defer.returnValue(True)
@@ -76,9 +75,10 @@ class ApplicationServiceApi(SimpleHttpClient):
                     "events": events
                 },
                 {
-                    "access_token": self.hs_token
+                    "access_token": service.hs_token
                 })
             if response:  # just an empty json object
+                # TODO: Mark txn as sent successfully
                 defer.returnValue(True)
         except CodeMessageException as e:
             logger.warning("push_bulk to %s received %s", uri, e.code)