misskey-dev / misskey

🌎 A completely free and open interplanetary microblogging platform 🚀
https://misskey-hub.net/
GNU Affero General Public License v3.0
9.95k stars 1.35k forks source link

feat: UserWebhook/SystemWebhookのテスト送信機能を追加 #14489

Closed samunohito closed 3 weeks ago

samunohito commented 1 month ago

What

UserWebhookとSystemWebhookにテスト送信機能が追加されます。

Why

fix https://github.com/misskey-dev/misskey/issues/14445

Additional info (optional)

ローカルにWebサーバを立てて実際に送信確認

Checklist

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 75.20958% with 207 lines in your changes missing coverage. Please review.

Project coverage is 41.50%. Comparing base (3bf63dd) to head (81363ec). Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
...kages/frontend/src/pages/settings/webhook.edit.vue 0.00% 78 Missing :warning:
.../frontend/src/components/MkSystemWebhookEditor.vue 0.00% 66 Missing :warning:
.../server/api/endpoints/admin/system-webhook/test.ts 75.32% 19 Missing :warning:
...ackend/src/server/api/endpoints/i/webhooks/test.ts 75.00% 19 Missing :warning:
packages/backend/src/core/QueueService.ts 12.50% 14 Missing :warning:
packages/backend/src/core/WebhookTestService.ts 97.92% 9 Missing :warning:
...ntend/src/components/MkSystemWebhookEditor.impl.ts 0.00% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #14489 +/- ## ============================================ + Coverage 19.72% 41.50% +21.77% ============================================ Files 714 1543 +829 Lines 100375 197423 +97048 Branches 996 2709 +1713 ============================================ + Hits 19802 81937 +62135 - Misses 80030 114924 +34894 - Partials 543 562 +19 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

github-actions[bot] commented 1 month ago

このPRによるapi.jsonの差分

差分はこちら ```diff --- base +++ head @@ -16797,6 +16797,204 @@ } } }, + "/admin/system-webhook/test": { + "post": { + "operationId": "admin___system-webhook___test", + "summary": "admin/system-webhook/test", + "description": "No description provided.\n\n**Internal Endpoint**: This endpoint is an API for the misskey mainframe and is not intended for use by third parties.\n**Credential required**: *Yes* / **Permission**: *read:admin:system-webhook*", + "externalDocs": { + "description": "Source code", + "url": "https://github.com/misskey-dev/misskey/blob/develop/packages/backend/src/server/api/endpoints/admin/system-webhook/test.ts" + }, + "tags": [ + "webhooks" + ], + "security": [ + { + "bearerAuth": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "webhookId": { + "type": "string", + "format": "misskey:id" + }, + "type": { + "type": "string", + "enum": [ + "abuseReport", + "abuseReportResolved", + "userCreated" + ] + }, + "override": { + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "secret": { + "type": "string" + } + } + } + }, + "required": [ + "webhookId", + "type" + ] + } + } + } + }, + "responses": { + "204": { + "description": "OK (without any results)" + }, + "400": { + "description": "Client error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "NO_SUCH_WEBHOOK": { + "value": { + "error": { + "message": "No such webhook.", + "code": "NO_SUCH_WEBHOOK", + "id": "0c52149c-e913-18f8-5dc7-74870bfe0cf9" + } + } + }, + "INVALID_PARAM": { + "value": { + "error": { + "message": "Invalid param.", + "code": "INVALID_PARAM", + "id": "3d81ceae-475f-4600-b2a8-2bc116157532" + } + } + } + } + } + } + }, + "401": { + "description": "Authentication error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "CREDENTIAL_REQUIRED": { + "value": { + "error": { + "message": "Credential required.", + "code": "CREDENTIAL_REQUIRED", + "id": "1384574d-a912-4b81-8601-c7b1c4085df1" + } + } + } + } + } + } + }, + "403": { + "description": "Forbidden error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "AUTHENTICATION_FAILED": { + "value": { + "error": { + "message": "Authentication failed. Please ensure your token is correct.", + "code": "AUTHENTICATION_FAILED", + "id": "b0a7f5f8-dc2f-4171-b91f-de88ad238e14" + } + } + } + } + } + } + }, + "418": { + "description": "I'm Ai", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "I_AM_AI": { + "value": { + "error": { + "message": "You sent a request to Ai-chan, Misskey's showgirl, instead of the server.", + "code": "I_AM_AI", + "id": "60c46cd1-f23a-46b1-bebe-5d2b73951a84" + } + } + } + } + } + } + }, + "429": { + "description": "To many requests", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "RATE_LIMIT_EXCEEDED": { + "value": { + "error": { + "message": "Rate limit exceeded. Please try again later.", + "code": "RATE_LIMIT_EXCEEDED", + "id": "d5826d14-3982-4d2e-8011-b9e9f02499ef" + } + } + } + } + } + } + }, + "500": { + "description": "Internal server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "INTERNAL_ERROR": { + "value": { + "error": { + "message": "Internal error occurred. Please contact us if the error persists.", + "code": "INTERNAL_ERROR", + "id": "5d37dbcb-891e-41ca-a3d6-e690c97775ac" + } + } + } + } + } + } + } + } + } + }, "/announcements": { "post": { "operationId": "announcements", @@ -51784,6 +51982,209 @@ } } } + } + } + } + }, + "500": { + "description": "Internal server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "INTERNAL_ERROR": { + "value": { + "error": { + "message": "Internal error occurred. Please contact us if the error persists.", + "code": "INTERNAL_ERROR", + "id": "5d37dbcb-891e-41ca-a3d6-e690c97775ac" + } + } + } + } + } + } + } + } + } + }, + "/i/webhooks/test": { + "post": { + "operationId": "i___webhooks___test", + "summary": "i/webhooks/test", + "description": "No description provided.\n\n**Internal Endpoint**: This endpoint is an API for the misskey mainframe and is not intended for use by third parties.\n**Credential required**: *Yes* / **Permission**: *read:account*", + "externalDocs": { + "description": "Source code", + "url": "https://github.com/misskey-dev/misskey/blob/develop/packages/backend/src/server/api/endpoints/i/webhooks/test.ts" + }, + "tags": [ + "webhooks" + ], + "security": [ + { + "bearerAuth": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "webhookId": { + "type": "string", + "format": "misskey:id" + }, + "type": { + "type": "string", + "enum": [ + "mention", + "unfollow", + "follow", + "followed", + "note", + "reply", + "renote", + "reaction" + ] + }, + "override": { + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "secret": { + "type": "string" + } + } + } + }, + "required": [ + "webhookId", + "type" + ] + } + } + } + }, + "responses": { + "204": { + "description": "OK (without any results)" + }, + "400": { + "description": "Client error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "NO_SUCH_WEBHOOK": { + "value": { + "error": { + "message": "No such webhook.", + "code": "NO_SUCH_WEBHOOK", + "id": "0c52149c-e913-18f8-5dc7-74870bfe0cf9" + } + } + }, + "INVALID_PARAM": { + "value": { + "error": { + "message": "Invalid param.", + "code": "INVALID_PARAM", + "id": "3d81ceae-475f-4600-b2a8-2bc116157532" + } + } + } + } + } + } + }, + "401": { + "description": "Authentication error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "CREDENTIAL_REQUIRED": { + "value": { + "error": { + "message": "Credential required.", + "code": "CREDENTIAL_REQUIRED", + "id": "1384574d-a912-4b81-8601-c7b1c4085df1" + } + } + } + } + } + } + }, + "403": { + "description": "Forbidden error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "AUTHENTICATION_FAILED": { + "value": { + "error": { + "message": "Authentication failed. Please ensure your token is correct.", + "code": "AUTHENTICATION_FAILED", + "id": "b0a7f5f8-dc2f-4171-b91f-de88ad238e14" + } + } + } + } + } + } + }, + "418": { + "description": "I'm Ai", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "I_AM_AI": { + "value": { + "error": { + "message": "You sent a request to Ai-chan, Misskey's showgirl, instead of the server.", + "code": "I_AM_AI", + "id": "60c46cd1-f23a-46b1-bebe-5d2b73951a84" + } + } + } + } + } + } + }, + "429": { + "description": "To many requests", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "RATE_LIMIT_EXCEEDED": { + "value": { + "error": { + "message": "Rate limit exceeded. Please try again later.", + "code": "RATE_LIMIT_EXCEEDED", + "id": "d5826d14-3982-4d2e-8011-b9e9f02499ef" + } + } + } } } } ```

Get diff files from Workflow Page

samunohito commented 1 month ago

とりあえずは使えるのでopenにしたけど、SystemWebhookのテスト送信周りのUXにちょっと自信がない(OKおす→保存される→再度モーダルを開かないと変更した内容でのテスト送信ができない)ので、妙案募集中

samunohito commented 1 month ago

テスト送信時は設定をリクエストパラメータから上書き出来るようにする…? テスト送信を行うエンドポイント自体は認証必要になってるし、レートリミットあるし、イタズラのリスクはそこまでないはず…

samunohito commented 1 month ago

Revertできる形にしつつ↑を試します(のでdraftに)

samunohito commented 1 month ago

テスト送信時は設定をリクエストパラメータから上書き出来るようにする…?

これにしました。 urlとsecretをエンドポイントのパラメータとして引き込み、その値で送信確認できるようになりました。

syuilo commented 1 month ago

/preview

syuilo commented 1 month ago

/preview

syuilo commented 1 month ago

/preview

syuilo commented 3 weeks ago

misskey-jsのautogen生成するのどうするんだっけ

syuilo commented 3 weeks ago

autogenがない状態で pnpm build-misskey-js-with-types や pnpm build してもエラーになる

syuilo commented 3 weeks ago

TASUKETE

samunohito commented 3 weeks ago

pnpm build-misskey-js-with-types

これやればできるはずですが…いったいなにが 夜以降でよければ確認します

syuilo commented 3 weeks ago

ゔわー

samunohito commented 3 weeks ago

@syuilo たぶんなおったはず

syuilo commented 3 weeks ago

今後同様のことが起こったらどう治せばいいかしら

samunohito commented 3 weeks ago

pnpm clean -> pnpm build-misskey-js-with-types -> pnpm build のような感じでビルドしたら直りました。 ちょっと怪しいので、cloneしたてのまっさらな環境で確認したほうがいいかも…?

syuilo commented 3 weeks ago

👍🏿