summary refs log tree commit diff
path: root/synapse/storage/profile.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-03-25 17:15:20 +0000
committerErik Johnston <erik@matrix.org>2015-03-25 17:15:20 +0000
commit0e8f5095c7e7075b249ad53a9f60a4d2fdeeaaed (patch)
tree39bdcca49ae0eabf09b3a98e2c4b810e0c68692f /synapse/storage/profile.py
parentEscape non printing ascii character (diff)
downloadsynapse-0e8f5095c7e7075b249ad53a9f60a4d2fdeeaaed.tar.xz
Fix unicode database support
Diffstat (limited to 'synapse/storage/profile.py')
-rw-r--r--synapse/storage/profile.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/synapse/storage/profile.py b/synapse/storage/profile.py
index a6e52cb248..09778045bf 100644
--- a/synapse/storage/profile.py
+++ b/synapse/storage/profile.py
@@ -13,6 +13,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from twisted.internet import defer
+
 from ._base import SQLBaseStore
 
 
@@ -24,19 +26,25 @@ class ProfileStore(SQLBaseStore):
             desc="create_profile",
         )
 
+    @defer.inlineCallbacks
     def get_profile_displayname(self, user_localpart):
-        return self._simple_select_one_onecol(
+        name = yield self._simple_select_one_onecol(
             table="profiles",
             keyvalues={"user_id": user_localpart},
             retcol="displayname",
             desc="get_profile_displayname",
         )
 
+        if name:
+            name = name.decode("utf8")
+
+        defer.returnValue(name)
+
     def set_profile_displayname(self, user_localpart, new_displayname):
         return self._simple_update_one(
             table="profiles",
             keyvalues={"user_id": user_localpart},
-            updatevalues={"displayname": new_displayname},
+            updatevalues={"displayname": new_displayname.encode("utf8")},
             desc="set_profile_displayname",
         )