summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--synapse/storage/appservice.py11
-rw-r--r--tests/storage/test_appservice.py4
2 files changed, 11 insertions, 4 deletions
diff --git a/synapse/storage/appservice.py b/synapse/storage/appservice.py
index a8780eca1e..557e377ca5 100644
--- a/synapse/storage/appservice.py
+++ b/synapse/storage/appservice.py
@@ -21,6 +21,7 @@ from twisted.internet import defer
 from synapse.api.constants import Membership
 from synapse.appservice import ApplicationService, AppServiceTransaction
 from synapse.storage.roommember import RoomsForUser
+from synapse.types import UserID
 from ._base import SQLBaseStore
 
 
@@ -31,6 +32,7 @@ class ApplicationServiceStore(SQLBaseStore):
 
     def __init__(self, hs):
         super(ApplicationServiceStore, self).__init__(hs)
+        self.hostname = hs.hostname
         self.services_cache = []
         self._populate_appservice_cache(
             hs.config.app_service_config_files
@@ -200,11 +202,16 @@ class ApplicationServiceStore(SQLBaseStore):
         return service_list
 
     def _load_appservice(self, as_info):
-        required_string_fields = ["url", "as_token", "hs_token", "sender"]
+        required_string_fields = [
+            "url", "as_token", "hs_token", "sender_localpart"
+        ]
         for field in required_string_fields:
             if not isinstance(as_info.get(field), basestring):
                 raise KeyError("Required string field: '%s'", field)
 
+        user = UserID(as_info["sender_localpart"], self.hostname)
+        user_id = user.to_string()
+
         # namespace checks
         if not isinstance(as_info.get("namespaces"), dict):
             raise KeyError("Requires 'namespaces' object.")
@@ -231,7 +238,7 @@ class ApplicationServiceStore(SQLBaseStore):
             url=as_info["url"],
             namespaces=as_info["namespaces"],
             hs_token=as_info["hs_token"],
-            sender=as_info["sender"],
+            sender=user_id,
             id=as_info["as_token"]  # the token is the only unique thing here
         )
 
diff --git a/tests/storage/test_appservice.py b/tests/storage/test_appservice.py
index 58551e40b9..675959c56c 100644
--- a/tests/storage/test_appservice.py
+++ b/tests/storage/test_appservice.py
@@ -60,7 +60,7 @@ class ApplicationServiceStoreTestCase(unittest.TestCase):
 
     def _add_appservice(self, as_token, url, hs_token, sender):
         as_yaml = dict(url=url, as_token=as_token, hs_token=hs_token,
-                       sender=sender, namespaces={})
+                       sender_localpart=sender, namespaces={})
         # use the token as the filename
         with open(as_token, 'w') as outfile:
             outfile.write(yaml.dump(as_yaml))
@@ -138,7 +138,7 @@ class ApplicationServiceTransactionStoreTestCase(unittest.TestCase):
 
     def _add_service(self, url, as_token):
         as_yaml = dict(url=url, as_token=as_token, hs_token="something",
-                       sender="a_sender", namespaces={})
+                       sender_localpart="a_sender", namespaces={})
         # use the token as the filename
         with open(as_token, 'w') as outfile:
             outfile.write(yaml.dump(as_yaml))