Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
feld
pleroma
Commits
78939c1d
Commit
78939c1d
authored
Aug 27, 2020
by
lain
Browse files
ChatController: Don't die if the recipient is gone.
parent
22050f9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/pleroma_api/controllers/chat_controller.ex
View file @
78939c1d
...
...
@@ -149,7 +149,9 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do
from
(
c
in
Chat
,
where:
c
.
user_id
==
^
user_id
,
where:
c
.
recipient
not
in
^
blocked_ap_ids
,
order_by:
[
desc:
c
.
updated_at
]
order_by:
[
desc:
c
.
updated_at
],
inner_join:
u
in
User
,
on:
u
.
ap_id
==
c
.
recipient
)
|>
Repo
.
all
()
...
...
test/web/pleroma_api/controllers/chat_controller_test.exs
View file @
78939c1d
...
...
@@ -267,6 +267,21 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
describe
"GET /api/v1/pleroma/chats"
do
setup
do
:
oauth_access
([
"read:chats"
])
test
"it does not return chats with deleted users"
,
%{
conn:
conn
,
user:
user
}
do
recipient
=
insert
(
:user
)
{
:ok
,
_
}
=
Chat
.
get_or_create
(
user
.
id
,
recipient
.
ap_id
)
Pleroma
.
Repo
.
delete
(
recipient
)
User
.
invalidate_cache
(
recipient
)
result
=
conn
|>
get
(
"/api/v1/pleroma/chats"
)
|>
json_response_and_validate_schema
(
200
)
assert
length
(
result
)
==
0
end
test
"it does not return chats with users you blocked"
,
%{
conn:
conn
,
user:
user
}
do
recipient
=
insert
(
:user
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment