Initial functionality

This commit is contained in:
Mark Felder 2024-01-29 15:15:40 -05:00
parent 251c455b91
commit 9352701ff8
2 changed files with 20 additions and 0 deletions

View file

@ -913,6 +913,8 @@ config :pleroma, Pleroma.Application,
config :pleroma, Pleroma.Uploaders.Uploader, timeout: 30_000
config :pleroma, Pleroma.Notification, keep: 50
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env()}.exs"

View file

@ -748,4 +748,22 @@ defmodule Pleroma.Notification do
)
|> Repo.update_all(set: [seen: true])
end
@spec expunge_read(User.t()) :: :ok
def expunge_read(user) do
keep_count = Pleroma.Config.get([__MODULE__, :keep])
old_notifs =
from(n in Notification,
where: n.user_id == ^user.id,
where: n.seen == true,
order_by: [desc: :id]
)
|> Repo.all()
|> Enum.drop(keep_count)
Repo.transaction(fn ->
Enum.each(old_notifs, &Repo.delete(&1))
end)
end
end