Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2577456
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
11 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/test/fixtures/tesla_mock/mobilizon-event-join-accept.json b/test/fixtures/tesla_mock/mobilizon-event-join-accept.json
new file mode 100644
index 000000000..be4437741
--- /dev/null
+++ b/test/fixtures/tesla_mock/mobilizon-event-join-accept.json
@@ -0,0 +1,80 @@
+%{
+ "@context" => [
+ "https://www.w3.org/ns/activitystreams",
+ "https://w3id.org/security/v1",
+ %{
+ "addressRegion" => "sc:addressRegion",
+ "timezone" => %{"@id" => "mz:timezone", "@type" => "sc:Text"},
+ "isOnline" => %{"@id" => "mz:isOnline", "@type" => "sc:Boolean"},
+ "pt" => "https://joinpeertube.org/ns#",
+ "manuallyApprovesFollowers" => "as:manuallyApprovesFollowers",
+ "inLanguage" => "sc:inLanguage",
+ "address" => %{"@id" => "sc:address", "@type" => "sc:PostalAddress"},
+ "discoverable" => "toot:discoverable",
+ "repliesModerationOption" => %{
+ "@id" => "mz:repliesModerationOption",
+ "@type" => "mz:repliesModerationOptionType"
+ },
+ "sc" => "http://schema.org#",
+ "mz" => "https://joinmobilizon.org/ns#",
+ "category" => "sc:category",
+ "joinModeType" => %{"@id" => "mz:joinModeType", "@type" => "rdfs:Class"},
+ "Hashtag" => "as:Hashtag",
+ "propertyID" => "sc:propertyID",
+ "PostalAddress" => "sc:PostalAddress",
+ "discussions" => %{"@id" => "mz:discussions", "@type" => "@id"},
+ "remainingAttendeeCapacity" => "sc:remainingAttendeeCapacity",
+ "streetAddress" => "sc:streetAddress",
+ "anonymousParticipationEnabled" => %{
+ "@id" => "mz:anonymousParticipationEnabled",
+ "@type" => "sc:Boolean"
+ },
+ "addressLocality" => "sc:addressLocality",
+ "joinMode" => %{"@id" => "mz:joinMode", "@type" => "mz:joinModeType"},
+ "location" => %{"@id" => "sc:location", "@type" => "sc:Place"},
+ "toot" => "http://joinmastodon.org/ns#",
+ "participantCount" => %{
+ "@id" => "mz:participantCount",
+ "@type" => "sc:Integer"
+ },
+ "uuid" => "sc:identifier",
+ "maximumAttendeeCapacity" => "sc:maximumAttendeeCapacity",
+ "participationMessage" => %{
+ "@id" => "mz:participationMessage",
+ "@type" => "sc:Text"
+ },
+ "openness" => %{"@id" => "mz:openness", "@type" => "@id"},
+ "members" => %{"@id" => "mz:members", "@type" => "@id"},
+ "events" => %{"@id" => "mz:events", "@type" => "@id"},
+ "resources" => %{"@id" => "mz:resources", "@type" => "@id"},
+ "addressCountry" => "sc:addressCountry",
+ "posts" => %{"@id" => "mz:posts", "@type" => "@id"},
+ "commentsEnabled" => %{
+ "@id" => "pt:commentsEnabled",
+ "@type" => "sc:Boolean"
+ },
+ "value" => "sc:value",
+ "PropertyValue" => "sc:PropertyValue",
+ "repliesModerationOptionType" => %{
+ "@id" => "mz:repliesModerationOptionType",
+ "@type" => "rdfs:Class"
+ },
+ "todos" => %{"@id" => "mz:todos", "@type" => "@id"},
+ "ical" => "http://www.w3.org/2002/12/cal/ical#",
+ "postalCode" => "sc:postalCode",
+ "memberCount" => %{"@id" => "mz:memberCount", "@type" => "sc:Integer"},
+ "@language" => "und"
+ }
+ ],
+ "actor" => "https://mobilizon.org/@tcit",
+ "id" => "https://mobilizon.mkljczk.pl/accept/join/fef2a925-cce5-4b8e-b12f-20afe01e5a0f",
+ "object" => %{
+ "actor" => "https://pleroma.mkljczk.pl/users/mkljczk",
+ "id" => "https://pleroma.mkljczk.pl/activities/7d1f3986-8b2c-48c2-b89e-d27ba8459777",
+ "object" => "https://mobilizon.mkljczk.pl/events/d9d08e46-81af-4ee9-91e5-1298f49beea9",
+ "participationMessage" => nil,
+ "published" => "2022-10-07T18:53:53Z",
+ "type" => "Join"
+ },
+ "type" => "Accept"
+}
\ No newline at end of file
diff --git a/test/fixtures/tesla_mock/mobilizon-event-join.json b/test/fixtures/tesla_mock/mobilizon-event-join.json
new file mode 100644
index 000000000..d04100d94
--- /dev/null
+++ b/test/fixtures/tesla_mock/mobilizon-event-join.json
@@ -0,0 +1,74 @@
+{
+ "@context": [
+ "https://www.w3.org/ns/activitystreams",
+ "https://w3id.org/security/v1",
+ {
+ "addressRegion": "sc:addressRegion",
+ "timezone": { "@id": "mz:timezone", "@type": "sc:Text" },
+ "isOnline": { "@id": "mz:isOnline", "@type": "sc:Boolean" },
+ "pt": "https://joinpeertube.org/ns#",
+ "manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
+ "inLanguage": "sc:inLanguage",
+ "address": { "@id": "sc:address", "@type": "sc:PostalAddress" },
+ "discoverable": "toot:discoverable",
+ "repliesModerationOption": {
+ "@id": "mz:repliesModerationOption",
+ "@type": "mz:repliesModerationOptionType"
+ },
+ "sc": "http://schema.org#",
+ "mz": "https://joinmobilizon.org/ns#",
+ "category": "sc:category",
+ "joinModeType": { "@id": "mz:joinModeType", "@type": "rdfs:Class" },
+ "Hashtag": "as:Hashtag",
+ "propertyID": "sc:propertyID",
+ "PostalAddress": "sc:PostalAddress",
+ "discussions": { "@id": "mz:discussions", "@type": "@id" },
+ "remainingAttendeeCapacity": "sc:remainingAttendeeCapacity",
+ "streetAddress": "sc:streetAddress",
+ "anonymousParticipationEnabled": {
+ "@id": "mz:anonymousParticipationEnabled",
+ "@type": "sc:Boolean"
+ },
+ "addressLocality": "sc:addressLocality",
+ "joinMode": { "@id": "mz:joinMode", "@type": "mz:joinModeType" },
+ "location": { "@id": "sc:location", "@type": "sc:Place" },
+ "toot": "http://joinmastodon.org/ns#",
+ "participantCount": {
+ "@id": "mz:participantCount",
+ "@type": "sc:Integer"
+ },
+ "uuid": "sc:identifier",
+ "maximumAttendeeCapacity": "sc:maximumAttendeeCapacity",
+ "participationMessage": {
+ "@id": "mz:participationMessage",
+ "@type": "sc:Text"
+ },
+ "openness": { "@id": "mz:openness", "@type": "@id" },
+ "members": { "@id": "mz:members", "@type": "@id" },
+ "events": { "@id": "mz:events", "@type": "@id" },
+ "resources": { "@id": "mz:resources", "@type": "@id" },
+ "addressCountry": "sc:addressCountry",
+ "posts": { "@id": "mz:posts", "@type": "@id" },
+ "commentsEnabled": {
+ "@id": "pt:commentsEnabled",
+ "@type": "sc:Boolean"
+ },
+ "value": "sc:value",
+ "PropertyValue": "sc:PropertyValue",
+ "repliesModerationOptionType": {
+ "@id": "mz:repliesModerationOptionType",
+ "@type": "rdfs:Class"
+ },
+ "todos": { "@id": "mz:todos", "@type": "@id" },
+ "ical": "http://www.w3.org/2002/12/cal/ical#",
+ "postalCode": "sc:postalCode",
+ "memberCount": { "@id": "mz:memberCount", "@type": "sc:Integer" },
+ "@language": "und"
+ }
+ ],
+ "actor": "https://mobilizon.org/@tcit",
+ "id": "https://mobilizon.mkljczk.pl/join/event/d1828aac-b57f-43c9-ac87-17388fab2bc8",
+ "object": "https://pleroma.mkljczk.pl/objects/b800bdb9-2cbb-40b6-9b29-196cfbd42398",
+ "participationMessage": null,
+ "type": "Join"
+}
diff --git a/test/pleroma/web/activity_pub/transmogrifier/event_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/event_handling_test.exs
index 560e6e474..4093e1ed3 100644
--- a/test/pleroma/web/activity_pub/transmogrifier/event_handling_test.exs
+++ b/test/pleroma/web/activity_pub/transmogrifier/event_handling_test.exs
@@ -1,45 +1,44 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 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"),
headers: HttpRequestMock.activitypub_object_headers()
}
%{url: "https://mobilizon.org/@tcit"} ->
%Tesla.Env{
status: 200,
body: File.read!("test/fixtures/tesla_mock/mobilizon.org-user.json"),
headers: HttpRequestMock.activitypub_object_headers()
}
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"] == ["https://mobilizon.org/@tcit/followers"]
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"
assert object.data["startTime"] == "2019-12-18T13:00:00Z"
assert object.data["endTime"] == "2019-12-18T14:00:00Z"
-
end
end
diff --git a/test/pleroma/web/activity_pub/transmogrifier/join_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/join_handling_test.exs
new file mode 100644
index 000000000..0d03144c9
--- /dev/null
+++ b/test/pleroma/web/activity_pub/transmogrifier/join_handling_test.exs
@@ -0,0 +1,80 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.ActivityPub.Transmogrifier.JoinHandlingTest do
+ use Pleroma.DataCase
+ alias Pleroma.Activity
+ alias Pleroma.Notification
+ alias Pleroma.Object
+ alias Pleroma.Repo
+ alias Pleroma.User
+ alias Pleroma.Web.ActivityPub.Transmogrifier
+ alias Pleroma.Web.ActivityPub.Utils
+
+ import Pleroma.Factory
+ import Ecto.Query
+ import Mock
+
+ setup_all do
+ Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
+ :ok
+ end
+
+ describe "handle_incoming" do
+ test "it works for incoming Mobilizon joins" do
+ user = insert(:user)
+
+ event = insert(:event)
+
+ join_data =
+ File.read!("test/fixtures/tesla_mock/mobilizon-event-join.json")
+ |> Jason.decode!()
+ |> Map.put("actor", user.ap_id)
+ |> Map.put("object", event.data["id"])
+
+ {:ok, %Activity{data: data, local: false} = activity} =
+ Transmogrifier.handle_incoming(join_data)
+
+ event = Object.get_by_id(event.id)
+
+ assert event.data["participations"] == [join_data["actor"]]
+
+ activity = Repo.get(Activity, activity.id)
+ assert activity.data["state"] == "accept"
+ end
+
+ test "with restricted events, it does create a Join, but not an Accept" do
+ user = insert(:user)
+
+ event = insert(:event, %{data: %{"joinMode" => "restricted"}})
+
+ join_data =
+ File.read!("test/fixtures/tesla_mock/mobilizon-event-join.json")
+ |> Jason.decode!()
+ |> Map.put("actor", user.ap_id)
+ |> Map.put("object", event.data["id"])
+
+ {:ok, %Activity{data: data, local: false} = activity} =
+ Transmogrifier.handle_incoming(join_data)
+
+ event = Object.get_by_id(event.id)
+
+ assert event.data["participations"] == nil
+
+ assert data["state"] == "pending"
+
+ accepts =
+ from(
+ a in Activity,
+ where: fragment("?->>'type' = ?", a.data, "Accept")
+ )
+ |> Repo.all()
+
+ assert Enum.empty?(accepts)
+
+ [notification] = Notification.for_user(user)
+ assert notification.type == "pleroma:participation_request"
+ end
+ end
+end
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Jun 24, 7:44 AM (1 d, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
234759
Default Alt Text
(11 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment