Rename SubscriptionNotificationController list and get actions to index and show

This commit is contained in:
Roman Chvanikov 2019-09-17 16:48:24 +03:00
parent a76168e743
commit 7d1773bc6b
3 changed files with 13 additions and 13 deletions

View File

@ -10,7 +10,7 @@ defmodule Pleroma.Web.PleromaAPI.SubscriptionNotificationController do
alias Pleroma.SubscriptionNotification alias Pleroma.SubscriptionNotification
alias Pleroma.Web.PleromaAPI.PleromaAPI alias Pleroma.Web.PleromaAPI.PleromaAPI
def list(%{assigns: %{user: user}} = conn, params) do def index(%{assigns: %{user: user}} = conn, params) do
notifications = PleromaAPI.get_subscription_notifications(user, params) notifications = PleromaAPI.get_subscription_notifications(user, params)
conn conn
@ -18,7 +18,7 @@ def list(%{assigns: %{user: user}} = conn, params) do
|> render("index.json", %{notifications: notifications, for: user}) |> render("index.json", %{notifications: notifications, for: user})
end end
def get(%{assigns: %{user: user}} = conn, %{"id" => id} = _params) do def show(%{assigns: %{user: user}} = conn, %{"id" => id} = _params) do
with {:ok, notification} <- SubscriptionNotification.get(user, id) do with {:ok, notification} <- SubscriptionNotification.get(user, id) do
render(conn, "show.json", %{subscription_notification: notification, for: user}) render(conn, "show.json", %{subscription_notification: notification, for: user})
else else

View File

@ -273,8 +273,8 @@ defmodule Pleroma.Web.Router do
post("/clear", SubscriptionNotificationController, :clear) post("/clear", SubscriptionNotificationController, :clear)
post("/dismiss", SubscriptionNotificationController, :dismiss) post("/dismiss", SubscriptionNotificationController, :dismiss)
delete("/destroy_multiple", SubscriptionNotificationController, :destroy_multiple) delete("/destroy_multiple", SubscriptionNotificationController, :destroy_multiple)
get("/", SubscriptionNotificationController, :list) get("/", SubscriptionNotificationController, :index)
get("/:id", SubscriptionNotificationController, :get) get("/:id", SubscriptionNotificationController, :show)
end end
end end

View File

@ -33,7 +33,7 @@ defmodule Pleroma.Web.PleromaAPI.SubscriptionNotificationControllerTest do
test "list of notifications", %{conn: conn, user: user, subscriber: subscriber} do test "list of notifications", %{conn: conn, user: user, subscriber: subscriber} do
status_text = "Hello" status_text = "Hello"
{:ok, _activity} = CommonAPI.post(user, %{"status" => status_text}) {:ok, _activity} = CommonAPI.post(user, %{"status" => status_text})
path = subscription_notification_path(conn, :list) path = subscription_notification_path(conn, :index)
conn = conn =
conn conn
@ -50,7 +50,7 @@ test "getting a single notification", %{conn: conn, user: user, subscriber: subs
{:ok, _activity} = CommonAPI.post(user, %{"status" => status_text}) {:ok, _activity} = CommonAPI.post(user, %{"status" => status_text})
[notification] = Repo.all(SubscriptionNotification) [notification] = Repo.all(SubscriptionNotification)
path = subscription_notification_path(conn, :get, notification) path = subscription_notification_path(conn, :show, notification)
conn = conn =
conn conn
@ -101,7 +101,7 @@ test "clearing all notifications also deletes them", %{
conn = conn =
build_conn() build_conn()
|> assign(:user, subscriber) |> assign(:user, subscriber)
|> get(subscription_notification_path(conn, :list)) |> get(subscription_notification_path(conn, :index))
assert json_response(conn, 200) == [] assert json_response(conn, 200) == []
@ -136,7 +136,7 @@ test "paginates notifications using min_id, since_id, max_id, and limit", %{
conn_res = conn_res =
get( get(
conn, conn,
subscription_notification_path(conn, :list, %{ subscription_notification_path(conn, :index, %{
"limit" => 2, "limit" => 2,
"min_id" => notification1_id "min_id" => notification1_id
}) })
@ -149,7 +149,7 @@ test "paginates notifications using min_id, since_id, max_id, and limit", %{
conn_res = conn_res =
get( get(
conn, conn,
subscription_notification_path(conn, :list, %{ subscription_notification_path(conn, :index, %{
"limit" => 2, "limit" => 2,
"since_id" => notification1_id "since_id" => notification1_id
}) })
@ -162,7 +162,7 @@ test "paginates notifications using min_id, since_id, max_id, and limit", %{
conn_res = conn_res =
get( get(
conn, conn,
subscription_notification_path(conn, :list, %{ subscription_notification_path(conn, :index, %{
"limit" => 2, "limit" => 2,
"max_id" => notification4_id "max_id" => notification4_id
}) })
@ -195,7 +195,7 @@ test "destroy multiple", %{conn: conn, user: user1, subscriber: user2} do
conn = assign(conn, :user, user1) conn = assign(conn, :user, user1)
conn_res = get(conn, subscription_notification_path(conn, :list)) conn_res = get(conn, subscription_notification_path(conn, :index))
result = json_response(conn_res, 200) result = json_response(conn_res, 200)
@ -205,7 +205,7 @@ test "destroy multiple", %{conn: conn, user: user1, subscriber: user2} do
conn2 = assign(conn, :user, user2) conn2 = assign(conn, :user, user2)
conn_res = get(conn2, subscription_notification_path(conn, :list)) conn_res = get(conn2, subscription_notification_path(conn, :index))
result = json_response(conn_res, 200) result = json_response(conn_res, 200)
@ -220,7 +220,7 @@ test "destroy multiple", %{conn: conn, user: user1, subscriber: user2} do
assert json_response(conn_destroy, 200) == %{} assert json_response(conn_destroy, 200) == %{}
conn_res = get(conn2, subscription_notification_path(conn, :list)) conn_res = get(conn2, subscription_notification_path(conn, :index))
result = json_response(conn_res, 200) result = json_response(conn_res, 200)