mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-04-11.git
synced 2024-08-15 00:43:26 +00:00
Fix deadlock when updating notifications
This commit is contained in:
parent
02fd02d482
commit
1caf6a3298
1 changed files with 2 additions and 11 deletions
|
@ -3402,8 +3402,8 @@ post "/feed/webhook/:token" do |env|
|
||||||
views: video.views,
|
views: video.views,
|
||||||
)
|
)
|
||||||
|
|
||||||
emails = PG_DB.query_all("UPDATE users SET notifications = array_append(notifications, $1) \
|
PG_DB.query_all("UPDATE users SET feed_needs_update = true, notifications = array_append(notifications, $1) \
|
||||||
WHERE updated < $2 AND $3 = ANY(subscriptions) AND $1 <> ALL(notifications) RETURNING email",
|
WHERE updated < $2 AND $3 = ANY(subscriptions) AND $1 <> ALL(notifications)",
|
||||||
video.id, video.published, video.ucid, as: String)
|
video.id, video.published, video.ucid, as: String)
|
||||||
|
|
||||||
video_array = video.to_a
|
video_array = video.to_a
|
||||||
|
@ -3413,15 +3413,6 @@ post "/feed/webhook/:token" do |env|
|
||||||
ON CONFLICT (id) DO UPDATE SET title = $2, published = $3, \
|
ON CONFLICT (id) DO UPDATE SET title = $2, published = $3, \
|
||||||
updated = $4, ucid = $5, author = $6, length_seconds = $7, \
|
updated = $4, ucid = $5, author = $6, length_seconds = $7, \
|
||||||
live_now = $8, premiere_timestamp = $9, views = $10", args: video_array)
|
live_now = $8, premiere_timestamp = $9, views = $10", args: video_array)
|
||||||
|
|
||||||
# Update all users affected by insert
|
|
||||||
if emails.empty?
|
|
||||||
values = "'{}'"
|
|
||||||
else
|
|
||||||
values = "VALUES #{emails.map { |email| %((E'#{email.gsub({'\'' => "\\'", '\\' => "\\\\"})}')) }.join(",")}"
|
|
||||||
end
|
|
||||||
|
|
||||||
PG_DB.exec("UPDATE users SET feed_needs_update = true WHERE email = ANY(#{values})")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue