Lint
This commit is contained in:
parent
5b302d8b76
commit
7379f1417b
4 changed files with 36 additions and 13 deletions
|
@ -27,16 +27,20 @@ def import_object(
|
|||
|> strip_recipients(opts)
|
||||
|
||||
create_data =
|
||||
Utils.make_create_data(%{
|
||||
actor: user,
|
||||
published: published,
|
||||
object: fixed_object,
|
||||
to: [],
|
||||
context: context
|
||||
}, %{})
|
||||
Utils.make_create_data(
|
||||
%{
|
||||
actor: user,
|
||||
published: published,
|
||||
object: fixed_object,
|
||||
to: [],
|
||||
context: context
|
||||
},
|
||||
%{}
|
||||
)
|
||||
|> Utils.lazy_put_activity_defaults()
|
||||
|
||||
with {:ok, activity, _meta} <- Pipeline.common_pipeline(create_data, local: true, importing: true) do
|
||||
with {:ok, activity, _meta} <-
|
||||
Pipeline.common_pipeline(create_data, local: true, importing: true) do
|
||||
# This is to meant to be executed in the oban queue, we only care if it succeeds,
|
||||
# so don't query for and put in the object here.
|
||||
{:ok, activity}
|
||||
|
@ -69,6 +73,7 @@ defp rewrite_actor(object, user) do
|
|||
defp strip_recipients(object, opts) do
|
||||
keep_unlisted = opts[:keep_unlisted] || false
|
||||
orig_is_public = Visibility.is_public?(object) and not Visibility.is_local_public?(object)
|
||||
|
||||
unlisted_ccs =
|
||||
if keep_unlisted and orig_is_public do
|
||||
[Pleroma.Constants.as_public()]
|
||||
|
|
|
@ -43,7 +43,10 @@ def fix_object_defaults(data, meta) do
|
|||
|> cast_and_filter_recipients("cc", follower_collection)
|
||||
|> cast_and_filter_recipients("bto", follower_collection)
|
||||
|> cast_and_filter_recipients("bcc", follower_collection)
|
||||
|> dont_apply_when_importing(& Transmogrifier.fix_implicit_addressing(&1, follower_collection), meta)
|
||||
|> dont_apply_when_importing(
|
||||
&Transmogrifier.fix_implicit_addressing(&1, follower_collection),
|
||||
meta
|
||||
)
|
||||
end
|
||||
|
||||
def fix_activity_addressing(activity, meta \\ []) do
|
||||
|
@ -54,7 +57,10 @@ def fix_activity_addressing(activity, meta \\ []) do
|
|||
|> cast_and_filter_recipients("cc", follower_collection)
|
||||
|> cast_and_filter_recipients("bto", follower_collection)
|
||||
|> cast_and_filter_recipients("bcc", follower_collection)
|
||||
|> dont_apply_when_importing(& Transmogrifier.fix_implicit_addressing(&1, follower_collection), meta)
|
||||
|> dont_apply_when_importing(
|
||||
&Transmogrifier.fix_implicit_addressing(&1, follower_collection),
|
||||
meta
|
||||
)
|
||||
end
|
||||
|
||||
def fix_actor(data) do
|
||||
|
|
|
@ -67,7 +67,10 @@ defp fix_addressing(data, object, meta) do
|
|||
|> CommonFixes.cast_and_filter_recipients("cc", follower_collection, object["cc"])
|
||||
|> CommonFixes.cast_and_filter_recipients("bto", follower_collection, object["bto"])
|
||||
|> CommonFixes.cast_and_filter_recipients("bcc", follower_collection, object["bcc"])
|
||||
|> CommonFixes.dont_apply_when_importing(& Transmogrifier.fix_implicit_addressing(&1, follower_collection), meta)
|
||||
|> CommonFixes.dont_apply_when_importing(
|
||||
&Transmogrifier.fix_implicit_addressing(&1, follower_collection),
|
||||
meta
|
||||
)
|
||||
end
|
||||
|
||||
def fix(data, meta) do
|
||||
|
|
|
@ -53,7 +53,13 @@ test "it keeps inReplyTo and context" do
|
|||
user = insert(:user)
|
||||
user2 = insert(:user)
|
||||
{:ok, replied_to_activity} = CommonAPI.post(user2, %{status: "mew"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "mew @#{user2.nickname}", in_reply_to_id: replied_to_activity})
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
status: "mew @#{user2.nickname}",
|
||||
in_reply_to_id: replied_to_activity
|
||||
})
|
||||
|
||||
assert user2.ap_id in activity.recipients
|
||||
|
||||
{:ok, activity_for_import} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
|
@ -76,7 +82,10 @@ test "it keeps public and unlisted posts unlisted with keep_unlisted option" do
|
|||
{:ok, activity_for_import} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
|
||||
importing_user = insert(:user)
|
||||
assert {:ok, imported_activity} = Importer.import_one(activity_for_import, importing_user, keep_unlisted: true)
|
||||
|
||||
assert {:ok, imported_activity} =
|
||||
Importer.import_one(activity_for_import, importing_user, keep_unlisted: true)
|
||||
|
||||
imported_activity = Activity.normalize(imported_activity)
|
||||
|
||||
if yn do
|
||||
|
|
Loading…
Reference in a new issue