Fixed syntax nits

This commit is contained in:
Pablo Saavedra 2017-05-15 16:21:02 +02:00
parent 627e6ea2b0
commit 224137fcf9
2 changed files with 6 additions and 5 deletions

View file

@ -52,9 +52,8 @@ def client_v2_patterns(path_regex, releases=(0,),
def set_timeline_upper_limit(filter_json, filter_timeline_limit):
if filter_timeline_limit < 0:
return # no upper limits
if 'room' in filter_json \
and 'timeline' in filter_json['room'] \
and 'limit' in filter_json['room']['timeline']:
timeline = filter_json.get('room', {}).get('timeline', {})
if 'limit' in timeline:
filter_json['room']['timeline']["limit"] = min(
filter_json['room']['timeline']['limit'],
filter_timeline_limit)

View file

@ -86,8 +86,10 @@ class CreateFilterRestServlet(RestServlet):
raise AuthError(403, "Can only create filters for local users")
content = parse_json_object_from_request(request)
set_timeline_upper_limit(content,
self.hs.config.filter_timeline_limit)
set_timeline_upper_limit(
content,
self.hs.config.filter_timeline_limit
)
filter_id = yield self.filtering.add_user_filter(
user_localpart=target_user.localpart,