total rebase
[anni] / lib / pleroma / web / rich_media / parser / ttl / opengraph.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.RichMedia.Parser.TTL.Opengraph do
6   @behaviour Pleroma.Web.RichMedia.Parser.TTL
7
8   @impl true
9   def ttl(%{"ttl" => ttl_string}, _url) when is_binary(ttl_string) do
10     try do
11       ttl = String.to_integer(ttl_string)
12       now = DateTime.utc_now() |> DateTime.to_unix()
13       now + ttl
14     rescue
15       _ -> nil
16     end
17   end
18
19   def ttl(_, _), do: nil
20 end