diff options
| author | おさむのひと <46447427+samunohito@users.noreply.github.com> | 2024-09-19 17:20:50 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-19 17:20:50 +0900 |
| commit | 4ac8aad50a1a1ef2ac2a13a04baca445294397ed (patch) | |
| tree | 37a81a7ca6a760dc0be88b61f409c4d24354d3ca /packages/backend/src/core/UserWebhookService.ts | |
| parent | fix(frontend): viteの一時ファイルがgitの変更に含まれないよ... (diff) | |
| download | sharkey-4ac8aad50a1a1ef2ac2a13a04baca445294397ed.tar.gz sharkey-4ac8aad50a1a1ef2ac2a13a04baca445294397ed.tar.bz2 sharkey-4ac8aad50a1a1ef2ac2a13a04baca445294397ed.zip | |
feat: UserWebhook/SystemWebhookのテスト送信機能を追加 (#14489)
* feat: UserWebhook/SystemWebhookのテスト送信機能を追加
* fix CHANGELOG.md
* 一部設定をパラメータから上書き出来るように修正
* remove async
* regenerate autogen
Diffstat (limited to 'packages/backend/src/core/UserWebhookService.ts')
| -rw-r--r-- | packages/backend/src/core/UserWebhookService.ts | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/packages/backend/src/core/UserWebhookService.ts b/packages/backend/src/core/UserWebhookService.ts index e96bfeea95..8a40a53688 100644 --- a/packages/backend/src/core/UserWebhookService.ts +++ b/packages/backend/src/core/UserWebhookService.ts @@ -5,8 +5,8 @@ import { Inject, Injectable } from '@nestjs/common'; import * as Redis from 'ioredis'; -import type { WebhooksRepository } from '@/models/_.js'; -import type { MiWebhook } from '@/models/Webhook.js'; +import { type WebhooksRepository } from '@/models/_.js'; +import { MiWebhook } from '@/models/Webhook.js'; import { DI } from '@/di-symbols.js'; import { bindThis } from '@/decorators.js'; import { GlobalEvents } from '@/core/GlobalEventService.js'; @@ -38,6 +38,31 @@ export class UserWebhookService implements OnApplicationShutdown { return this.activeWebhooks; } + /** + * UserWebhook の一覧を取得する. + */ + @bindThis + public fetchWebhooks(params?: { + ids?: MiWebhook['id'][]; + isActive?: MiWebhook['active']; + on?: MiWebhook['on']; + }): Promise<MiWebhook[]> { + const query = this.webhooksRepository.createQueryBuilder('webhook'); + if (params) { + if (params.ids && params.ids.length > 0) { + query.andWhere('webhook.id IN (:...ids)', { ids: params.ids }); + } + if (params.isActive !== undefined) { + query.andWhere('webhook.active = :isActive', { isActive: params.isActive }); + } + if (params.on && params.on.length > 0) { + query.andWhere(':on <@ webhook.on', { on: params.on }); + } + } + + return query.getMany(); + } + @bindThis private async onMessage(_: string, data: string): Promise<void> { const obj = JSON.parse(data); |