Improve readability
authorEgor Kislitsyn <egor@kislitsyn.com>
Fri, 14 Feb 2020 11:50:31 +0000 (15:50 +0400)
committerEgor Kislitsyn <egor@kislitsyn.com>
Fri, 14 Feb 2020 11:50:31 +0000 (15:50 +0400)
lib/pleroma/web/activity_pub/mrf/activity_expiration_policy.ex

index 1b88601611249ea494a3463d09e98df3ad71681e..5d823f2c7dc0de90a9253746c159b7630fb064d6 100644 (file)
@@ -7,9 +7,9 @@ defmodule Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicy do
   @behaviour Pleroma.Web.ActivityPub.MRF
 
   @impl true
-  def filter(%{"id" => id} = activity) do
+  def filter(activity) do
     activity =
-      if String.starts_with?(id, Pleroma.Web.Endpoint.url()) do
+      if local?(activity) do
         maybe_add_expiration(activity)
       else
         activity
@@ -21,6 +21,10 @@ defmodule Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicy do
   @impl true
   def describe, do: {:ok, %{}}
 
+  defp local?(%{"id" => id}) do
+    String.starts_with?(id, Pleroma.Web.Endpoint.url())
+  end
+
   defp maybe_add_expiration(activity) do
     days = Pleroma.Config.get([:mrf_activity_expiration, :days], 365)
     expires_at = NaiveDateTime.utc_now() |> Timex.shift(days: days)