X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fpleroma%2Fmigration_helper%2Fnotification_backfill.ex;h=75d20a40207056341ea39a794673a49dd1b6f7d4;hb=63f2d1cbefccf5107ee5e5a7170ee4379cac6cd2;hp=d260e62cacde990436e314027b3d308619013354;hpb=55562ca9362d66553ea3638c91174bbeb6c637f1;p=akkoma
diff --git a/lib/pleroma/migration_helper/notification_backfill.ex b/lib/pleroma/migration_helper/notification_backfill.ex
index d260e62ca..75d20a402 100644
--- a/lib/pleroma/migration_helper/notification_backfill.ex
+++ b/lib/pleroma/migration_helper/notification_backfill.ex
@@ -1,9 +1,8 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.MigrationHelper.NotificationBackfill do
- alias Pleroma.Object
alias Pleroma.Repo
alias Pleroma.User
@@ -19,13 +18,13 @@ defmodule Pleroma.MigrationHelper.NotificationBackfill do
query
|> Repo.chunk_stream(100)
|> Enum.each(fn notification ->
- type =
- notification.activity
- |> type_from_activity()
+ if notification.activity do
+ type = type_from_activity(notification.activity)
- notification
- |> Ecto.Changeset.change(%{type: type})
- |> Repo.update()
+ notification
+ |> Ecto.Changeset.change(%{type: type})
+ |> Repo.update()
+ end
end)
end
@@ -72,22 +71,12 @@ defmodule Pleroma.MigrationHelper.NotificationBackfill do
"pleroma:emoji_reaction"
"Create" ->
- activity
- |> type_from_activity_object()
+ type_from_activity_object(activity)
t ->
raise "No notification type for activity type #{t}"
end
end
- defp type_from_activity_object(%{data: %{"type" => "Create", "object" => %{}}}), do: "mention"
-
- defp type_from_activity_object(%{data: %{"type" => "Create"}} = activity) do
- object = Object.get_by_ap_id(activity.data["object"])
-
- case object && object.data["type"] do
- "ChatMessage" -> "pleroma:chat_mention"
- _ -> "mention"
- end
- end
+ defp type_from_activity_object(%{data: %{"type" => "Create"}}), do: "mention"
end