diff options
| author | matthewmcgarvey <matthewmcgarvey14@gmail.com> | 2022-02-23 22:45:07 -0600 |
|---|---|---|
| committer | matthewmcgarvey <matthewmcgarvey14@gmail.com> | 2022-02-23 22:45:07 -0600 |
| commit | d5f43bae9222cd0ba8a418615272d3edd996a4a8 (patch) | |
| tree | 73ed0fff6badbc8da8d6747bfca4f3bdbd2dd3ad /src | |
| parent | e215a20a0ac3dd4a3141f842ec6dd90b54cb67c3 (diff) | |
| download | invidious-d5f43bae9222cd0ba8a418615272d3edd996a4a8.tar.gz invidious-d5f43bae9222cd0ba8a418615272d3edd996a4a8.tar.bz2 invidious-d5f43bae9222cd0ba8a418615272d3edd996a4a8.zip | |
Combine notifications endpoints and move them
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious.cr | 2 | ||||
| -rw-r--r-- | src/invidious/routes/api/v1/authenticated.cr | 14 | ||||
| -rw-r--r-- | src/invidious/routing.cr | 3 |
3 files changed, 6 insertions, 13 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index e32c1086..db3921f6 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -405,8 +405,6 @@ Invidious::Routing.get "/vi/:id/:name", Invidious::Routes::Images, :thumbnails # API routes (macro) define_v1_api_routes() -Invidious::Routing.get "/api/v1/auth/notifications", Invidious::Routes::API::V1::Authenticated, :notifications_get -Invidious::Routing.post "/api/v1/auth/notifications", Invidious::Routes::API::V1::Authenticated, :notifications_post # Video playback (macros) define_api_manifest_routes() diff --git a/src/invidious/routes/api/v1/authenticated.cr b/src/invidious/routes/api/v1/authenticated.cr index 6ced4edb..b559a01a 100644 --- a/src/invidious/routes/api/v1/authenticated.cr +++ b/src/invidious/routes/api/v1/authenticated.cr @@ -398,19 +398,11 @@ module Invidious::Routes::API::V1::Authenticated env.response.status_code = 204 end - def self.notifications_get(env) + def self.notifications(env) env.response.content_type = "text/event-stream" - topics = env.params.query["topics"]?.try &.split(",").uniq.first(1000) - topics ||= [] of String - - create_notification_stream(env, topics, CONNECTION_CHANNEL) - end - - def self.notifications_post(env) - env.response.content_type = "text/event-stream" - - topics = env.params.body["topics"]?.try &.split(",").uniq.first(1000) + raw_topics = env.params.body["topics"]? || env.params.query["topics"]? + topics = raw_topics.try &.split(",").uniq.first(1000) topics ||= [] of String create_notification_stream(env, topics, CONNECTION_CHANNEL) diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr index d539d891..bd72c577 100644 --- a/src/invidious/routing.cr +++ b/src/invidious/routing.cr @@ -96,6 +96,9 @@ macro define_v1_api_routes Invidious::Routing.post "/api/v1/auth/tokens/register", {{namespace}}::Authenticated, :register_token Invidious::Routing.post "/api/v1/auth/tokens/unregister", {{namespace}}::Authenticated, :unregister_token + Invidious::Routing.get "/api/v1/auth/notifications", {{namespace}}::Authenticated, :notifications + Invidious::Routing.post "/api/v1/auth/notifications", {{namespace}}::Authenticated, :notifications + # Misc Invidious::Routing.get "/api/v1/stats", {{namespace}}::Misc, :stats Invidious::Routing.get "/api/v1/playlists/:plid", {{namespace}}::Misc, :get_playlist |
