1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.Transmogrifier.ArticleHandlingTest do
6 use Oban.Testing, repo: Pleroma.Repo
11 alias Pleroma.Object.Fetcher
12 alias Pleroma.Web.ActivityPub.Transmogrifier
14 test "Pterotype (Wordpress Plugin) Article" do
15 Tesla.Mock.mock(fn %{url: "https://wedistribute.org/wp-json/pterotype/v1/actor/-blog"} ->
18 body: File.read!("test/fixtures/tesla_mock/wedistribute-user.json"),
19 headers: HttpRequestMock.activitypub_object_headers()
24 File.read!("test/fixtures/tesla_mock/wedistribute-create-article.json") |> Jason.decode!()
26 {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
28 object = Object.normalize(data["object"], fetch: false)
30 assert object.data["name"] == "The end is near: Mastodon plans to drop OStatus support"
32 assert object.data["summary"] ==
33 "One of the largest platforms in the federated social web is dropping the protocol that it started with."
35 assert object.data["url"] == "https://wedistribute.org/2019/07/mastodon-drops-ostatus/"
38 test "Plume Article" do
40 %{url: "https://baptiste.gelez.xyz/~/PlumeDevelopment/this-month-in-plume-june-2018/"} ->
43 body: File.read!("test/fixtures/tesla_mock/baptiste.gelex.xyz-article.json"),
44 headers: HttpRequestMock.activitypub_object_headers()
47 %{url: "https://baptiste.gelez.xyz/@/BaptisteGelez"} ->
50 body: File.read!("test/fixtures/tesla_mock/baptiste.gelex.xyz-user.json"),
51 headers: HttpRequestMock.activitypub_object_headers()
56 Fetcher.fetch_object_from_id(
57 "https://baptiste.gelez.xyz/~/PlumeDevelopment/this-month-in-plume-june-2018/"
60 assert object.data["name"] == "This Month in Plume: June 2018"
62 assert object.data["url"] ==
63 "https://baptiste.gelez.xyz/~/PlumeDevelopment/this-month-in-plume-june-2018/"
66 test "Prismo Article" do
67 Tesla.Mock.mock(fn %{url: "https://prismo.news/@mxb"} ->
70 body: File.read!("test/fixtures/tesla_mock/https___prismo.news__mxb.json"),
71 headers: HttpRequestMock.activitypub_object_headers()
75 data = File.read!("test/fixtures/prismo-url-map.json") |> Jason.decode!()
77 {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
78 object = Object.normalize(data["object"], fetch: false)
80 assert object.data["url"] == "https://prismo.news/posts/83"