correct url

ca8ee06 · gmorell · 2026-06-11 16:29

13 files +11 -11

Files changed

modified lib/oh_my_ex_oh_ircd/irc/scrobble_serv.ex
+1 −1
@@ -408,7 +408,7 @@ defmodule OhMyExOhIrcd.IRC.ScrobbleServ do
408 408 reply(who, [
409 409 "New scrobble token for #{channel} as \"#{who_name}\" (shown once — store it now):",
410 410 " #{display}",
411 − "POST it as `Authorization: Bearer <token>` to /api/scrobble."
411 + "POST it as `Authorization: Bearer <token>` to /api/v1/scrobble."
412 412 ])
413 413
414 414 _ ->
modified lib/oh_my_ex_oh_ircd_web/live/user_live/scrobble.ex
+1 −1
@@ -273,7 +273,7 @@ defmodule OhMyExOhIrcdWeb.UserLive.Scrobble do
273 273 </form>
274 274 <p class="text-xs text-base-content/60">
275 275 Each token is bound to you and a fixed display name. POST scrobbles to
276 − <code>/api/scrobble</code>
276 + <code>/api/v1/scrobble</code>
277 277 with header <code>Authorization: Bearer &lt;token&gt;</code>
278 278 and a JSON body containing <code>artist</code> and <code>track</code>
279 279 (optional <code>album</code>).
modified lib/oh_my_ex_oh_ircd_web/router.ex
+1 −1
@@ -32,7 +32,7 @@ defmodule OhMyExOhIrcdWeb.Router do
32 32 end
33 33 end
34 34
35 − scope "/api", OhMyExOhIrcdWeb do
35 + scope "/api/v1", OhMyExOhIrcdWeb do
36 36 pipe_through :scrobble_api
37 37
38 38 post "/scrobble", ScrobbleController, :create
modified test/oh_my_ex_oh_ircd_web/controllers/scrobble_controller_test.exs
+8 −8
@@ -28,17 +28,17 @@ defmodule OhMyExOhIrcdWeb.ScrobbleControllerTest do
28 28 defp payload, do: %{"artist" => "Boards of Canada", "track" => "Roygbiv"}
29 29
30 30 test "rejects a missing token with 401", %{conn: conn} do
31 − conn = post(conn, ~p"/api/scrobble", payload())
31 + conn = post(conn, ~p"/api/v1/scrobble", payload())
32 32 assert json_response(conn, 401) == %{"error" => "unauthorized"}
33 33 end
34 34
35 35 test "rejects a bad token with 401", %{conn: conn} do
36 − conn = conn |> auth("garbage") |> post(~p"/api/scrobble", payload())
36 + conn = conn |> auth("garbage") |> post(~p"/api/v1/scrobble", payload())
37 37 assert json_response(conn, 401) == %{"error" => "unauthorized"}
38 38 end
39 39
40 40 test "rejects a missing required field with 422", %{conn: conn, token: token} do
41 − conn = conn |> auth(token) |> post(~p"/api/scrobble", %{"artist" => "y"})
41 + conn = conn |> auth(token) |> post(~p"/api/v1/scrobble", %{"artist" => "y"})
42 42 body = json_response(conn, 422)
43 43 assert body["error"] == "invalid_payload"
44 44 end
@@ -47,7 +47,7 @@ defmodule OhMyExOhIrcdWeb.ScrobbleControllerTest do
47 47 body =
48 48 conn
49 49 |> auth(token)
50 − |> post(~p"/api/scrobble", Map.put(payload(), "who", "someone-else"))
50 + |> post(~p"/api/v1/scrobble", Map.put(payload(), "who", "someone-else"))
51 51 |> json_response(422)
52 52
53 53 assert body["error"] == "invalid_payload"
@@ -58,7 +58,7 @@ defmodule OhMyExOhIrcdWeb.ScrobbleControllerTest do
58 58 body =
59 59 conn
60 60 |> auth(token)
61 − |> post(~p"/api/scrobble", Map.put(payload(), "evil", "\r\nPRIVMSG #x :hax"))
61 + |> post(~p"/api/v1/scrobble", Map.put(payload(), "evil", "\r\nPRIVMSG #x :hax"))
62 62 |> json_response(422)
63 63
64 64 assert body["error"] == "invalid_payload"
@@ -67,7 +67,7 @@ defmodule OhMyExOhIrcdWeb.ScrobbleControllerTest do
67 67
68 68 test "valid token but ScrobbleServ not joined returns 404", %{conn: conn, token: token} do
69 69 # No invite happened → config (if any) is joined: false.
70 − conn = conn |> auth(token) |> post(~p"/api/scrobble", payload())
70 + conn = conn |> auth(token) |> post(~p"/api/v1/scrobble", payload())
71 71 assert json_response(conn, 404) == %{"error" => "not_joined"}
72 72 end
73 73
@@ -75,7 +75,7 @@ defmodule OhMyExOhIrcdWeb.ScrobbleControllerTest do
75 75 {:ok, _} = Scrobbles.ensure_config(chan)
76 76 {:ok, _} = Scrobbles.set_joined(chan, true)
77 77
78 − conn = conn |> auth(token) |> post(~p"/api/scrobble", payload())
78 + conn = conn |> auth(token) |> post(~p"/api/v1/scrobble", payload())
79 79 assert json_response(conn, 200) == %{"status" => "ok"}
80 80
81 81 assert [scrobble] = Scrobbles.recent(chan, 5)
@@ -89,7 +89,7 @@ defmodule OhMyExOhIrcdWeb.ScrobbleControllerTest do
89 89 {:ok, _} = Scrobbles.set_joined(chan, true)
90 90 {:ok, _} = Scrobbles.set_enabled(chan, false)
91 91
92 − body = conn |> auth(token) |> post(~p"/api/scrobble", payload()) |> json_response(200)
92 + body = conn |> auth(token) |> post(~p"/api/v1/scrobble", payload()) |> json_response(200)
93 93 assert body == %{"status" => "ignored", "reason" => "disabled"}
94 94 assert Scrobbles.recent(chan, 5) == []
95 95 end

Parents: 6ccfeee