diff options
author | lain <lain@soykaf.club> | 2020-06-02 14:49:56 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-06-02 14:50:10 +0200 |
commit | 38dce485c47e9315663c5c9cfd67dab4164b1bbe (patch) | |
tree | b8dfaf11e099a12044c49e451c098f9a978d5e0e /lib | |
parent | 904295d53b82fcfd7dfefd4c970815b36f06faf0 (diff) | |
download | pleroma-38dce485c47e9315663c5c9cfd67dab4164b1bbe.tar.gz |
Notification: Add function to backfill notification types
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/notification.ex | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index 41ac53505..c8b964400 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -37,6 +37,26 @@ defmodule Pleroma.Notification do timestamps() end + def fill_in_notification_types() do + query = + from(n in __MODULE__, + where: is_nil(n.type), + preload: :activity + ) + + query + |> Repo.all() + |> Enum.each(fn notification -> + type = + notification.activity + |> type_from_activity() + + notification + |> changeset(%{type: type}) + |> Repo.update() + end) + end + def update_notification_type(user, activity) do with %__MODULE__{} = notification <- Repo.get_by(__MODULE__, user_id: user.id, activity_id: activity.id) do |