Skip to content

Commit

Permalink
chore: replace WebhookEventType with WebhookEventTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 committed Sep 30, 2024
1 parent 849b11a commit 01326c2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/backend/src/core/QueueService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { randomUUID } from 'node:crypto';
import { Inject, Injectable } from '@nestjs/common';
import type { IActivity } from '@/core/activitypub/type.js';
import type { MiDriveFile } from '@/models/DriveFile.js';
import type { MiWebhook, WebhookEventType } from '@/models/Webhook.js';
import type { MiWebhook, WebhookEventTypes } from '@/models/Webhook.js';
import type { MiSystemWebhook, SystemWebhookEventType } from '@/models/SystemWebhook.js';
import type { Config } from '@/config.js';
import { DI } from '@/di-symbols.js';
Expand Down Expand Up @@ -463,7 +463,7 @@ export class QueueService {
@bindThis
public userWebhookDeliver(
webhook: MiWebhook,
type: WebhookEventType,
type: WebhookEventTypes,
content: unknown,
opts?: { attempts?: number },
) {
Expand Down
3 changes: 1 addition & 2 deletions packages/backend/src/models/Webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { id } from './util/id.js';
import { MiUser } from './User.js';

export const webhookEventTypes = ['mention', 'unfollow', 'follow', 'followed', 'note', 'reply', 'renote', 'reaction'] as const;
export type WebhookEventType = (typeof webhookEventTypes)[number] | `note@${string}`; // TODO: remove this line later
export type WebhookEventTypes = typeof webhookEventTypes[number] | `note@${string}`;

@Entity('webhook')
Expand Down Expand Up @@ -39,7 +38,7 @@ export class MiWebhook {
@Column('varchar', {
length: 128, array: true, default: '{}',
})
public on: WebhookEventType[];
public on: WebhookEventTypes[];

@Column('varchar', {
length: 1024,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Inject, Injectable } from '@nestjs/common';
import { Endpoint } from '@/server/api/endpoint-base.js';
import { IdService } from '@/core/IdService.js';
import type { WebhooksRepository } from '@/models/_.js';
import { webhookEventTypes, WebhookEventType } from '@/models/Webhook.js';
import { webhookEventTypes, WebhookEventTypes } from '@/models/Webhook.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
import { DI } from '@/di-symbols.js';
import { RoleService } from '@/core/RoleService.js';
Expand Down Expand Up @@ -112,7 +112,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
name: ps.name,
url: ps.url,
secret: ps.secret,
on: ps.on as WebhookEventType[],
on: ps.on as WebhookEventTypes[],
});

this.globalEventService.publishInternalEvent('webhookCreated', webhook);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { Inject, Injectable } from '@nestjs/common';
import { Endpoint } from '@/server/api/endpoint-base.js';
import type { WebhooksRepository } from '@/models/_.js';
import { webhookEventTypes, WebhookEventType } from '@/models/Webhook.js';
import { webhookEventTypes, WebhookEventTypes } from '@/models/Webhook.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
import { DI } from '@/di-symbols.js';
import { RoleService } from '@/core/RoleService.js';
Expand Down Expand Up @@ -83,7 +83,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
name: ps.name,
url: ps.url,
secret: ps.secret === null ? '' : ps.secret,
on: ps.on as WebhookEventType[],
on: ps.on as WebhookEventTypes[],
active: ps.active,
});

Expand Down

0 comments on commit 01326c2

Please sign in to comment.