diff options
| author | Omar Roth <omarroth@protonmail.com> | 2019-06-01 09:51:31 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@protonmail.com> | 2019-06-01 09:51:31 -0500 |
| commit | 701b5ea56134f2c8d8e8f54036b9f6467095b47b (patch) | |
| tree | e96cf7c5f6aad008176959eeaf010f0d01194658 /src | |
| parent | 86d0de4b0e6d77fb1e5772815acf67639176c0cc (diff) | |
| download | invidious-701b5ea56134f2c8d8e8f54036b9f6467095b47b.tar.gz invidious-701b5ea56134f2c8d8e8f54036b9f6467095b47b.tar.bz2 invidious-701b5ea56134f2c8d8e8f54036b9f6467095b47b.zip | |
Remove watched videos from notifications
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious.cr | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index fa4ac44d..de134947 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -350,6 +350,7 @@ get "/watch" do |env| if user subscriptions = user.subscriptions watched = user.watched + notifications = user.notifications end subscriptions ||= [] of String @@ -377,6 +378,12 @@ get "/watch" do |env| PG_DB.exec("UPDATE users SET watched = watched || $1 WHERE email = $2", [id], user.as(User).email) end + if notifications && notifications.includes? id + PG_DB.exec("UPDATE users SET notifications = array_remove(notifications, $1) WHERE email = $2", id, user.as(User).email) + env.get("user").as(User).notifications.delete(id) + notifications.delete(id) + end + if nojs if preferences source = preferences.comments[0] @@ -558,6 +565,7 @@ get "/embed/:id" do |env| if user subscriptions = user.subscriptions watched = user.watched + notifications = user.notifications end subscriptions ||= [] of String @@ -580,6 +588,12 @@ get "/embed/:id" do |env| PG_DB.exec("UPDATE users SET watched = watched || $1 WHERE email = $2", [id], user.as(User).email) end + if notifications && notifications.includes? id + PG_DB.exec("UPDATE users SET notifications = array_remove(notifications, $1) WHERE email = $2", id, user.as(User).email) + env.get("user").as(User).notifications.delete(id) + notifications.delete(id) + end + fmt_stream = video.fmt_stream(decrypt_function) adaptive_fmts = video.adaptive_fmts(decrypt_function) @@ -1696,10 +1710,10 @@ post "/subscription_ajax" do |env| when .starts_with? "action_create" if !user.subscriptions.includes? channel_id get_channel(channel_id, PG_DB, false, false) - PG_DB.exec("UPDATE users SET subscriptions = array_append(subscriptions,$1) WHERE email = $2", channel_id, email) + PG_DB.exec("UPDATE users SET subscriptions = array_append(subscriptions, $1) WHERE email = $2", channel_id, email) end when .starts_with? "action_remove" - PG_DB.exec("UPDATE users SET subscriptions = array_remove(subscriptions,$1) WHERE email = $2", channel_id, email) + PG_DB.exec("UPDATE users SET subscriptions = array_remove(subscriptions, $1) WHERE email = $2", channel_id, email) end payload = { @@ -4534,7 +4548,7 @@ delete "/api/v1/auth/subscriptions/:ucid" do |env| ucid = env.params.url["ucid"] - PG_DB.exec("UPDATE users SET subscriptions = array_remove(subscriptions,$1) WHERE email = $2", ucid, user.email) + PG_DB.exec("UPDATE users SET subscriptions = array_remove(subscriptions, $1) WHERE email = $2", ucid, user.email) payload = { "email" => user.email, "action" => "refresh", |
