Skip to content

Commit d5f43ba

Browse files
Combine notifications endpoints and move them
1 parent e215a20 commit d5f43ba

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

src/invidious.cr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,6 @@ Invidious::Routing.get "/vi/:id/:name", Invidious::Routes::Images, :thumbnails
405405

406406
# API routes (macro)
407407
define_v1_api_routes()
408-
Invidious::Routing.get "/api/v1/auth/notifications", Invidious::Routes::API::V1::Authenticated, :notifications_get
409-
Invidious::Routing.post "/api/v1/auth/notifications", Invidious::Routes::API::V1::Authenticated, :notifications_post
410408

411409
# Video playback (macros)
412410
define_api_manifest_routes()

src/invidious/routes/api/v1/authenticated.cr

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -398,19 +398,11 @@ module Invidious::Routes::API::V1::Authenticated
398398
env.response.status_code = 204
399399
end
400400

401-
def self.notifications_get(env)
401+
def self.notifications(env)
402402
env.response.content_type = "text/event-stream"
403403

404-
topics = env.params.query["topics"]?.try &.split(",").uniq.first(1000)
405-
topics ||= [] of String
406-
407-
create_notification_stream(env, topics, CONNECTION_CHANNEL)
408-
end
409-
410-
def self.notifications_post(env)
411-
env.response.content_type = "text/event-stream"
412-
413-
topics = env.params.body["topics"]?.try &.split(",").uniq.first(1000)
404+
raw_topics = env.params.body["topics"]? || env.params.query["topics"]?
405+
topics = raw_topics.try &.split(",").uniq.first(1000)
414406
topics ||= [] of String
415407

416408
create_notification_stream(env, topics, CONNECTION_CHANNEL)

src/invidious/routing.cr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ macro define_v1_api_routes
9696
Invidious::Routing.post "/api/v1/auth/tokens/register", {{namespace}}::Authenticated, :register_token
9797
Invidious::Routing.post "/api/v1/auth/tokens/unregister", {{namespace}}::Authenticated, :unregister_token
9898

99+
Invidious::Routing.get "/api/v1/auth/notifications", {{namespace}}::Authenticated, :notifications
100+
Invidious::Routing.post "/api/v1/auth/notifications", {{namespace}}::Authenticated, :notifications
101+
99102
# Misc
100103
Invidious::Routing.get "/api/v1/stats", {{namespace}}::Misc, :stats
101104
Invidious::Routing.get "/api/v1/playlists/:plid", {{namespace}}::Misc, :get_playlist

0 commit comments

Comments
 (0)