Don't allow remote comments to be inserted if parent event doesn't allow it
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -8,6 +8,7 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier.CommentsTest do
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Discussions
|
||||
alias Mobilizon.Discussions.Comment
|
||||
alias Mobilizon.Events.Event
|
||||
alias Mobilizon.Federation.ActivityPub.{Activity, Transmogrifier}
|
||||
alias Mobilizon.Federation.ActivityStream.Convertible
|
||||
alias Mobilizon.Service.HTTP.ActivityPub.Mock
|
||||
@@ -73,6 +74,24 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier.CommentsTest do
|
||||
assert returned_activity.data["object"]["inReplyTo"] == origin_comment.url
|
||||
end
|
||||
|
||||
test "it doesn't saves replies to an event if the event doesn't accept comments" do
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-post-activity.json")
|
||||
|> Jason.decode!()
|
||||
|
||||
%Event{url: reply_to_url} = insert(:event, options: %{comment_moderation: :closed})
|
||||
|
||||
object =
|
||||
data["object"]
|
||||
|> Map.put("inReplyTo", reply_to_url)
|
||||
|
||||
data =
|
||||
data
|
||||
|> Map.put("object", object)
|
||||
|
||||
:error = Transmogrifier.handle_incoming(data)
|
||||
end
|
||||
|
||||
@url_404 "https://404.site/whatever"
|
||||
test "it does not crash if the object in inReplyTo can't be fetched" do
|
||||
data =
|
||||
|
||||
Reference in New Issue
Block a user