From: Egor Kislitsyn Date: Mon, 8 Jun 2020 13:21:47 +0000 (+0400) Subject: Merge branch 'develop' into global-status-expiration X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=da22119c2ffd14098611b1691dc70110431527b5;p=akkoma Merge branch 'develop' into global-status-expiration --- da22119c2ffd14098611b1691dc70110431527b5 diff --cc lib/pleroma/web/activity_pub/activity_pub.ex index 7f6b59cc6,eb73c95fe..5b519033e --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@@ -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}) @@@ -204,18 -182,10 +185,18 @@@ 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