Add Credo checks and refactor code

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Make Logger.debug calls lazy

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Add missing @moduledocs

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Refactor according to credo

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Final fixes and add credo to CI

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Closes #52
This commit is contained in:
Thomas Citharel
2019-01-03 14:59:59 +01:00
parent ea82d392e9
commit 2f2c538cc9
27 changed files with 163 additions and 121 deletions

View File

@@ -43,14 +43,7 @@ defmodule Mobilizon.Service.ActivityPub do
def insert(map, local \\ true) when is_map(map) do
with map <- lazy_put_activity_defaults(map),
:ok <- insert_full_object(map) do
object_id =
cond do
is_map(map["object"]) ->
map["object"]["id"]
is_binary(map["object"]) ->
map["id"]
end
object_id = if is_map(map["object"]), do: map["object"]["id"], else: map["id"]
map = if local, do: Map.put(map, "id", "#{object_id}/activity"), else: map
@@ -384,7 +377,7 @@ defmodule Mobilizon.Service.ActivityPub do
{:ok, data} = Transmogrifier.prepare_outgoing(activity.data)
json = Jason.encode!(data)
Logger.debug("Remote inboxes are : #{inspect(remote_inboxes)}")
Logger.debug(fn -> "Remote inboxes are : #{inspect(remote_inboxes)}" end)
Enum.each(remote_inboxes, fn inbox ->
Federator.enqueue(:publish_single_ap, %{