# - Increase replies count
# - Set up ActivityExpiration
# - Set up notifications
+ # - Index incoming posts for search (if needed)
@impl true
def handle(%{data: %{"type" => "Create"}} = activity, meta) do
with {:ok, object, meta} <- handle_object_creation(meta[:object_data], activity, meta),
%User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do
{:ok, notifications} = Notification.create_notifications(activity, do_send: false)
{:ok, _user} = ActivityPub.increase_note_count_if_public(user, object)
+ {:ok, _user} = ActivityPub.update_last_status_at_if_public(user, object)
- if in_reply_to = object.data["inReplyTo"] && object.data["type"] != "Answer" do
+ if in_reply_to = object.data["type"] != "Answer" && object.data["inReplyTo"] do
Object.increase_replies_count(in_reply_to)
end
Task.start(fn -> Pleroma.Web.RichMedia.Helpers.fetch_data_for_activity(activity) end)
end)
+ Pleroma.Search.add_to_index(Map.put(activity, :object, object))
+
meta =
meta
|> add_notifications(notifications)
def handle(%{data: %{"type" => "EmojiReact"}} = object, meta) do
reacted_object = Object.get_by_ap_id(object.data["object"])
Utils.add_emoji_reaction_to_object(object, reacted_object)
-
Notification.create_notifications(object)
{:ok, object, meta}
# - Reduce the user note count
# - Reduce the reply count
# - Stream out the activity
+ # - Removes posts from search index (if needed)
@impl true
def handle(%{data: %{"type" => "Delete", "object" => deleted_object}} = object, meta) do
deleted_object =
if result == :ok do
Notification.create_notifications(object)
+
+ # Only remove from index when deleting actual objects, not users or anything else
+ with %Pleroma.Object{} <- deleted_object do
+ Pleroma.Search.remove_from_index(deleted_object)
+ end
+
{:ok, object, meta}
else
{:error, result}
end
@impl true
+ def handle_after_transaction(%Pleroma.Activity{data: %{"type" => "Create"}} = activity) do
+ Pleroma.Elasticsearch.put_by_id(:activity, activity.id)
+ end
+
+ def handle_after_transaction(%Pleroma.Activity{
+ data: %{"type" => "Delete", "deleted_activity_id" => id}
+ }) do
+ Pleroma.Elasticsearch.delete_by_id(:activity, id)
+ end
+
+ def handle_after_transaction(%Pleroma.Activity{}) do
+ :ok
+ end
+
+ def handle_after_transaction(%Pleroma.Object{}) do
+ :ok
+ end
+
def handle_after_transaction(meta) do
meta
|> send_notifications()