mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-26 16:52:12 +05:30
Add buffer for notification channels
This commit is contained in:
parent
d197497349
commit
d6ec441c8e
@ -186,7 +186,7 @@ spawn do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
connection_channel = Channel({Bool, Channel(PQ::Notification)}).new
|
connection_channel = Channel({Bool, Channel(PQ::Notification)}).new(32)
|
||||||
spawn do
|
spawn do
|
||||||
connections = [] of Channel(PQ::Notification)
|
connections = [] of Channel(PQ::Notification)
|
||||||
|
|
||||||
|
@ -662,7 +662,7 @@ def copy_in_chunks(input, output, chunk_size = 4096)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_notification_stream(env, proxies, config, kemal_config, decrypt_function, topics, connection_channel)
|
def create_notification_stream(env, proxies, config, kemal_config, decrypt_function, topics, connection_channel)
|
||||||
connection = Channel(PQ::Notification).new
|
connection = Channel(PQ::Notification).new(8)
|
||||||
connection_channel.send({true, connection})
|
connection_channel.send({true, connection})
|
||||||
|
|
||||||
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
||||||
@ -750,6 +750,10 @@ def create_notification_stream(env, proxies, config, kemal_config, decrypt_funct
|
|||||||
video_id = notification["videoId"].as_s
|
video_id = notification["videoId"].as_s
|
||||||
published = notification["published"].as_i64
|
published = notification["published"].as_i64
|
||||||
|
|
||||||
|
if !topics.try &.includes? topic
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
video = get_video(video_id, PG_DB, proxies)
|
video = get_video(video_id, PG_DB, proxies)
|
||||||
video.published = Time.unix(published)
|
video.published = Time.unix(published)
|
||||||
response = JSON.parse(video.to_json(locale, config, Kemal.config, decrypt_function))
|
response = JSON.parse(video.to_json(locale, config, Kemal.config, decrypt_function))
|
||||||
@ -763,7 +767,6 @@ def create_notification_stream(env, proxies, config, kemal_config, decrypt_funct
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if topics.try &.includes? topic
|
|
||||||
env.response.puts "id: #{id}"
|
env.response.puts "id: #{id}"
|
||||||
env.response.puts "data: #{response.to_json}"
|
env.response.puts "data: #{response.to_json}"
|
||||||
env.response.puts
|
env.response.puts
|
||||||
@ -771,7 +774,6 @@ def create_notification_stream(env, proxies, config, kemal_config, decrypt_funct
|
|||||||
|
|
||||||
id += 1
|
id += 1
|
||||||
end
|
end
|
||||||
end
|
|
||||||
rescue ex
|
rescue ex
|
||||||
ensure
|
ensure
|
||||||
connection_channel.send({false, connection})
|
connection_channel.send({false, connection})
|
||||||
|
Loading…
Reference in New Issue
Block a user