forked from AkkomaGang/akkoma
notification: add Notification.set_read_up_to()
This commit is contained in:
parent
e1c40b8ca2
commit
f16c2e0b1b
1 changed files with 14 additions and 0 deletions
|
@ -42,6 +42,20 @@ def for_user(user, opts \\ %{}) do
|
||||||
Repo.all(query)
|
Repo.all(query)
|
||||||
end
|
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
|
def get(%{id: user_id} = _user, id) do
|
||||||
query =
|
query =
|
||||||
from(
|
from(
|
||||||
|
|
Loading…
Reference in a new issue