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