Merge branch 'meta/pleroma-attributes-improvements' into 'master'

Pleroma attributes improvements

See merge request framasoft/mobilizon!35
This commit is contained in:
Thomas Citharel 2018-12-27 11:36:24 +01:00
commit 3c1b0448a8
20 changed files with 70 additions and 104 deletions

View File

@ -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`

View File

@ -1,3 +1,8 @@
# Portions of this file are derived from Pleroma:
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social>
# 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}

View File

@ -1,3 +1,8 @@
# Portions of this file are derived from Pleroma:
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social>
# 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

View File

@ -1,8 +1,19 @@
# Portions of this file are derived from Pleroma:
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social>
# 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

View File

@ -1,3 +1,8 @@
# Portions of this file are derived from Pleroma:
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social>
# 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

View File

@ -1,6 +1,7 @@
# Portions of this file are derived from Pleroma:
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social>
# 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 """

View File

@ -1,6 +1,7 @@
# Portions of this file are derived from Pleroma:
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social>
# 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 """

View File

@ -1,6 +1,7 @@
# Portions of this file are derived from Pleroma:
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social>
# 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 """

View File

@ -1,6 +1,7 @@
# Portions of this file are derived from Pleroma:
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social>
# 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 """

View File

@ -1,6 +1,7 @@
# Portions of this file are derived from Pleroma:
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social>
# 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

View File

@ -1,6 +1,7 @@
# Portions of this file are derived from Pleroma:
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social>
# 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

View File

@ -1,95 +0,0 @@
# Portions of this file are derived from Pleroma:
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social>
# 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

View File

@ -1,12 +1,13 @@
# Portions of this file are derived from Pleroma:
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social>
# 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

View File

@ -1,12 +1,13 @@
# Portions of this file are derived from Pleroma:
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social>
# 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

View File

@ -1,4 +1,9 @@
defmodule Mobilizon.Service.Activitypub.ActivitypubTest do
# Portions of this file are derived from Pleroma:
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social>
# 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

View File

@ -1,4 +1,9 @@
defmodule Mobilizon.Service.Activitypub.TransmogrifierTest do
# Portions of this file are derived from Pleroma:
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social>
# 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

View File

@ -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

View File

@ -1,3 +1,8 @@
# Portions of this file are derived from Pleroma:
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social>
# 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

View File

@ -1,3 +1,8 @@
# Portions of this file are derived from Pleroma:
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social>
# 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

View File

@ -1,3 +1,8 @@
# Portions of this file are derived from Pleroma:
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social>
# 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