diff --git a/synapse/api/filtering.py b/synapse/api/filtering.py index 583daea906..c8c55bc061 100644 --- a/synapse/api/filtering.py +++ b/synapse/api/filtering.py @@ -12,11 +12,13 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from synapse.api.errors import SynapseError from synapse.storage.presence import UserPresenceState from synapse.types import UserID, RoomID from twisted.internet import defer +import six import ujson as json import jsonschema from jsonschema import FormatChecker @@ -353,10 +355,8 @@ class Filter(object): ev_type = event.get("type", None) content = event.get("content", {}) - is_url = ( - "url" in content - and isinstance(content["url"], basestring) - ) + # check if there is a string url field in the content for filtering purposes + is_url = isinstance(content.get("url"), six.text_type) return self.check_fields( room_id,