projects
/
akkoma
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e1c40b8
)
notification: add Notification.set_read_up_to()
author
William Pitcock
<nenolod@dereferenced.org>
Tue, 6 Nov 2018 22:50:43 +0000
(22:50 +0000)
committer
William Pitcock
<nenolod@dereferenced.org>
Tue, 6 Nov 2018 22:50:43 +0000
(22:50 +0000)
lib/pleroma/notification.ex
patch
|
blob
|
history
diff --git
a/lib/pleroma/notification.ex
b/lib/pleroma/notification.ex
index e0dcd98236eb8984a4b2b36ae13b15b65d4d97b4..75d7461e41dcce52120560cd4112a6af135b2e47 100644
(file)
--- 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(