Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pleroma
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
feld
pleroma
Commits
78939c1d
Commit
78939c1d
authored
4 years ago
by
lain
Browse files
Options
Downloads
Patches
Plain Diff
ChatController: Don't die if the recipient is gone.
parent
22050f9e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/pleroma/web/pleroma_api/controllers/chat_controller.ex
+3
-1
3 additions, 1 deletion
lib/pleroma/web/pleroma_api/controllers/chat_controller.ex
test/web/pleroma_api/controllers/chat_controller_test.exs
+15
-0
15 additions, 0 deletions
test/web/pleroma_api/controllers/chat_controller_test.exs
with
18 additions
and
1 deletion
lib/pleroma/web/pleroma_api/controllers/chat_controller.ex
+
3
−
1
View file @
78939c1d
...
...
@@ -149,7 +149,9 @@ def index(%{assigns: %{user: %{id: user_id} = user}} = conn, _params) 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
()
...
...
This diff is collapsed.
Click to expand it.
test/web/pleroma_api/controllers/chat_controller_test.exs
+
15
−
0
View file @
78939c1d
...
...
@@ -267,6 +267,21 @@ test "it returns a chat", %{conn: conn, user: user} 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
)
...
...
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