Fix rendering metadata from deleted (empty) comments

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-09-10 11:30:12 +02:00
parent e9e12500dc
commit acbe0e6c59
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773

View file

@ -2,7 +2,8 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Discussions.Comment do
alias Phoenix.HTML.Tag
alias Mobilizon.Discussions.Comment
def build_tags(%Comment{} = comment, _locale \\ "en") do
@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),
@ -11,4 +12,6 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Discussions.Comment do
Tag.tag(:meta, property: "twitter:card", content: "summary")
]
end
def build_tags(%Comment{} = _comment, _locale), do: []
end