diff --git a/lib/pleroma/web/api_spec/operations/pleroma_event_operation.ex b/lib/pleroma/web/api_spec/operations/pleroma_event_operation.ex index b23d1e7d52..48753f424e 100644 --- a/lib/pleroma/web/api_spec/operations/pleroma_event_operation.ex +++ b/lib/pleroma/web/api_spec/operations/pleroma_event_operation.ex @@ -76,13 +76,13 @@ def participation_requests_operation do } end - def participate_operation do + def join_operation do %Operation{ tags: ["Event actions"], summary: "Participate", security: [%{"oAuth" => ["write"]}], description: "Participate in an event", - operationId: "PleromaAPI.EventController.participate", + operationId: "PleromaAPI.EventController.join", parameters: [id_param()], requestBody: request_body( @@ -107,13 +107,13 @@ def participate_operation do } end - def unparticipate_operation do + def leave_operation do %Operation{ tags: ["Event actions"], summary: "Unparticipate", security: [%{"oAuth" => ["write"]}], description: "Delete event participation", - operationId: "PleromaAPI.EventController.unparticipate", + operationId: "PleromaAPI.EventController.leave", parameters: [id_param()], responses: %{ 200 => event_response(), @@ -123,13 +123,13 @@ def unparticipate_operation do } end - def accept_participation_request_operation do + def authorize_participation_request_operation do %Operation{ tags: ["Event actions"], summary: "Accept participation", security: [%{"oAuth" => ["write"]}], description: "Accept event participation request", - operationId: "PleromaAPI.EventController.accept_participation_request", + operationId: "PleromaAPI.EventController.authorize_participation_request", parameters: [id_param(), participant_id_param()], responses: %{ 200 => event_response(), diff --git a/lib/pleroma/web/pleroma_api/controllers/event_controller.ex b/lib/pleroma/web/pleroma_api/controllers/event_controller.ex index e25b995126..6045b2891f 100644 --- a/lib/pleroma/web/pleroma_api/controllers/event_controller.ex +++ b/lib/pleroma/web/pleroma_api/controllers/event_controller.ex @@ -27,7 +27,7 @@ defmodule Pleroma.Web.PleromaAPI.EventController do plug( :assign_participant - when action in [:accept_participation_request, :reject_participation_request] + when action in [:authorize_participation_request, :reject_participation_request] ) plug( @@ -35,10 +35,10 @@ defmodule Pleroma.Web.PleromaAPI.EventController do when action in [ :participations, :participation_requests, - :accept_participation_request, + :authorize_participation_request, :reject_participation_request, - :participate, - :unparticipate, + :join, + :leave, :export_ics ] ) @@ -48,10 +48,10 @@ defmodule Pleroma.Web.PleromaAPI.EventController do %{scopes: ["write"]} when action in [ :create, - :accept_participation_request, + :authorize_participation_request, :reject_participation_request, - :participate, - :unparticipate + :join, + :leave ] ) @@ -156,11 +156,11 @@ def participation_requests( end end - def participate(%{assigns: %{user: %{ap_id: actor}, event_activity: %{actor: actor}}} = conn, _) do + def join(%{assigns: %{user: %{ap_id: actor}, event_activity: %{actor: actor}}} = conn, _) do render_error(conn, :bad_request, "Can't join your own event") end - def participate( + def join( %{assigns: %{user: user, event_activity: activity}, body_params: params} = conn, _ ) do @@ -171,14 +171,14 @@ def participate( end end - def unparticipate( + def leave( %{assigns: %{user: %{ap_id: actor}, event_activity: %{actor: actor}}} = conn, _ ) do render_error(conn, :bad_request, "Can't leave your own event") end - def unparticipate(%{assigns: %{user: user, event_activity: activity}} = conn, _) do + def leave(%{assigns: %{user: user, event_activity: activity}} = conn, _) do with {:ok, _} <- CommonAPI.leave(user, activity.id) do conn |> put_view(StatusView) @@ -189,7 +189,7 @@ def unparticipate(%{assigns: %{user: user, event_activity: activity}} = conn, _) end end - def accept_participation_request( + def authorize_participation_request( %{ assigns: %{ user: for_user, diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index ac191cdd8e..5db3d65002 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -491,9 +491,9 @@ defmodule Pleroma.Web.Router do get("/events/:id/participation_requests", EventController, :participation_requests) post( - "/events/:id/participation_requests/:participant_id/accept", + "/events/:id/participation_requests/:participant_id/authorize", EventController, - :accept_participation_request + :authorize_participation_request ) post( @@ -502,8 +502,8 @@ defmodule Pleroma.Web.Router do :reject_participation_request ) - post("/events/:id/participate", EventController, :participate) - post("/events/:id/unparticipate", EventController, :unparticipate) + post("/events/:id/join", EventController, :join) + post("/events/:id/leave", EventController, :leave) get("/events/:id/ics", EventController, :export_ics) get("/search/location", SearchController, :location) diff --git a/test/pleroma/web/pleroma_api/controllers/event_controller_test.exs b/test/pleroma/web/pleroma_api/controllers/event_controller_test.exs index 9d3c17d42c..c43ecb7e28 100644 --- a/test/pleroma/web/pleroma_api/controllers/event_controller_test.exs +++ b/test/pleroma/web/pleroma_api/controllers/event_controller_test.exs @@ -137,7 +137,7 @@ test "don't display requests if not an author", %{conn: conn} do end end - describe "POST /api/v1/pleroma/events/:id/participate" do + describe "POST /api/v1/pleroma/events/:id/join" do setup do user = insert(:user) %{user: user, conn: conn} = oauth_access(["write"], user: user) @@ -156,7 +156,7 @@ test "joins an event", %{conn: conn} do conn = conn - |> post("/api/v1/pleroma/events/#{activity.id}/participate") + |> post("/api/v1/pleroma/events/#{activity.id}/join") assert json_response_and_validate_schema(conn, 200) @@ -177,7 +177,7 @@ test "can't participate in your own event", %{conn: conn, current_user: user} do conn = conn - |> post("/api/v1/pleroma/events/#{activity.id}/participate") + |> post("/api/v1/pleroma/events/#{activity.id}/join") assert json_response_and_validate_schema(conn, :bad_request) == %{ "error" => "Can't join your own event" @@ -185,7 +185,7 @@ test "can't participate in your own event", %{conn: conn, current_user: user} do end end - describe "POST /api/v1/pleroma/events/:id/unparticipate" do + describe "POST /api/v1/pleroma/events/:id/leave" do setup do user = insert(:user) %{user: user, conn: conn} = oauth_access(["write"], user: user) @@ -206,7 +206,7 @@ test "leaves an event", %{conn: conn, current_user: user} do conn = conn - |> post("/api/v1/pleroma/events/#{activity.id}/unparticipate") + |> post("/api/v1/pleroma/events/#{activity.id}/leave") assert json_response_and_validate_schema(conn, 200) @@ -229,7 +229,7 @@ test "can't leave event you are not participating in", %{conn: conn} do conn = conn - |> post("/api/v1/pleroma/events/#{activity.id}/unparticipate") + |> post("/api/v1/pleroma/events/#{activity.id}/leave") assert json_response_and_validate_schema(conn, :bad_request) == %{ "error" => "Not participating in the event"