summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2018-08-22 17:00:29 +0100
committerErik Johnston <erik@matrix.org>2018-08-22 17:00:29 +0100
commit9643a6f7f208f52febc4be7edb1e38f4ff077b4d (patch)
treebbdee545550e19b7e9e5cdfcb0fcece2737388c3 /synapse
parentrename error code (diff)
downloadsynapse-9643a6f7f208f52febc4be7edb1e38f4ff077b4d.tar.xz
Update notice format
Diffstat (limited to 'synapse')
-rw-r--r--synapse/api/constants.py6
-rw-r--r--synapse/server_notices/resource_limits_server_notices.py14
2 files changed, 15 insertions, 5 deletions
diff --git a/synapse/api/constants.py b/synapse/api/constants.py
index 1fb24578e2..a67862f4ed 100644
--- a/synapse/api/constants.py
+++ b/synapse/api/constants.py
@@ -80,8 +80,6 @@ class EventTypes(object):
     ServerACL = "m.room.server_acl"
     Pinned = "m.room.pinned_events"
 
-    ServerNoticeLimitReached = "m.server_notice.usage_limit_reached"
-
 
 class RejectedReason(object):
     AUTH_ERROR = "auth_error"
@@ -106,3 +104,7 @@ DEFAULT_ROOM_VERSION = "1"
 # vdh-test-version is a placeholder to get room versioning support working and tested
 # until we have a working v2.
 KNOWN_ROOM_VERSIONS = {"1", "vdh-test-version"}
+
+
+ServerNoticeMsgType = "m.server_notice"
+ServerNoticeLimitReached = "m.server_notice.usage_limit_reached"
diff --git a/synapse/server_notices/resource_limits_server_notices.py b/synapse/server_notices/resource_limits_server_notices.py
index 84b91aeb5d..575697e54b 100644
--- a/synapse/server_notices/resource_limits_server_notices.py
+++ b/synapse/server_notices/resource_limits_server_notices.py
@@ -18,7 +18,11 @@ from six import iteritems
 
 from twisted.internet import defer
 
-from synapse.api.constants import EventTypes
+from synapse.api.constants import (
+    EventTypes,
+    ServerNoticeLimitReached,
+    ServerNoticeMsgType,
+)
 from synapse.api.errors import AuthError, ResourceLimitError, SynapseError
 from synapse.server_notices.server_notices_manager import SERVER_NOTICE_ROOM_TAG
 
@@ -102,11 +106,13 @@ class ResourceLimitsServerNotices(object):
                 # Add block notification
                 content = {
                     'body': event_content,
+                    'msgtype': ServerNoticeMsgType,
+                    'server_notice_type': ServerNoticeLimitReached,
                     'admin_uri': self._config.admin_uri,
                     'limit_type': event_limit_type
                 }
                 event = yield self._server_notices_manager.send_notice(
-                    user_id, content, EventTypes.ServerNoticeLimitReached
+                    user_id, content, EventTypes.Message,
                 )
 
                 content = {
@@ -174,7 +180,9 @@ class ResourceLimitsServerNotices(object):
 
         events = yield self._store.get_events(referenced_events)
         for event_id, event in iteritems(events):
-            if event.type == EventTypes.ServerNoticeLimitReached:
+            if event.type != EventTypes.Message:
+                continue
+            if event.content.get("msgtype") == ServerNoticeMsgType:
                 currently_blocked = True
                 # remove event in case we need to disable blocking later on.
                 if event_id in referenced_events: