Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
89b85f65
Commit
89b85f65
authored
Jun 08, 2020
by
lain
Browse files
ChatController: Remove nonsensical pagination.
parent
7d66dd18
Pipeline
#26930
passed with stages
in 14 minutes and 59 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
docs/API/chats.md
View file @
89b85f65
...
...
@@ -135,7 +135,7 @@ Returned data:
```
The recipient of messages that are sent to this chat is given by their AP ID.
The usual
pagination
options are
implemented.
No
pagination
is
implemented
for now
.
### Getting the messages for a Chat
...
...
lib/pleroma/web/pleroma_api/controllers/chat_controller.ex
View file @
89b85f65
...
...
@@ -140,7 +140,7 @@ def messages(%{assigns: %{user: %{id: user_id} = user}} = conn, %{id: id} = para
end
end
def
index
(%{
assigns:
%{
user:
%{
id:
user_id
}
=
user
}}
=
conn
,
params
)
do
def
index
(%{
assigns:
%{
user:
%{
id:
user_id
}
=
user
}}
=
conn
,
_
params
)
do
blocked_ap_ids
=
User
.
blocked_users_ap_ids
(
user
)
chats
=
...
...
@@ -149,7 +149,7 @@ def index(%{assigns: %{user: %{id: user_id} = user}} = conn, params) do
where:
c
.
recipient
not
in
^
blocked_ap_ids
,
order_by:
[
desc:
c
.
updated_at
]
)
|>
Pagination
.
fetch_paginated
(
params
|>
stringify_keys
)
|>
Repo
.
all
(
)
conn
|>
put_view
(
ChatView
)
...
...
test/web/pleroma_api/controllers/chat_controller_test.exs
View file @
89b85f65
...
...
@@ -289,7 +289,7 @@ test "it does not return chats with users you blocked", %{conn: conn, user: user
assert
length
(
result
)
==
0
end
test
"it
pagin
at
e
s"
,
%{
conn:
conn
,
user:
user
}
do
test
"it
returns all ch
ats"
,
%{
conn:
conn
,
user:
user
}
do
Enum
.
each
(
1
..
30
,
fn
_
->
recipient
=
insert
(
:user
)
{
:ok
,
_
}
=
Chat
.
get_or_create
(
user
.
id
,
recipient
.
ap_id
)
...
...
@@ -300,14 +300,7 @@ test "it paginates", %{conn: conn, user: user} do
|>
get
(
"/api/v1/pleroma/chats"
)
|>
json_response_and_validate_schema
(
200
)
assert
length
(
result
)
==
20
result
=
conn
|>
get
(
"/api/v1/pleroma/chats?max_id=
#{
List
.
last
(
result
)[
"id"
]
}
"
)
|>
json_response_and_validate_schema
(
200
)
assert
length
(
result
)
==
10
assert
length
(
result
)
==
30
end
test
"it return a list of chats the current user is participating in, in descending order of updates"
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment