diff --git a/README.md b/README.md index 6ecf19e86..00b4b2d2b 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Your federated organization and mobilization platform. Gather people with a convivial, ethical, and emancipating tool. ## Development -Clone the repo, and start the project via Docker +Clone the repo, and start the project trough Docker. You'll need both Docker and Docker-Compose. ```bash git clone https://framagit.org/framasoft/mobilizon && cd mobilizon make @@ -65,3 +65,4 @@ to start a database container, an API container and the front-end dev container * Mastodon: https://framapiaf.org/@mobilizon * Forum: https://framacolibri.org/c/mobilizon/fr-francais +Note: Most federation code comes from [Pleroma](https://pleroma.social), which is `Copyright © 2017-2018 Pleroma Authors - AGPL-3.0` 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..37bee7fe4 100644 --- a/lib/mobilizon_web/controllers/web_finger_controller.ex +++ b/lib/mobilizon_web/controllers/web_finger_controller.ex @@ -1,8 +1,19 @@ +# 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 + @moduledoc """ + Handles Webfinger requests + """ use MobilizonWeb, :controller alias Mobilizon.Service.WebFinger + @doc """ + Provides /.well-known/host-meta + """ def host_meta(conn, _params) do xml = WebFinger.host_meta() @@ -11,6 +22,9 @@ defmodule MobilizonWeb.WebFingerController do |> send_resp(200, xml) end + @doc """ + Provides /.well-known/webfinger + """ def webfinger(conn, %{"resource" => resource}) do with {:ok, response} <- WebFinger.webfinger(resource, "JSON") do json(conn, response) @@ -19,7 +33,5 @@ defmodule MobilizonWeb.WebFingerController do end end - def webfinger(conn, _) do - send_resp(conn, 400, "No query provided") - end + def webfinger(conn, _), do: send_resp(conn, 400, "No query provided") end 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..1ad689db8 100644 --- a/test/mobilizon/service/activitypub/transmogrifier_test.exs +++ b/test/mobilizon/service/activity_pub/transmogrifier_test.exs @@ -1,4 +1,9 @@ -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