CommonAPI: Prevent users from accessing media of other users

This commit is contained in:
Mint 2023-09-02 01:43:25 +03:00 committed by Haelwenn (lanodan) Monnier
commit 1afde067b1
9 changed files with 82 additions and 31 deletions

View file

@ -279,6 +279,24 @@ defmodule Pleroma.Web.CommonAPITest do
assert {:reject, "[KeywordPolicy] Matches with rejected keyword"} ==
CommonAPI.post_chat_message(author, recipient, "GNO/Linux")
end
test "it reject messages with attachments not belonging to user" do
author = insert(:user)
not_author = insert(:user)
recipient = author
attachment = insert(:attachment, %{user: not_author})
{:error, message} =
CommonAPI.post_chat_message(
author,
recipient,
"123",
media_id: attachment.id
)
assert message == :forbidden
end
end
describe "unblocking" do