Remove credo and use mix format, and lint everything
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -34,16 +34,16 @@ defmodule EventosWeb.ActivityPub.ActorView do
|
||||
"publicKeyPem" => public_key
|
||||
},
|
||||
"endpoints" => %{
|
||||
"sharedInbox" => actor.shared_inbox_url,
|
||||
},
|
||||
# "icon" => %{
|
||||
# "type" => "Image",
|
||||
# "url" => User.avatar_url(actor)
|
||||
# },
|
||||
# "image" => %{
|
||||
# "type" => "Image",
|
||||
# "url" => User.banner_url(actor)
|
||||
# }
|
||||
"sharedInbox" => actor.shared_inbox_url
|
||||
}
|
||||
# "icon" => %{
|
||||
# "type" => "Image",
|
||||
# "url" => User.avatar_url(actor)
|
||||
# },
|
||||
# "image" => %{
|
||||
# "type" => "Image",
|
||||
# "url" => User.banner_url(actor)
|
||||
# }
|
||||
}
|
||||
|> Map.merge(Utils.make_json_ld_header())
|
||||
end
|
||||
@@ -87,13 +87,14 @@ defmodule EventosWeb.ActivityPub.ActorView do
|
||||
end
|
||||
|
||||
def render("outbox.json", %{actor: actor, page: page}) do
|
||||
{page, no_page} = if page == 0 do
|
||||
{1, true}
|
||||
else
|
||||
{page, false}
|
||||
end
|
||||
{page, no_page} =
|
||||
if page == 0 do
|
||||
{1, true}
|
||||
else
|
||||
{page, false}
|
||||
end
|
||||
|
||||
{activities, total} = ActivityPub.fetch_public_activities_for_actor(actor, page)
|
||||
{activities, total} = ActivityPub.fetch_public_activities_for_actor(actor, page)
|
||||
|
||||
collection =
|
||||
Enum.map(activities, fn act ->
|
||||
@@ -128,7 +129,12 @@ defmodule EventosWeb.ActivityPub.ActorView do
|
||||
def render("activity.json", %{activity: %Activity{local: local} = activity}) do
|
||||
%{
|
||||
"id" => activity.data.url <> "/activity",
|
||||
"type" => if local do "Create" else "Announce" end,
|
||||
"type" =>
|
||||
if local do
|
||||
"Create"
|
||||
else
|
||||
"Announce"
|
||||
end,
|
||||
"actor" => activity.data.organizer_actor.url,
|
||||
"published" => Timex.now(),
|
||||
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
|
||||
|
||||
@@ -2,6 +2,7 @@ defmodule EventosWeb.ActivityPub.ObjectView do
|
||||
use EventosWeb, :view
|
||||
alias EventosWeb.ActivityPub.ObjectView
|
||||
alias Eventos.Service.ActivityPub.Transmogrifier
|
||||
|
||||
@base %{
|
||||
"@context" => [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
@@ -17,8 +18,6 @@ defmodule EventosWeb.ActivityPub.ObjectView do
|
||||
}
|
||||
|
||||
def render("event.json", %{event: event}) do
|
||||
|
||||
|
||||
event = %{
|
||||
"type" => "Event",
|
||||
"id" => event.url,
|
||||
@@ -27,8 +26,9 @@ defmodule EventosWeb.ActivityPub.ObjectView do
|
||||
"content" => event.description,
|
||||
"mediaType" => "text/markdown",
|
||||
"published" => Timex.format!(event.inserted_at, "{ISO:Extended}"),
|
||||
"updated" => Timex.format!(event.updated_at, "{ISO:Extended}"),
|
||||
"updated" => Timex.format!(event.updated_at, "{ISO:Extended}")
|
||||
}
|
||||
|
||||
Map.merge(event, @base)
|
||||
end
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@ defmodule EventosWeb.ActorView do
|
||||
end
|
||||
|
||||
def render("actor_basic.json", %{actor: actor}) do
|
||||
%{id: actor.id,
|
||||
%{
|
||||
id: actor.id,
|
||||
username: actor.preferred_username,
|
||||
domain: actor.domain,
|
||||
display_name: actor.name,
|
||||
@@ -28,12 +29,13 @@ defmodule EventosWeb.ActorView do
|
||||
# public_key: actor.public_key,
|
||||
suspended: actor.suspended,
|
||||
url: actor.url,
|
||||
avatar: actor.avatar_url,
|
||||
avatar: actor.avatar_url
|
||||
}
|
||||
end
|
||||
|
||||
def render("actor.json", %{actor: actor}) do
|
||||
output = %{id: actor.id,
|
||||
output = %{
|
||||
id: actor.id,
|
||||
username: actor.preferred_username,
|
||||
domain: actor.domain,
|
||||
display_name: actor.name,
|
||||
@@ -46,11 +48,18 @@ defmodule EventosWeb.ActorView do
|
||||
banner: actor.banner_url,
|
||||
organized_events: render_many(actor.organized_events, EventView, "event_for_actor.json")
|
||||
}
|
||||
|
||||
import Logger
|
||||
Logger.debug(inspect actor.type)
|
||||
Logger.debug(inspect(actor.type))
|
||||
|
||||
if actor.type == :Group do
|
||||
Logger.debug("I'm a group !")
|
||||
Map.put(output, :members, render_many(Actors.members_for_group(actor), MemberView, "member.json"))
|
||||
|
||||
Map.put(
|
||||
output,
|
||||
:members,
|
||||
render_many(Actors.members_for_group(actor), MemberView, "member.json")
|
||||
)
|
||||
else
|
||||
Logger.debug("not a group")
|
||||
output
|
||||
|
||||
@@ -15,7 +15,8 @@ defmodule EventosWeb.AddressView do
|
||||
end
|
||||
|
||||
def render("address.json", %{address: address}) do
|
||||
%{id: address.id,
|
||||
%{
|
||||
id: address.id,
|
||||
description: address.description,
|
||||
floor: address.floor,
|
||||
addressCountry: address.addressCountry,
|
||||
@@ -29,11 +30,12 @@ defmodule EventosWeb.AddressView do
|
||||
|
||||
def render("geom.json", %{address: %Geo.Point{} = point}) do
|
||||
[lat, lon] = Tuple.to_list(point.coordinates)
|
||||
|
||||
%{
|
||||
type: "point",
|
||||
data: %{
|
||||
"latitude": lat,
|
||||
"longitude": lon,
|
||||
latitude: lat,
|
||||
longitude: lon
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
@@ -11,8 +11,6 @@ defmodule EventosWeb.BotView do
|
||||
end
|
||||
|
||||
def render("bot.json", %{bot: bot}) do
|
||||
%{id: bot.id,
|
||||
source: bot.source,
|
||||
type: bot.type}
|
||||
%{id: bot.id, source: bot.source, type: bot.type}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,9 +14,11 @@ defmodule EventosWeb.CategoryView do
|
||||
end
|
||||
|
||||
def render("category.json", %{category: category}) do
|
||||
%{id: category.id,
|
||||
%{
|
||||
id: category.id,
|
||||
title: category.title,
|
||||
description: category.description,
|
||||
picture: category.picture}
|
||||
picture: category.picture
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,10 +11,6 @@ defmodule EventosWeb.CommentView do
|
||||
end
|
||||
|
||||
def render("comment.json", %{comment: comment}) do
|
||||
%{id: comment.id,
|
||||
uuid: comment.uuid,
|
||||
url: comment.url,
|
||||
text: comment.text
|
||||
}
|
||||
%{id: comment.id, uuid: comment.uuid, url: comment.url, text: comment.text}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,8 +9,8 @@ defmodule EventosWeb.ErrorHelpers do
|
||||
Generates tag for inlined form input errors.
|
||||
"""
|
||||
def error_tag(form, field) do
|
||||
Enum.map(Keyword.get_values(form.errors, field), fn (error) ->
|
||||
content_tag :span, translate_error(error), class: "help-block"
|
||||
Enum.map(Keyword.get_values(form.errors, field), fn error ->
|
||||
content_tag(:span, translate_error(error), class: "help-block")
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
@@ -19,6 +19,6 @@ defmodule EventosWeb.ErrorView do
|
||||
# In case no render clause matches or no
|
||||
# template is found, let's render it as 500
|
||||
def template_not_found(_template, assigns) do
|
||||
render "500.html", assigns
|
||||
render("500.html", assigns)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,7 +10,13 @@ defmodule EventosWeb.EventView do
|
||||
data: render_many(events, EventView, "event_simple.json"),
|
||||
coord: coord,
|
||||
city: city,
|
||||
country: country,
|
||||
country: country
|
||||
}
|
||||
end
|
||||
|
||||
def render("index_all.json", %{events: events}) do
|
||||
%{
|
||||
data: render_many(events, EventView, "event_simple.json")
|
||||
}
|
||||
end
|
||||
|
||||
@@ -23,14 +29,12 @@ defmodule EventosWeb.EventView do
|
||||
end
|
||||
|
||||
def render("event_for_actor.json", %{event: event}) do
|
||||
%{id: event.id,
|
||||
title: event.title,
|
||||
uuid: event.uuid,
|
||||
}
|
||||
%{id: event.id, title: event.title, uuid: event.uuid}
|
||||
end
|
||||
|
||||
def render("event_simple.json", %{event: event}) do
|
||||
%{id: event.id,
|
||||
%{
|
||||
id: event.id,
|
||||
title: event.title,
|
||||
description: event.description,
|
||||
begins_on: event.begins_on,
|
||||
@@ -39,15 +43,16 @@ defmodule EventosWeb.EventView do
|
||||
organizer: %{
|
||||
username: event.organizer_actor.preferred_username,
|
||||
display_name: event.organizer_actor.name,
|
||||
avatar: event.organizer_actor.avatar_url,
|
||||
avatar: event.organizer_actor.avatar_url
|
||||
},
|
||||
type: "Event",
|
||||
address_type: event.address_type,
|
||||
address_type: event.address_type
|
||||
}
|
||||
end
|
||||
|
||||
def render("event.json", %{event: event}) do
|
||||
%{id: event.id,
|
||||
%{
|
||||
id: event.id,
|
||||
title: event.title,
|
||||
description: event.description,
|
||||
begins_on: event.begins_on,
|
||||
@@ -57,7 +62,7 @@ defmodule EventosWeb.EventView do
|
||||
participants: render_many(event.participants, ActorView, "actor_basic.json"),
|
||||
physical_address: render_one(event.physical_address, AddressView, "address.json"),
|
||||
type: "Event",
|
||||
address_type: event.address_type,
|
||||
address_type: event.address_type
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,16 +18,18 @@ defmodule EventosWeb.GroupView do
|
||||
end
|
||||
|
||||
def render("group_simple.json", %{group: group}) do
|
||||
%{id: group.id,
|
||||
%{
|
||||
id: group.id,
|
||||
title: group.title,
|
||||
description: group.description,
|
||||
suspended: group.suspended,
|
||||
url: group.url,
|
||||
url: group.url
|
||||
}
|
||||
end
|
||||
|
||||
def render("group.json", %{group: group}) do
|
||||
%{id: group.id,
|
||||
%{
|
||||
id: group.id,
|
||||
title: group.title,
|
||||
description: group.description,
|
||||
suspended: group.suspended,
|
||||
|
||||
@@ -14,7 +14,6 @@ defmodule EventosWeb.ParticipantView do
|
||||
end
|
||||
|
||||
def render("participant.json", %{participant: participant}) do
|
||||
%{id: participant.id,
|
||||
role: participant.role}
|
||||
%{id: participant.id, role: participant.role}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ defmodule EventosWeb.SearchView do
|
||||
%{
|
||||
data: %{
|
||||
events: render_many(events, EventView, "event_simple.json"),
|
||||
actors: render_many(actors, ActorView, "actor_basic.json"),
|
||||
actors: render_many(actors, ActorView, "actor_basic.json")
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
@@ -14,7 +14,8 @@ defmodule EventosWeb.SessionView do
|
||||
end
|
||||
|
||||
def render("session.json", %{session: session}) do
|
||||
%{id: session.id,
|
||||
%{
|
||||
id: session.id,
|
||||
title: session.title,
|
||||
subtitle: session.subtitle,
|
||||
short_abstract: session.short_abstract,
|
||||
@@ -22,6 +23,7 @@ defmodule EventosWeb.SessionView do
|
||||
language: session.language,
|
||||
slides_url: session.slides_url,
|
||||
videos_urls: session.videos_urls,
|
||||
audios_urls: session.audios_urls}
|
||||
audios_urls: session.audios_urls
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,7 +14,6 @@ defmodule EventosWeb.TagView do
|
||||
end
|
||||
|
||||
def render("tag.json", %{tag: tag}) do
|
||||
%{id: tag.id,
|
||||
title: tag.title}
|
||||
%{id: tag.id, title: tag.title}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,9 +14,6 @@ defmodule EventosWeb.TrackView do
|
||||
end
|
||||
|
||||
def render("track.json", %{track: track}) do
|
||||
%{id: track.id,
|
||||
name: track.name,
|
||||
description: track.description,
|
||||
color: track.color}
|
||||
%{id: track.id, name: track.name, description: track.description, color: track.color}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -26,35 +26,30 @@ defmodule EventosWeb.UserView do
|
||||
end
|
||||
|
||||
def render("user_simple.json", %{user: user}) do
|
||||
%{id: user.id,
|
||||
%{
|
||||
id: user.id,
|
||||
role: user.role,
|
||||
actors: render_many(user.actors, ActorView, "actor_basic.json")
|
||||
}
|
||||
end
|
||||
|
||||
def render("user.json", %{user: user}) do
|
||||
%{id: user.id,
|
||||
role: user.role,
|
||||
actors: render_many(user.actors, ActorView, "actor.json")
|
||||
}
|
||||
%{id: user.id, role: user.role, actors: render_many(user.actors, ActorView, "actor.json")}
|
||||
end
|
||||
|
||||
def render("user_private.json", %{user: user}) do
|
||||
%{id: user.id,
|
||||
email: user.email,
|
||||
role: user.role,
|
||||
}
|
||||
%{id: user.id, email: user.email, role: user.role}
|
||||
end
|
||||
|
||||
def render("confirmation.json", %{user: user}) do
|
||||
%{
|
||||
email: user.email,
|
||||
email: user.email
|
||||
}
|
||||
end
|
||||
|
||||
def render("password_reset.json", %{user: user}) do
|
||||
%{
|
||||
email: user.email,
|
||||
email: user.email
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user