aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/pleroma/web/activity_pub/utils.ex2
-rw-r--r--lib/pleroma/web/endpoint.ex6
-rw-r--r--priv/static/schemas/litepub-0.1.jsonld23
-rw-r--r--test/fixtures/httpoison_mock/https___prismo.news__mxb.json1
-rw-r--r--test/fixtures/prismo-url-map.json65
-rw-r--r--test/support/httpoison_mock.ex8
-rw-r--r--test/web/activity_pub/transmogrifier_test.exs8
7 files changed, 110 insertions, 3 deletions
diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex
index fac91830a..549148989 100644
--- a/lib/pleroma/web/activity_pub/utils.ex
+++ b/lib/pleroma/web/activity_pub/utils.ex
@@ -72,7 +72,7 @@ defmodule Pleroma.Web.ActivityPub.Utils do
%{
"@context" => [
"https://www.w3.org/ns/activitystreams",
- "https://litepub.github.io/litepub/context.jsonld"
+ "#{Web.base_url()}/schemas/litepub-0.1.jsonld"
]
}
end
diff --git a/lib/pleroma/web/endpoint.ex b/lib/pleroma/web/endpoint.ex
index 6673ab576..cb5de087b 100644
--- a/lib/pleroma/web/endpoint.ex
+++ b/lib/pleroma/web/endpoint.ex
@@ -11,13 +11,16 @@ defmodule Pleroma.Web.Endpoint do
#
# You should set gzip to true if you are running phoenix.digest
# when deploying your static files in production.
+ plug(CORSPlug)
+
plug(Plug.Static, at: "/media", from: Pleroma.Uploaders.Local.upload_path(), gzip: false)
plug(
Plug.Static,
at: "/",
from: :pleroma,
- only: ~w(index.html static finmoji emoji packs sounds images instance sw.js favicon.png)
+ only:
+ ~w(index.html static finmoji emoji packs sounds images instance sw.js favicon.png schemas)
)
# Code reloading can be explicitly enabled under the
@@ -56,7 +59,6 @@ defmodule Pleroma.Web.Endpoint do
extra: "SameSite=Strict"
)
- plug(CORSPlug)
plug(Pleroma.Web.Router)
@doc """
diff --git a/priv/static/schemas/litepub-0.1.jsonld b/priv/static/schemas/litepub-0.1.jsonld
new file mode 100644
index 000000000..819d25c38
--- /dev/null
+++ b/priv/static/schemas/litepub-0.1.jsonld
@@ -0,0 +1,23 @@
+{
+ "@context": [
+ "https://www.w3.org/ns/activitystreams",
+ "https://w3id.org/security/v1",
+ {
+ "Emoji": "toot:Emoji",
+ "Hashtag": "as:Hashtag",
+ "PropertyValue": "schema:PropertyValue",
+ "atomUri": "ostatus:atomUri",
+ "conversation": {
+ "@id": "ostatus:conversation",
+ "@type": "@id"
+ },
+ "manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
+ "ostatus": "http://ostatus.org#",
+ "schema": "http://schema.org",
+ "toot": "http://joinmastodon.org/ns#",
+ "totalItems": "as:totalItems",
+ "value": "schema:value",
+ "sensitive": "as:sensitive"
+ }
+ ]
+}
diff --git a/test/fixtures/httpoison_mock/https___prismo.news__mxb.json b/test/fixtures/httpoison_mock/https___prismo.news__mxb.json
new file mode 100644
index 000000000..a2fe53117
--- /dev/null
+++ b/test/fixtures/httpoison_mock/https___prismo.news__mxb.json
@@ -0,0 +1 @@
+{"id":"https://prismo.news/@mxb","type":"Person","name":"mxb","preferredUsername":"mxb","summary":"Creator of △ Prismo\r\n\r\nFollow me at @mb@mstdn.io","inbox":"https://prismo.news/ap/accounts/mxb/inbox","outbox":"https://prismo.news/ap/accounts/mxb/outbox","url":"https://prismo.news/@mxb","publicKey":{"id":"https://prismo.news/@mxb#main-key","owner":"https://prismo.news/@mxb","publicKeyPem":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA41gqLkBYuPLurC2TarF8\nbdyvqP54XzKyScJ6iPNkk4D4plYdWUVj0aOIHQ8LVfBeziH83jDMpRegm1sRLpNG\n1Ti+SzlWyTwugJ8wfQvwJL7iEzqhuPFddjPLpv0djMptvm5vtG6u6O3g4RpX12bv\n4pYRoMStPSv9KRKD/8Naw5Nv85PIWRc9rOly/EoVZBnbesroo69caiGthgChE2pa\niisQ5CEgj/615WUlUATkz3VdExKQkQOdeVABheIvcS5OsMurXnpWyLQ4n9WalNvF\nlJc08aOTIo4plsLAvdcGRDsBzio4qPok3jgzPpFkDqe+02WG/QMPT9VrzKO49N5R\nqQIDAQAB\n-----END PUBLIC KEY-----\n"},"icon":{"type":"Image","url":"https://prismo.s3.wasabisys.com/account/1/avatar/size_400-b6e570850878684362ba3b4bd9ceb007.jpg","media_type":null},"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"Hashtag":"as:Hashtag"},{"votes":{"@id":"as:votes","@type":"@id"}}]} \ No newline at end of file
diff --git a/test/fixtures/prismo-url-map.json b/test/fixtures/prismo-url-map.json
new file mode 100644
index 000000000..4e2e2fd4a
--- /dev/null
+++ b/test/fixtures/prismo-url-map.json
@@ -0,0 +1,65 @@
+{
+ "id": "https://prismo.news/posts/83#Create",
+ "type": "Create",
+ "actor": [
+ {
+ "type": "Person",
+ "id": "https://prismo.news/@mxb"
+ }
+ ],
+ "to": [
+ "https://www.w3.org/ns/activitystreams#Public"
+ ],
+ "object": {
+ "id": "https://prismo.news/posts/83",
+ "type": "Article",
+ "name": "Introducing: Federated follows!",
+ "published": "2018-11-01T07:10:05Z",
+ "content": "We are more than thrilled to announce that Prismo now supports federated follows! It means you ca...",
+ "url": {
+ "type": "Link",
+ "mimeType": "text/html",
+ "href": "https://prismo.news/posts/83"
+ },
+ "votes": 12,
+ "attributedTo": [
+ {
+ "type": "Person",
+ "id": "https://prismo.news/@mxb"
+ }
+ ],
+ "to": [
+ "https://www.w3.org/ns/activitystreams#Public"
+ ],
+ "tags": [
+ {
+ "type": "Hashtag",
+ "href": "https://prismo.news/tags/prismo",
+ "name": "#prismo"
+ },
+ {
+ "type": "Hashtag",
+ "href": "https://prismo.news/tags/prismodev",
+ "name": "#prismodev"
+ },
+ {
+ "type": "Hashtag",
+ "href": "https://prismo.news/tags/meta",
+ "name": "#meta"
+ }
+ ],
+ "@context": [
+ "https://www.w3.org/ns/activitystreams",
+ "https://w3id.org/security/v1",
+ {
+ "Hashtag": "as:Hashtag"
+ },
+ {
+ "votes": {
+ "@id": "as:votes",
+ "@type": "@id"
+ }
+ }
+ ]
+ }
+}
diff --git a/test/support/httpoison_mock.ex b/test/support/httpoison_mock.ex
index 75c78d70e..ab964334d 100644
--- a/test/support/httpoison_mock.ex
+++ b/test/support/httpoison_mock.ex
@@ -3,6 +3,14 @@ defmodule HTTPoisonMock do
def get(url, body \\ [], headers \\ [])
+ def get("https://prismo.news/@mxb", _, _) do
+ {:ok,
+ %Response{
+ status_code: 200,
+ body: File.read!("test/fixtures/httpoison_mock/https___prismo.news__mxb.json")
+ }}
+ end
+
def get("https://osada.macgirvin.com/channel/mike", _, _) do
{:ok,
%Response{
diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs
index 07ff1deeb..6e4820dbc 100644
--- a/test/web/activity_pub/transmogrifier_test.exs
+++ b/test/web/activity_pub/transmogrifier_test.exs
@@ -145,6 +145,14 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
assert "test" in data["object"]["tag"]
end
+ test "it works for incoming notices with url not being a string (prismo)" do
+ data = File.read!("test/fixtures/prismo-url-map.json") |> Poison.decode!()
+
+ {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
+
+ assert data["object"]["url"] == "https://prismo.news/posts/83"
+ end
+
test "it works for incoming follow requests" do
user = insert(:user)