Merge branch 'develop' into global-status-expiration
authorEgor Kislitsyn <egor@kislitsyn.com>
Mon, 8 Jun 2020 13:21:47 +0000 (17:21 +0400)
committerEgor Kislitsyn <egor@kislitsyn.com>
Mon, 8 Jun 2020 13:21:47 +0000 (17:21 +0400)
1  2 
config/config.exs
lib/pleroma/web/activity_pub/activity_pub.ex
test/web/activity_pub/activity_pub_test.exs

Simple merge
index 7f6b59cc625ffe96d3b7abe9040284062a0f1342,eb73c95fe6cc8452ee38c51411e7fa3cdf1fad3b..5b519033eac9232db801e71a0091fbf7ccfbaee8
@@@ -159,17 -144,10 +145,12 @@@ defmodule Pleroma.Web.ActivityPub.Activ
            local: local,
            actor: map["actor"],
            recipients: recipients
 -        })
 +        }
 +        |> Repo.insert()
 +        |> maybe_create_activity_expiration()
  
        # Splice in the child object if we have one.
-       activity =
-         if not is_nil(object) do
-           Map.put(activity, :object, object)
-         else
-           activity
-         end
+       activity = Maps.put_if_present(activity, :object, object)
  
        BackgroundWorker.enqueue("fetch_data_for_activity", %{"activity_id" => activity.id})
  
      stream_out_participations(participations)
    end
  
 +  defp maybe_create_activity_expiration({:ok, %{data: %{"expires_at" => expires_at}} = activity}) do
 +    with {:ok, _} <- ActivityExpiration.create(activity, expires_at) do
 +      {:ok, activity}
 +    end
 +  end
 +
 +  defp maybe_create_activity_expiration(result), do: result
 +
    defp create_or_bump_conversation(activity, actor) do
      with {:ok, conversation} <- Conversation.create_or_bump_for(activity),
-          %User{} = user <- User.get_cached_by_ap_id(actor),
-          Participation.mark_as_read(user, conversation) do
+          %User{} = user <- User.get_cached_by_ap_id(actor) do
+       Participation.mark_as_read(user, conversation)
        {:ok, conversation}
      end
    end