Refactor media upload
Use Upload Media logic from Pleroma Backend changes for picture upload Move AS <-> Model conversion to separate module Front changes Downgrade apollo-client: https://github.com/Akryum/vue-apollo/issues/577 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -72,15 +72,15 @@ defmodule Mobilizon.Service.ActivityPub.ActivityPubTest do
|
||||
|
||||
describe "fetching an" do
|
||||
test "object by url" do
|
||||
use_cassette "activity_pub/fetch_social_tcit_fr_status" do
|
||||
use_cassette "activity_pub/fetch_framapiaf_framasoft_status" do
|
||||
{:ok, object} =
|
||||
ActivityPub.fetch_object_from_url(
|
||||
"https://social.tcit.fr/users/tcit/statuses/99908779444618462"
|
||||
"https://framapiaf.org/users/Framasoft/statuses/102093631881522097"
|
||||
)
|
||||
|
||||
{:ok, object_again} =
|
||||
ActivityPub.fetch_object_from_url(
|
||||
"https://social.tcit.fr/users/tcit/statuses/99908779444618462"
|
||||
"https://framapiaf.org/users/Framasoft/statuses/102093631881522097"
|
||||
)
|
||||
|
||||
assert object.id == object_again.id
|
||||
@@ -88,14 +88,12 @@ defmodule Mobilizon.Service.ActivityPub.ActivityPubTest do
|
||||
end
|
||||
|
||||
test "object reply by url" do
|
||||
use_cassette "activity_pub/fetch_social_tcit_fr_reply" do
|
||||
use_cassette "activity_pub/fetch_framasoft_framapiaf_reply" do
|
||||
{:ok, object} =
|
||||
ActivityPub.fetch_object_from_url(
|
||||
"https://social.tcit.fr/users/tcit/statuses/101160654038714030"
|
||||
)
|
||||
ActivityPub.fetch_object_from_url("https://mamot.fr/@imacrea/102094441327423790")
|
||||
|
||||
assert object.in_reply_to_comment.url ==
|
||||
"https://social.tcit.fr/users/tcit/statuses/101160195754333819"
|
||||
"https://framapiaf.org/users/Framasoft/statuses/102093632302210150"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -103,7 +101,7 @@ defmodule Mobilizon.Service.ActivityPub.ActivityPubTest do
|
||||
use_cassette "activity_pub/fetch_reply_to_framatube" do
|
||||
{:ok, object} =
|
||||
ActivityPub.fetch_object_from_url(
|
||||
"https://framapiaf.org/@troisiemelobe/101156292125317651"
|
||||
"https://diaspodon.fr/users/dada/statuses/100820008426311925"
|
||||
)
|
||||
|
||||
assert object.in_reply_to_comment == nil
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
defmodule Mobilizon.Service.ActivityPub.Converters.ActorTest do
|
||||
use Mobilizon.DataCase
|
||||
alias Mobilizon.Service.ActivityPub.Converters.Actor, as: ActorConverter
|
||||
alias Mobilizon.Actors.Actor
|
||||
|
||||
describe "actor to AS" do
|
||||
test "valid actor to as" do
|
||||
data = ActorConverter.model_to_as(%Actor{type: :Person, preferred_username: "test_account"})
|
||||
assert is_map(data)
|
||||
assert data["type"] == "Person"
|
||||
assert data["preferred_username"] == "test_account"
|
||||
end
|
||||
end
|
||||
|
||||
describe "AS to Actor" do
|
||||
test "valid as data to model" do
|
||||
actor =
|
||||
ActorConverter.as_to_model_data(%{
|
||||
"type" => "Person",
|
||||
"preferred_username" => "test_account"
|
||||
})
|
||||
|
||||
assert actor["type"] == :Person
|
||||
assert actor["preferred_username"] == "test_account"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -307,12 +307,6 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
{:ok, %Actor{} = actor} = Actors.get_actor_by_url(data["actor"])
|
||||
assert actor.name == "gargle"
|
||||
|
||||
assert actor.avatar_url ==
|
||||
"https://cd.niu.moe/accounts/avatars/000/033/323/original/fd7f8ae0b3ffedc9.jpeg"
|
||||
|
||||
assert actor.banner_url ==
|
||||
"https://cd.niu.moe/accounts/headers/000/033/323/original/850b3448fa5fd477.png"
|
||||
|
||||
assert actor.summary == "<p>Some bio</p>"
|
||||
end
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ defmodule Mobilizon.Service.ActivityPub.UtilsTest do
|
||||
"id" => Routes.page_url(Endpoint, :comment, reply.uuid),
|
||||
"inReplyTo" => comment.url,
|
||||
"attributedTo" => reply.actor.url
|
||||
} == Utils.make_comment_data(reply)
|
||||
} == Mobilizon.Service.ActivityPub.Converters.Comment.model_to_as(reply)
|
||||
end
|
||||
|
||||
test "comment data from map" do
|
||||
|
||||
Reference in New Issue
Block a user