mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2025-03-13 07:02:41 +00:00
Initial functionality
This commit is contained in:
parent
251c455b91
commit
9352701ff8
2 changed files with 20 additions and 0 deletions
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue