From 1a9fd27304e1c37918c9569ea27c91c147614b65 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 27 Dec 2018 11:24:04 +0100 Subject: [PATCH] Add links to upstream Pleroma files (rename AP tests module names too) Signed-off-by: Thomas Citharel --- .../controllers/activity_pub_controller.ex | 5 + .../controllers/node_info_controller.ex | 5 + .../controllers/web_finger_controller.ex | 5 + lib/mobilizon_web/http_signature.ex | 5 + lib/service/activity_pub/activity_pub.ex | 1 + lib/service/activity_pub/transmogrifier.ex | 1 + lib/service/activity_pub/utils.ex | 1 + lib/service/federator.ex | 1 + lib/service/formatter/formatter.ex | 1 + .../http_signatures/http_signatures.ex | 1 + lib/service/streamer.ex | 95 ------------------- lib/service/web_finger/web_finger.ex | 3 +- lib/service/xml_builder.ex | 3 +- .../activity_pub_test.exs} | 7 +- .../transmogrifier_test.exs | 8 +- .../utils_test.exs | 2 +- .../service/web_finger/web_finger_test.exs | 5 + .../activity_pub_controller_test.exs | 5 + .../controllers/webfinger_controller_test.exs | 5 + 19 files changed, 59 insertions(+), 100 deletions(-) delete mode 100644 lib/service/streamer.ex rename test/mobilizon/service/{activitypub/activitypub_test.exs => activity_pub/activity_pub_test.exs} (93%) rename test/mobilizon/service/{activitypub => activity_pub}/transmogrifier_test.exs (98%) rename test/mobilizon/service/{activitypub => activity_pub}/utils_test.exs (96%) diff --git a/lib/mobilizon_web/controllers/activity_pub_controller.ex b/lib/mobilizon_web/controllers/activity_pub_controller.ex index a7e9a650d..10db79ace 100644 --- a/lib/mobilizon_web/controllers/activity_pub_controller.ex +++ b/lib/mobilizon_web/controllers/activity_pub_controller.ex @@ -1,3 +1,8 @@ +# Portions of this file are derived from Pleroma: +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only +# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/pleroma/web/activity_pub/activity_pub_controller.ex + defmodule MobilizonWeb.ActivityPubController do use MobilizonWeb, :controller alias Mobilizon.{Actors, Actors.Actor, Events} diff --git a/lib/mobilizon_web/controllers/node_info_controller.ex b/lib/mobilizon_web/controllers/node_info_controller.ex index af7248e6f..ab8b5e073 100644 --- a/lib/mobilizon_web/controllers/node_info_controller.ex +++ b/lib/mobilizon_web/controllers/node_info_controller.ex @@ -1,3 +1,8 @@ +# Portions of this file are derived from Pleroma: +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only +# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex + defmodule MobilizonWeb.NodeInfoController do use MobilizonWeb, :controller diff --git a/lib/mobilizon_web/controllers/web_finger_controller.ex b/lib/mobilizon_web/controllers/web_finger_controller.ex index ffbf7db9c..5a787d1ae 100644 --- a/lib/mobilizon_web/controllers/web_finger_controller.ex +++ b/lib/mobilizon_web/controllers/web_finger_controller.ex @@ -1,3 +1,8 @@ +# Portions of this file are derived from Pleroma: +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only +# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/pleroma/web/web_finger/web_finger_controller.ex + defmodule MobilizonWeb.WebFingerController do use MobilizonWeb, :controller diff --git a/lib/mobilizon_web/http_signature.ex b/lib/mobilizon_web/http_signature.ex index e3c33513a..a10b8c123 100644 --- a/lib/mobilizon_web/http_signature.ex +++ b/lib/mobilizon_web/http_signature.ex @@ -1,3 +1,8 @@ +# Portions of this file are derived from Pleroma: +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only +# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/pleroma/plugs/http_signature.ex + defmodule MobilizonWeb.HTTPSignaturePlug do @moduledoc """ # HTTPSignaturePlug diff --git a/lib/service/activity_pub/activity_pub.ex b/lib/service/activity_pub/activity_pub.ex index 1636fdc66..c3bc3c80b 100644 --- a/lib/service/activity_pub/activity_pub.ex +++ b/lib/service/activity_pub/activity_pub.ex @@ -1,6 +1,7 @@ # Portions of this file are derived from Pleroma: # Copyright © 2017-2018 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only +# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/pleroma/web/activity_pub/activity_pub.ex defmodule Mobilizon.Service.ActivityPub do @moduledoc """ diff --git a/lib/service/activity_pub/transmogrifier.ex b/lib/service/activity_pub/transmogrifier.ex index 7228e7e1a..9e8a13ac3 100644 --- a/lib/service/activity_pub/transmogrifier.ex +++ b/lib/service/activity_pub/transmogrifier.ex @@ -1,6 +1,7 @@ # Portions of this file are derived from Pleroma: # Copyright © 2017-2018 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only +# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/pleroma/web/activity_pub/transmogrifier.ex defmodule Mobilizon.Service.ActivityPub.Transmogrifier do @moduledoc """ diff --git a/lib/service/activity_pub/utils.ex b/lib/service/activity_pub/utils.ex index 5e32c5c5a..2b766d6e9 100644 --- a/lib/service/activity_pub/utils.ex +++ b/lib/service/activity_pub/utils.ex @@ -1,6 +1,7 @@ # Portions of this file are derived from Pleroma: # Copyright © 2017-2018 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only +# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/pleroma/web/activity_pub/utils.ex defmodule Mobilizon.Service.ActivityPub.Utils do @moduledoc """ diff --git a/lib/service/federator.ex b/lib/service/federator.ex index 20d8c98df..968a37552 100644 --- a/lib/service/federator.ex +++ b/lib/service/federator.ex @@ -1,6 +1,7 @@ # Portions of this file are derived from Pleroma: # Copyright © 2017-2018 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only +# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/pleroma/web/federator/federator.ex defmodule Mobilizon.Service.Federator do @moduledoc """ diff --git a/lib/service/formatter/formatter.ex b/lib/service/formatter/formatter.ex index a13556e69..70512b0bf 100644 --- a/lib/service/formatter/formatter.ex +++ b/lib/service/formatter/formatter.ex @@ -1,6 +1,7 @@ # Portions of this file are derived from Pleroma: # Copyright © 2017-2018 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only +# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/pleroma/formatter.ex defmodule Mobilizon.Service.Formatter do alias Mobilizon.Actors.Actor diff --git a/lib/service/http_signatures/http_signatures.ex b/lib/service/http_signatures/http_signatures.ex index 832dfd375..d718f021b 100644 --- a/lib/service/http_signatures/http_signatures.ex +++ b/lib/service/http_signatures/http_signatures.ex @@ -1,6 +1,7 @@ # Portions of this file are derived from Pleroma: # Copyright © 2017-2018 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only +# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/pleroma/web/http_signatures/http_signatures.ex # https://tools.ietf.org/html/draft-cavage-http-signatures-08 defmodule Mobilizon.Service.HTTPSignatures do diff --git a/lib/service/streamer.ex b/lib/service/streamer.ex deleted file mode 100644 index 7b14ce588..000000000 --- a/lib/service/streamer.ex +++ /dev/null @@ -1,95 +0,0 @@ -# Portions of this file are derived from Pleroma: -# Copyright © 2017-2018 Pleroma Authors -# SPDX-License-Identifier: AGPL-3.0-only - -defmodule Mobilizon.Service.Streamer do - @moduledoc """ - # Streamer - - Handles streaming activities - """ - - use GenServer - require Logger - - def init(args) do - {:ok, args} - end - - def start_link do - spawn(fn -> - # 30 seconds - Process.sleep(1000 * 30) - GenServer.cast(__MODULE__, %{action: :ping}) - end) - - GenServer.start_link(__MODULE__, %{}, name: __MODULE__) - end - - def add_socket(topic, socket) do - GenServer.cast(__MODULE__, %{action: :add, socket: socket, topic: topic}) - end - - def remove_socket(topic, socket) do - GenServer.cast(__MODULE__, %{action: :remove, socket: socket, topic: topic}) - end - - def stream(topic, item) do - GenServer.cast(__MODULE__, %{action: :stream, topic: topic, item: item}) - end - - def handle_cast(%{action: :ping}, topics) do - topics - |> Map.values() - |> List.flatten() - |> Enum.each(fn socket -> - Logger.debug("Sending keepalive ping") - send(socket.transport_pid, {:text, ""}) - end) - - spawn(fn -> - # 30 seconds - Process.sleep(1000 * 30) - GenServer.cast(__MODULE__, %{action: :ping}) - end) - - {:noreply, topics} - end - - def handle_cast(%{action: :add, topic: topic, socket: socket}, sockets) do - topic = internal_topic(topic, socket) - sockets_for_topic = sockets[topic] || [] - sockets_for_topic = Enum.uniq([socket | sockets_for_topic]) - sockets = Map.put(sockets, topic, sockets_for_topic) - - Logger.debug(fn -> - "Got new conn for #{topic}" - end) - - {:noreply, sockets} - end - - def handle_cast(%{action: :remove, topic: topic, socket: socket}, sockets) do - topic = internal_topic(topic, socket) - sockets_for_topic = sockets[topic] || [] - sockets_for_topic = List.delete(sockets_for_topic, socket) - sockets = Map.put(sockets, topic, sockets_for_topic) - - Logger.debug(fn -> - "Removed conn for #{topic}" - end) - - {:noreply, sockets} - end - - def handle_cast(m, state) do - Logger.info("Unknown: #{inspect(m)}, #{inspect(state)}") - {:noreply, state} - end - - defp internal_topic("user", socket) do - "user:#{socket.assigns[:user].id}" - end - - defp internal_topic(topic, _), do: topic -end diff --git a/lib/service/web_finger/web_finger.ex b/lib/service/web_finger/web_finger.ex index cdaa5a99a..4e453bf59 100644 --- a/lib/service/web_finger/web_finger.ex +++ b/lib/service/web_finger/web_finger.ex @@ -1,12 +1,13 @@ # Portions of this file are derived from Pleroma: # Copyright © 2017-2018 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only +# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/pleroma/web/web_finger/web_finger.ex defmodule Mobilizon.Service.WebFinger do @moduledoc """ # WebFinger - Performs the WebFinger requests and responses (json only) + Performs the WebFinger requests and responses (JSON only) """ alias Mobilizon.Actors diff --git a/lib/service/xml_builder.ex b/lib/service/xml_builder.ex index c2177d548..ac32a45b5 100644 --- a/lib/service/xml_builder.ex +++ b/lib/service/xml_builder.ex @@ -1,12 +1,13 @@ # Portions of this file are derived from Pleroma: # Copyright © 2017-2018 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only +# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/xml_builder.ex defmodule Mobilizon.Service.XmlBuilder do @moduledoc """ XML Builder. - Do we still need this ? Only for xrd ? + Needed to build XRD for webfinger host_meta """ def to_xml({tag, attributes, content}) do diff --git a/test/mobilizon/service/activitypub/activitypub_test.exs b/test/mobilizon/service/activity_pub/activity_pub_test.exs similarity index 93% rename from test/mobilizon/service/activitypub/activitypub_test.exs rename to test/mobilizon/service/activity_pub/activity_pub_test.exs index d870afcaf..5975ad4a9 100644 --- a/test/mobilizon/service/activitypub/activitypub_test.exs +++ b/test/mobilizon/service/activity_pub/activity_pub_test.exs @@ -1,4 +1,9 @@ -defmodule Mobilizon.Service.Activitypub.ActivitypubTest do +# Portions of this file are derived from Pleroma: +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only +# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/test/web/activity_pub/activity_pub_test.exs + +defmodule Mobilizon.Service.ActivityPub.ActivityPubTest do use Mobilizon.DataCase import Mobilizon.Factory diff --git a/test/mobilizon/service/activitypub/transmogrifier_test.exs b/test/mobilizon/service/activity_pub/transmogrifier_test.exs similarity index 98% rename from test/mobilizon/service/activitypub/transmogrifier_test.exs rename to test/mobilizon/service/activity_pub/transmogrifier_test.exs index faa7e2d62..e6da6555e 100644 --- a/test/mobilizon/service/activitypub/transmogrifier_test.exs +++ b/test/mobilizon/service/activity_pub/transmogrifier_test.exs @@ -1,4 +1,10 @@ -defmodule Mobilizon.Service.Activitypub.TransmogrifierTest do +# Portions of this file are derived from Pleroma: +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only +# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/test/web/activity_pub/transmogrifier_test.exs + +defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do + use Mobilizon.DataCase import Mobilizon.Factory diff --git a/test/mobilizon/service/activitypub/utils_test.exs b/test/mobilizon/service/activity_pub/utils_test.exs similarity index 96% rename from test/mobilizon/service/activitypub/utils_test.exs rename to test/mobilizon/service/activity_pub/utils_test.exs index 45b25efce..642531ef8 100644 --- a/test/mobilizon/service/activitypub/utils_test.exs +++ b/test/mobilizon/service/activity_pub/utils_test.exs @@ -1,4 +1,4 @@ -defmodule Mobilizon.Service.Activitypub.UtilsTest do +defmodule Mobilizon.Service.ActivityPub.UtilsTest do use Mobilizon.DataCase import Mobilizon.Factory alias Mobilizon.Service.ActivityPub.Utils diff --git a/test/mobilizon/service/web_finger/web_finger_test.exs b/test/mobilizon/service/web_finger/web_finger_test.exs index 06fa4d1f2..e66a5df52 100644 --- a/test/mobilizon/service/web_finger/web_finger_test.exs +++ b/test/mobilizon/service/web_finger/web_finger_test.exs @@ -1,3 +1,8 @@ +# Portions of this file are derived from Pleroma: +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only +# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/test/web/web_finger/web_finger_test.exs + defmodule Mobilizon.Service.WebFingerTest do use Mobilizon.DataCase alias Mobilizon.Service.WebFinger diff --git a/test/mobilizon_web/controllers/activity_pub_controller_test.exs b/test/mobilizon_web/controllers/activity_pub_controller_test.exs index f9450a04a..4038a0432 100644 --- a/test/mobilizon_web/controllers/activity_pub_controller_test.exs +++ b/test/mobilizon_web/controllers/activity_pub_controller_test.exs @@ -1,3 +1,8 @@ +# Portions of this file are derived from Pleroma: +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only +# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/test/web/web_finger/web_finger_controller_test.exs + defmodule MobilizonWeb.ActivityPubControllerTest do use MobilizonWeb.ConnCase import Mobilizon.Factory diff --git a/test/mobilizon_web/controllers/webfinger_controller_test.exs b/test/mobilizon_web/controllers/webfinger_controller_test.exs index de9b2643b..37b41bef8 100644 --- a/test/mobilizon_web/controllers/webfinger_controller_test.exs +++ b/test/mobilizon_web/controllers/webfinger_controller_test.exs @@ -1,3 +1,8 @@ +# Portions of this file are derived from Pleroma: +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only +# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/test/web/web_finger/web_finger_test.exs + defmodule MobilizonWeb.WebFingerTest do use MobilizonWeb.ConnCase alias Mobilizon.Actors.Actor