debianize-mobilizon/lib/service/metadata/comment.ex
Thomas Citharel acbe0e6c59
Fix rendering metadata from deleted (empty) comments
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2021-09-26 17:52:22 +02:00

18 lines
711 B
Elixir

defimpl Mobilizon.Service.Metadata, for: Mobilizon.Discussions.Comment do
alias Phoenix.HTML.Tag
alias Mobilizon.Discussions.Comment
@spec build_tags(Comment.t(), String.t()) :: list(Phoenix.HTML.safe())
def build_tags(%Comment{deleted_at: nil} = comment, _locale) do
[
Tag.tag(:meta, property: "og:title", content: comment.actor.preferred_username),
Tag.tag(:meta, property: "og:url", content: comment.url),
Tag.tag(:meta, property: "og:description", content: comment.text),
Tag.tag(:meta, property: "og:type", content: "website"),
Tag.tag(:meta, property: "twitter:card", content: "summary")
]
end
def build_tags(%Comment{} = _comment, _locale), do: []
end