forked from AkkomaGang/akkoma
ChatController: Use new oauth scope *:chats.
This commit is contained in:
parent
f77d4a302d
commit
f4cf4ae16e
3 changed files with 17 additions and 17 deletions
|
@ -33,7 +33,7 @@ def mark_as_read_operation do
|
|||
},
|
||||
security: [
|
||||
%{
|
||||
"oAuth" => ["write"]
|
||||
"oAuth" => ["write:chats"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ def mark_message_as_read_operation do
|
|||
},
|
||||
security: [
|
||||
%{
|
||||
"oAuth" => ["write"]
|
||||
"oAuth" => ["write:chats"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ def create_operation do
|
|||
},
|
||||
security: [
|
||||
%{
|
||||
"oAuth" => ["write"]
|
||||
"oAuth" => ["write:chats"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ def index_operation do
|
|||
},
|
||||
security: [
|
||||
%{
|
||||
"oAuth" => ["read"]
|
||||
"oAuth" => ["read:chats"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ def messages_operation do
|
|||
},
|
||||
security: [
|
||||
%{
|
||||
"oAuth" => ["read"]
|
||||
"oAuth" => ["read:chats"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ def post_chat_message_operation do
|
|||
},
|
||||
security: [
|
||||
%{
|
||||
"oAuth" => ["write"]
|
||||
"oAuth" => ["write:chats"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ def delete_message_operation do
|
|||
},
|
||||
security: [
|
||||
%{
|
||||
"oAuth" => ["write"]
|
||||
"oAuth" => ["write:chats"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 @@ test "it marks one message as read", %{conn: conn, user: user} 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 @@ test "it marks all messages in a chat as read", %{conn: conn, user: user} 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 @@ test "it works with an attachment", %{conn: conn, user: user} 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 @@ test "it deletes a message from the chat", %{conn: conn, user: user} 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 @@ test "it returns the messages for a given chat", %{conn: conn, user: user} 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 @@ test "it creates or returns a chat", %{conn: conn} 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 @@ test "it returns a chat", %{conn: conn, user: user} 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)
|
||||
|
|
Loading…
Reference in a new issue