ChatController: Use new oauth scope *:chats.

This commit is contained in:
lain 2020-06-06 16:48:02 +02:00
parent f77d4a302d
commit f4cf4ae16e
3 changed files with 17 additions and 17 deletions

View file

@ -33,7 +33,7 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
},
security: [
%{
"oAuth" => ["write"]
"oAuth" => ["write:chats"]
}
]
}
@ -58,7 +58,7 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
},
security: [
%{
"oAuth" => ["write"]
"oAuth" => ["write:chats"]
}
]
}
@ -120,7 +120,7 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
},
security: [
%{
"oAuth" => ["write"]
"oAuth" => ["write:chats"]
}
]
}
@ -137,7 +137,7 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
},
security: [
%{
"oAuth" => ["read"]
"oAuth" => ["read:chats"]
}
]
}
@ -161,7 +161,7 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
},
security: [
%{
"oAuth" => ["read"]
"oAuth" => ["read:chats"]
}
]
}
@ -187,7 +187,7 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
},
security: [
%{
"oAuth" => ["write"]
"oAuth" => ["write:chats"]
}
]
}
@ -212,7 +212,7 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
},
security: [
%{
"oAuth" => ["write"]
"oAuth" => ["write:chats"]
}
]
}

View file

@ -23,7 +23,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do
plug(
OAuthScopesPlug,
%{scopes: ["write:statuses"]}
%{scopes: ["write:chats"]}
when action in [
:post_chat_message,
:create,
@ -35,7 +35,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do
plug(
OAuthScopesPlug,
%{scopes: ["read:statuses"]} when action in [:messages, :index, :show]
%{scopes: ["read:chats"]} when action in [:messages, :index, :show]
)
plug(OpenApiSpex.Plug.CastAndValidate, render_error: Pleroma.Web.ApiSpec.RenderError)

View file

@ -14,7 +14,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
import Pleroma.Factory
describe "POST /api/v1/pleroma/chats/:id/messages/:message_id/read" do
setup do: oauth_access(["write:statuses"])
setup do: oauth_access(["write:chats"])
test "it marks one message as read", %{conn: conn, user: user} do
other_user = insert(:user)
@ -41,7 +41,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
end
describe "POST /api/v1/pleroma/chats/:id/read" do
setup do: oauth_access(["write:statuses"])
setup do: oauth_access(["write:chats"])
test "it marks all messages in a chat as read", %{conn: conn, user: user} do
other_user = insert(:user)
@ -68,7 +68,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
end
describe "POST /api/v1/pleroma/chats/:id/messages" do
setup do: oauth_access(["write:statuses"])
setup do: oauth_access(["write:chats"])
test "it posts a message to the chat", %{conn: conn, user: user} do
other_user = insert(:user)
@ -125,7 +125,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
end
describe "DELETE /api/v1/pleroma/chats/:id/messages/:message_id" do
setup do: oauth_access(["write:statuses"])
setup do: oauth_access(["write:chats"])
test "it deletes a message from the chat", %{conn: conn, user: user} do
recipient = insert(:user)
@ -169,7 +169,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
end
describe "GET /api/v1/pleroma/chats/:id/messages" do
setup do: oauth_access(["read:statuses"])
setup do: oauth_access(["read:chats"])
test "it paginates", %{conn: conn, user: user} do
recipient = insert(:user)
@ -229,7 +229,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
end
describe "POST /api/v1/pleroma/chats/by-account-id/:id" do
setup do: oauth_access(["write:statuses"])
setup do: oauth_access(["write:chats"])
test "it creates or returns a chat", %{conn: conn} do
other_user = insert(:user)
@ -244,7 +244,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
end
describe "GET /api/v1/pleroma/chats/:id" do
setup do: oauth_access(["read:statuses"])
setup do: oauth_access(["read:chats"])
test "it returns a chat", %{conn: conn, user: user} do
other_user = insert(:user)
@ -261,7 +261,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
end
describe "GET /api/v1/pleroma/chats" do
setup do: oauth_access(["read:statuses"])
setup do: oauth_access(["read:chats"])
test "it does not return chats with users you blocked", %{conn: conn, user: user} do
recipient = insert(:user)