Improve json-ld metadata on event live streams

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-11-15 12:11:29 +01:00
parent bcf17fe30b
commit 85ceb1de47
2 changed files with 54 additions and 22 deletions

View File

@@ -29,7 +29,7 @@ defmodule Mobilizon.Service.Metadata.Utils do
* Slices it to a limit and add an ellipsis character
* Returns a default description if text is empty
"""
@spec process_description(String.t(), String.t(), integer()) :: String.t()
@spec process_description(String.t(), String.t(), integer() | nil) :: String.t()
def process_description(description, locale \\ "en", limit \\ @slice_limit)
def process_description(nil, locale, limit), do: process_description("", locale, limit)
@@ -56,6 +56,8 @@ defmodule Mobilizon.Service.Metadata.Utils do
defdelegate datetime_to_string(datetime, locale \\ "en", format \\ :medium), to: DateTime
defdelegate render_address(address), to: Address
defp maybe_slice(description, nil), do: description
defp maybe_slice(description, limit) do
if String.length(description) > limit do
description