Merge pull request 'Allow fine-grained announce visibilities' (#941) from Oneric/akkoma:announce-visibility into develop
Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/941 Reviewed-by: floatingghost <hannah@coffee-and-dreams.uk> Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
parent
68de463392
commit
b645643cfb
5 changed files with 91 additions and 62 deletions
|
|
@ -86,23 +86,32 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.AnnounceValidationTest do
|
|||
object = Object.normalize(post_activity, fetch: false)
|
||||
|
||||
# Another user can't announce it
|
||||
{:ok, announce, []} = Builder.announce(announcer, object, public: false)
|
||||
{:ok, announce, []} = Builder.announce(announcer, object, visibility: "private")
|
||||
|
||||
{:error, cng} = ObjectValidator.validate(announce, [])
|
||||
|
||||
assert {:actor, {"can not announce this object", []}} in cng.errors
|
||||
|
||||
# The actor of the object can announce it
|
||||
{:ok, announce, []} = Builder.announce(user, object, public: false)
|
||||
# The actor of the object can announce it with a restrictive scope
|
||||
{:ok, announce, []} = Builder.announce(user, object, visibility: "private")
|
||||
assert {:ok, _, _} = ObjectValidator.validate(announce, [])
|
||||
|
||||
{:ok, announce, []} = Builder.announce(user, object, visibility: "direct")
|
||||
assert {:ok, _, _} = ObjectValidator.validate(announce, [])
|
||||
|
||||
# The actor of the object can not announce it publicly
|
||||
{:ok, announce, []} = Builder.announce(user, object, public: true)
|
||||
{:ok, announce, []} = Builder.announce(user, object, visibility: "public")
|
||||
{:error, cng1} = ObjectValidator.validate(announce, [])
|
||||
|
||||
{:error, cng} = ObjectValidator.validate(announce, [])
|
||||
{:ok, announce, []} = Builder.announce(user, object, visibility: "unlisted")
|
||||
{:error, cng2} = ObjectValidator.validate(announce, [])
|
||||
|
||||
assert {:actor, {"can not announce this object publicly", []}} in cng.errors
|
||||
{:ok, announce, []} = Builder.announce(user, object, visibility: "local")
|
||||
{:error, cng3} = ObjectValidator.validate(announce, [])
|
||||
|
||||
for cng <- [cng1, cng2, cng3] do
|
||||
assert {:actor, {"can not announce this object publicly", []}} in cng.errors
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -784,13 +784,15 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
|
|||
{:ok, post} = CommonAPI.post(poster, %{status: "hey"})
|
||||
{:ok, private_post} = CommonAPI.post(poster, %{status: "hey", visibility: "private"})
|
||||
|
||||
{:ok, announce_data, _meta} = Builder.announce(user, post.object, public: true)
|
||||
{:ok, announce_data, _meta} = Builder.announce(user, post.object, visibility: "public")
|
||||
|
||||
{:ok, private_announce_data, _meta} =
|
||||
Builder.announce(user, private_post.object, public: false)
|
||||
Builder.announce(user, private_post.object, visibility: "private")
|
||||
|
||||
{:ok, relay_announce_data, _meta} =
|
||||
Builder.announce(Pleroma.Web.ActivityPub.Relay.get_actor(), post.object, public: true)
|
||||
Builder.announce(Pleroma.Web.ActivityPub.Relay.get_actor(), post.object,
|
||||
visibility: "public"
|
||||
)
|
||||
|
||||
{:ok, announce, _meta} = ActivityPub.persist(announce_data, local: true)
|
||||
{:ok, private_announce, _meta} = ActivityPub.persist(private_announce_data, local: true)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue