diff options
author | William Pitcock <nenolod@dereferenced.org> | 2018-11-06 22:50:43 +0000 |
---|---|---|
committer | William Pitcock <nenolod@dereferenced.org> | 2018-11-06 22:50:43 +0000 |
commit | f16c2e0b1b524fa9fc6a3733dd47e1d82f199fc7 (patch) | |
tree | 830283e427343afee9111e765e07f961ebd60a0f | |
parent | e1c40b8ca288fe689cd78a96b34276089df3babe (diff) | |
download | pleroma-f16c2e0b1b524fa9fc6a3733dd47e1d82f199fc7.tar.gz |
notification: add Notification.set_read_up_to()
-rw-r--r-- | lib/pleroma/notification.ex | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index e0dcd9823..75d7461e4 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -42,6 +42,20 @@ defmodule Pleroma.Notification do Repo.all(query) end + def set_read_up_to(%{id: user_id} = _user, id) do + query = + from( + n in Notification, + where: n.user_id == ^user_id, + where: n.id <= ^id, + update: [ + set: [seen: true] + ] + ) + + Repo.update_all(query, []) + end + def get(%{id: user_id} = _user, id) do query = from( |