Merge branch 'develop' into feld-2168-media-preview-proxy
This commit is contained in:
commit
479578b148
54 changed files with 1095 additions and 254 deletions
|
|
@ -533,7 +533,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
end)
|
||||
|
||||
:ok = Mix.Tasks.Pleroma.Relay.run(["list"])
|
||||
assert_receive {:mix_shell, :info, ["relay.mastodon.host"]}
|
||||
assert_receive {:mix_shell, :info, ["https://relay.mastodon.host/actor"]}
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
|
|
|
|||
|
|
@ -990,13 +990,39 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
end
|
||||
|
||||
describe "uploading files" do
|
||||
test "copies the file to the configured folder" do
|
||||
file = %Plug.Upload{
|
||||
setup do
|
||||
test_file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
||||
%{test_file: test_file}
|
||||
end
|
||||
|
||||
test "sets a description if given", %{test_file: file} do
|
||||
{:ok, %Object{} = object} = ActivityPub.upload(file, description: "a cool file")
|
||||
assert object.data["name"] == "a cool file"
|
||||
end
|
||||
|
||||
test "it sets the default description depending on the configuration", %{test_file: file} do
|
||||
clear_config([Pleroma.Upload, :default_description])
|
||||
|
||||
Pleroma.Config.put([Pleroma.Upload, :default_description], nil)
|
||||
{:ok, %Object{} = object} = ActivityPub.upload(file)
|
||||
assert object.data["name"] == ""
|
||||
|
||||
Pleroma.Config.put([Pleroma.Upload, :default_description], :filename)
|
||||
{:ok, %Object{} = object} = ActivityPub.upload(file)
|
||||
assert object.data["name"] == "an_image.jpg"
|
||||
|
||||
Pleroma.Config.put([Pleroma.Upload, :default_description], "unnamed attachment")
|
||||
{:ok, %Object{} = object} = ActivityPub.upload(file)
|
||||
assert object.data["name"] == "unnamed attachment"
|
||||
end
|
||||
|
||||
test "copies the file to the configured folder", %{test_file: file} do
|
||||
clear_config([Pleroma.Upload, :default_description], :filename)
|
||||
{:ok, %Object{} = object} = ActivityPub.upload(file)
|
||||
assert object.data["name"] == "an_image.jpg"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -42,4 +42,42 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AudioHandlingTest do
|
|||
assert object.data["album"] == "lain radio"
|
||||
assert object.data["length"] == 180_000
|
||||
end
|
||||
|
||||
test "Funkwhale Audio object" do
|
||||
Tesla.Mock.mock(fn
|
||||
%{url: "https://channels.tests.funkwhale.audio/federation/actors/compositions"} ->
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/funkwhale_channel.json")
|
||||
}
|
||||
end)
|
||||
|
||||
data = File.read!("test/fixtures/tesla_mock/funkwhale_create_audio.json") |> Poison.decode!()
|
||||
|
||||
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
assert object = Object.normalize(activity, false)
|
||||
|
||||
assert object.data["to"] == ["https://www.w3.org/ns/activitystreams#Public"]
|
||||
|
||||
assert object.data["cc"] == []
|
||||
|
||||
assert object.data["url"] == "https://channels.tests.funkwhale.audio/library/tracks/74"
|
||||
|
||||
assert object.data["attachment"] == [
|
||||
%{
|
||||
"mediaType" => "audio/ogg",
|
||||
"type" => "Link",
|
||||
"name" => nil,
|
||||
"url" => [
|
||||
%{
|
||||
"href" =>
|
||||
"https://channels.tests.funkwhale.audio/api/v1/listen/3901e5d8-0445-49d5-9711-e096cf32e515/?upload=42342395-0208-4fee-a38d-259a6dae0871&download=false",
|
||||
"mediaType" => "audio/ogg",
|
||||
"type" => "Link"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
40
test/web/activity_pub/transmogrifier/event_handling_test.exs
Normal file
40
test/web/activity_pub/transmogrifier/event_handling_test.exs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.Transmogrifier.EventHandlingTest do
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.Object.Fetcher
|
||||
|
||||
test "Mobilizon Event object" do
|
||||
Tesla.Mock.mock(fn
|
||||
%{url: "https://mobilizon.org/events/252d5816-00a3-4a89-a66f-15bf65c33e39"} ->
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/mobilizon.org-event.json")
|
||||
}
|
||||
|
||||
%{url: "https://mobilizon.org/@tcit"} ->
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/mobilizon.org-user.json")
|
||||
}
|
||||
end)
|
||||
|
||||
assert {:ok, object} =
|
||||
Fetcher.fetch_object_from_id(
|
||||
"https://mobilizon.org/events/252d5816-00a3-4a89-a66f-15bf65c33e39"
|
||||
)
|
||||
|
||||
assert object.data["to"] == ["https://www.w3.org/ns/activitystreams#Public"]
|
||||
assert object.data["cc"] == []
|
||||
|
||||
assert object.data["url"] ==
|
||||
"https://mobilizon.org/events/252d5816-00a3-4a89-a66f-15bf65c33e39"
|
||||
|
||||
assert object.data["published"] == "2019-12-17T11:33:56Z"
|
||||
assert object.data["name"] == "Mobilizon Launching Party"
|
||||
end
|
||||
end
|
||||
|
|
@ -24,6 +24,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.QuestionHandlingTest do
|
|||
|
||||
object = Object.normalize(activity, false)
|
||||
|
||||
assert object.data["url"] == "https://mastodon.sdf.org/@rinpatch/102070944809637304"
|
||||
|
||||
assert object.data["closed"] == "2019-05-11T09:03:36Z"
|
||||
|
||||
assert object.data["context"] == activity.data["context"]
|
||||
|
|
|
|||
|
|
@ -381,7 +381,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
}
|
||||
|
||||
assert expected == json_response(conn, 200)
|
||||
|
|
@ -663,7 +664,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => admin.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
},
|
||||
%{
|
||||
"deactivated" => user.deactivated,
|
||||
|
|
@ -677,7 +679,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
},
|
||||
%{
|
||||
"deactivated" => user2.deactivated,
|
||||
|
|
@ -691,7 +694,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => true,
|
||||
"url" => user2.ap_id,
|
||||
"registration_reason" => "I'm a chill dude"
|
||||
"registration_reason" => "I'm a chill dude",
|
||||
"actor_type" => "Person"
|
||||
}
|
||||
]
|
||||
|> Enum.sort_by(& &1["nickname"])
|
||||
|
|
@ -766,7 +770,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -794,7 +799,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -822,7 +828,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -850,7 +857,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -878,7 +886,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -906,7 +915,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -929,7 +939,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user2.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -964,7 +975,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -992,7 +1004,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
},
|
||||
%{
|
||||
"deactivated" => admin.deactivated,
|
||||
|
|
@ -1006,7 +1019,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => admin.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
},
|
||||
%{
|
||||
"deactivated" => false,
|
||||
|
|
@ -1020,7 +1034,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => old_admin.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
}
|
||||
]
|
||||
|> Enum.sort_by(& &1["nickname"])
|
||||
|
|
@ -1058,7 +1073,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => true,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => "Plz let me in!"
|
||||
"registration_reason" => "Plz let me in!",
|
||||
"actor_type" => "Person"
|
||||
}
|
||||
]
|
||||
|> Enum.sort_by(& &1["nickname"])
|
||||
|
|
@ -1091,7 +1107,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => admin.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
},
|
||||
%{
|
||||
"deactivated" => false,
|
||||
|
|
@ -1105,7 +1122,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => second_admin.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
}
|
||||
]
|
||||
|> Enum.sort_by(& &1["nickname"])
|
||||
|
|
@ -1140,7 +1158,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => moderator.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1168,7 +1187,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user1.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
},
|
||||
%{
|
||||
"deactivated" => false,
|
||||
|
|
@ -1182,7 +1202,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user2.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
}
|
||||
]
|
||||
|> Enum.sort_by(& &1["nickname"])
|
||||
|
|
@ -1245,7 +1266,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1272,7 +1294,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => admin.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1357,7 +1380,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
"registration_reason" => nil,
|
||||
"actor_type" => "Person"
|
||||
}
|
||||
|
||||
log_entry = Repo.one(ModerationLog)
|
||||
|
|
|
|||
|
|
@ -39,8 +39,10 @@ defmodule Pleroma.Web.AdminAPI.RelayControllerTest do
|
|||
relay_url: "http://mastodon.example.org/users/admin"
|
||||
})
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200) ==
|
||||
"http://mastodon.example.org/users/admin"
|
||||
assert json_response_and_validate_schema(conn, 200) == %{
|
||||
"actor" => "http://mastodon.example.org/users/admin",
|
||||
"followed_back" => false
|
||||
}
|
||||
|
||||
log_entry = Repo.one(ModerationLog)
|
||||
|
||||
|
|
@ -59,8 +61,13 @@ defmodule Pleroma.Web.AdminAPI.RelayControllerTest do
|
|||
|
||||
conn = get(conn, "/api/pleroma/admin/relay")
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200)["relays"] --
|
||||
["mastodon.example.org", "mstdn.io"] == []
|
||||
assert json_response_and_validate_schema(conn, 200)["relays"] == [
|
||||
%{
|
||||
"actor" => "http://mastodon.example.org/users/admin",
|
||||
"followed_back" => true
|
||||
},
|
||||
%{"actor" => "https://mstdn.io/users/mayuutann", "followed_back" => true}
|
||||
]
|
||||
end
|
||||
|
||||
test "DELETE /relay", %{conn: conn, admin: admin} do
|
||||
|
|
|
|||
|
|
@ -517,6 +517,12 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
represented = StatusView.render("show.json", %{for: user, activity: activity})
|
||||
|
||||
assert represented[:id] == to_string(activity.id)
|
||||
|
||||
assert represented[:url] ==
|
||||
"https://mobilizon.org/events/252d5816-00a3-4a89-a66f-15bf65c33e39"
|
||||
|
||||
assert represented[:content] ==
|
||||
"<p><a href=\"https://mobilizon.org/events/252d5816-00a3-4a89-a66f-15bf65c33e39\">Mobilizon Launching Party</a></p><p>Mobilizon is now federated! 🎉</p><p></p><p>You can view this event from other instances if they are subscribed to mobilizon.org, and soon directly from Mastodon and Pleroma. It is possible that you may see some comments from other instances, including Mastodon ones, just below.</p><p></p><p>With a Mobilizon account on an instance, you may <strong>participate</strong> at events from other instances and <strong>add comments</strong> on events.</p><p></p><p>Of course, it's still <u>a work in progress</u>: if reports made from an instance on events and comments can be federated, you can't block people right now, and moderators actions are rather limited, but this <strong>will definitely get fixed over time</strong> until first stable version next year.</p><p></p><p>Anyway, if you want to come up with some feedback, head over to our forum or - if you feel you have technical skills and are familiar with it - on our Gitlab repository.</p><p></p><p>Also, to people that want to set Mobilizon themselves even though we really don't advise to do that for now, we have a little documentation but it's quite the early days and you'll probably need some help. No worries, you can chat with us on our Forum or though our Matrix channel.</p><p></p><p>Check our website for more informations and follow us on Twitter or Mastodon.</p>"
|
||||
end
|
||||
|
||||
describe "build_tags/1" do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue