Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
afb646dc
Commit
afb646dc
authored
10 years ago
by
Paul "LeoNerd" Evans
Browse files
Options
Downloads
Patches
Plain Diff
Allow GET /room/:room_id/messages without 'limit' parameter to default to 10
parent
d8b35250
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/rest/room.py
+3
-1
3 additions, 1 deletion
synapse/rest/room.py
synapse/streams/config.py
+5
-1
5 additions, 1 deletion
synapse/streams/config.py
with
8 additions
and
2 deletions
synapse/rest/room.py
+
3
−
1
View file @
afb646dc
...
@@ -327,7 +327,9 @@ class RoomMessageListRestServlet(RestServlet):
...
@@ -327,7 +327,9 @@ class RoomMessageListRestServlet(RestServlet):
@defer.inlineCallbacks
@defer.inlineCallbacks
def
on_GET
(
self
,
request
,
room_id
):
def
on_GET
(
self
,
request
,
room_id
):
user
=
yield
self
.
auth
.
get_user_by_req
(
request
)
user
=
yield
self
.
auth
.
get_user_by_req
(
request
)
pagination_config
=
PaginationConfig
.
from_request
(
request
)
pagination_config
=
PaginationConfig
.
from_request
(
request
,
default_limit
=
10
,
)
with_feedback
=
"
feedback
"
in
request
.
args
with_feedback
=
"
feedback
"
in
request
.
args
handler
=
self
.
handlers
.
message_handler
handler
=
self
.
handlers
.
message_handler
msgs
=
yield
handler
.
get_messages
(
msgs
=
yield
handler
.
get_messages
(
...
...
This diff is collapsed.
Click to expand it.
synapse/streams/config.py
+
5
−
1
View file @
afb646dc
...
@@ -47,7 +47,8 @@ class PaginationConfig(object):
...
@@ -47,7 +47,8 @@ class PaginationConfig(object):
self
.
limit
=
int
(
limit
)
if
limit
is
not
None
else
None
self
.
limit
=
int
(
limit
)
if
limit
is
not
None
else
None
@classmethod
@classmethod
def
from_request
(
cls
,
request
,
raise_invalid_params
=
True
):
def
from_request
(
cls
,
request
,
raise_invalid_params
=
True
,
default_limit
=
None
):
def
get_param
(
name
,
default
=
None
):
def
get_param
(
name
,
default
=
None
):
lst
=
request
.
args
.
get
(
name
,
[])
lst
=
request
.
args
.
get
(
name
,
[])
if
len
(
lst
)
>
1
:
if
len
(
lst
)
>
1
:
...
@@ -84,6 +85,9 @@ class PaginationConfig(object):
...
@@ -84,6 +85,9 @@ class PaginationConfig(object):
if
limit
is
not
None
and
not
limit
.
isdigit
():
if
limit
is
not
None
and
not
limit
.
isdigit
():
raise
SynapseError
(
400
,
"'
limit
'
parameter must be an integer.
"
)
raise
SynapseError
(
400
,
"'
limit
'
parameter must be an integer.
"
)
if
limit
is
None
:
limit
=
default_limit
try
:
try
:
return
PaginationConfig
(
from_tok
,
to_tok
,
direction
,
limit
)
return
PaginationConfig
(
from_tok
,
to_tok
,
direction
,
limit
)
except
:
except
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment