activity interpretation: formatting

This commit is contained in:
William Pitcock 2018-06-24 06:34:44 +00:00
parent 66819ea784
commit 971bb4f2bd
3 changed files with 5 additions and 1 deletions

View file

@ -122,7 +122,8 @@ def fix_content_map(object), do: object
# TODO: validate those with a Ecto scheme # TODO: validate those with a Ecto scheme
# - tags # - tags
# - emoji # - emoji
def handle_incoming(%{"type" => "Create", "object" => %{"type" => objtype} = object} = data) when objtype in ["Article", "Note"] do def handle_incoming(%{"type" => "Create", "object" => %{"type" => objtype} = object} = data)
when objtype in ["Article", "Note"] do
with nil <- Activity.get_create_activity_by_object_ap_id(object["id"]), with nil <- Activity.get_create_activity_by_object_ap_id(object["id"]),
%User{} = user <- User.get_or_fetch_by_ap_id(data["actor"]) do %User{} = user <- User.get_or_fetch_by_ap_id(data["actor"]) do
object = fix_object(data["object"]) object = fix_object(data["object"])

View file

@ -210,6 +210,7 @@ def get_visibility(object) do
def render_content(%{"type" => "Article"} = object) do def render_content(%{"type" => "Article"} = object) do
summary = object["name"] summary = object["name"]
content = content =
if !!summary and summary != "" do if !!summary and summary != "" do
"<p><a href=\"#{object["url"]}\">#{summary}</a></p>#{object["content"]}" "<p><a href=\"#{object["url"]}\">#{summary}</a></p>#{object["content"]}"

View file

@ -261,6 +261,7 @@ def render(
def render_content(%{"type" => "Note"} = object) do def render_content(%{"type" => "Note"} = object) do
summary = object["summary"] summary = object["summary"]
content = content =
if !!summary and summary != "" do if !!summary and summary != "" do
"<p>#{summary}</p>#{object["content"]}" "<p>#{summary}</p>#{object["content"]}"
@ -273,6 +274,7 @@ def render_content(%{"type" => "Note"} = object) do
def render_content(%{"type" => "Article"} = object) do def render_content(%{"type" => "Article"} = object) do
summary = object["name"] || object["summary"] summary = object["name"] || object["summary"]
content = content =
if !!summary and summary != "" do if !!summary and summary != "" do
"<p><a href=\"#{object["url"]}\">#{summary}</a></p>#{object["content"]}" "<p><a href=\"#{object["url"]}\">#{summary}</a></p>#{object["content"]}"