Front-end stuff

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2018-05-19 10:19:21 +02:00
parent cf0cbc8bde
commit e47ff97ac6
30 changed files with 435 additions and 357 deletions

View File

@@ -241,6 +241,11 @@ defmodule Eventos.Service.ActivityPub do
"type" => "Image",
"url" => [%{"href" => data["image"]["url"]}]
}
name = if String.trim(data["name"]) === "" do
data["preferredUsername"]
else
data["name"]
end
user_data = %{
url: data["id"],
@@ -250,7 +255,7 @@ defmodule Eventos.Service.ActivityPub do
"banner" => banner
},
avatar: avatar,
name: data["name"],
name: name,
preferred_username: data["preferredUsername"],
follower_address: data["followers"],
summary: data["summary"],
@@ -269,7 +274,7 @@ defmodule Eventos.Service.ActivityPub do
end
@spec fetch_public_activities_for_actor(Actor.t, integer(), integer()) :: list()
def fetch_public_activities_for_actor(%Actor{} = actor, page \\ 10, limit \\ 1) do
def fetch_public_activities_for_actor(%Actor{} = actor, page \\ 10, limit \\ 10) do
{:ok, events, total} = Events.get_events_for_actor(actor, page, limit)
activities = Enum.map(events, fn event ->
{:ok, activity} = event_to_activity(event)

View File

@@ -80,8 +80,9 @@ defmodule Eventos.Service.WebFinger do
address = "http://#{domain}/.well-known/webfinger?resource=acct:#{actor}"
with response <- HTTPoison.get(address, [Accept: "application/json"],follow_redirect: true),
{:ok, %{status_code: status_code, body: body}} when status_code in 200..299 <- response do
Logger.debug(inspect address)
with response <- HTTPoison.get!(address, [Accept: "application/json, application/activity+json, application/jrd+json"],follow_redirect: true),
%{status_code: status_code, body: body} when status_code in 200..299 <- response do
{:ok, doc} = Jason.decode(body)
webfinger_from_json(doc)
else