UserWebhookPayload<'followed'> 修正

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
eternal-flame-AD 2024-11-11 18:08:40 -06:00
parent f60335c043
commit fd2fa3ca9e
No known key found for this signature in database
3 changed files with 17 additions and 14 deletions

View file

@ -469,10 +469,10 @@ export class QueueService {
* @see UserWebhookDeliverProcessorService
*/
@bindThis
public userWebhookDeliver(
public userWebhookDeliver<T extends WebhookEventTypes>(
webhook: MiWebhook,
type: typeof webhookEventTypes[number],
content: UserWebhookPayload<WebhookEventTypes>,
type: T,
content: UserWebhookPayload<T>,
opts?: { attempts?: number },
) {
const data: UserWebhookDeliverJobData = {

View file

@ -17,8 +17,11 @@ export type UserWebhookPayload<T extends WebhookEventTypes> =
T extends 'note' | 'reply' | 'renote' |'mention' ? {
note: Packed<'Note'>,
} :
T extends 'follow' | 'followed' | 'unfollow' ? {
user: Packed<'User'>,
T extends 'follow' | 'unfollow' ? {
user: Packed<'UserDetailedNotMe'>,
} :
T extends 'followed' ? {
user: Packed<'UserLite'>,
} : never;
@Injectable()

View file

@ -321,7 +321,7 @@ export class WebhookTestService {
}
const webhook = webhooks[0];
const send = <U extends WebhookEventTypes>(contents: UserWebhookPayload<U>) => {
const send = <U extends WebhookEventTypes>(type: U, contents: UserWebhookPayload<U>) => {
const merged = {
...webhook,
...params.override,
@ -329,7 +329,7 @@ export class WebhookTestService {
// テスト目的なのでUserWebhookServiceの機能を経由せず直接キューに追加するチェック処理などをスキップする意図.
// また、Jobの試行回数も1回だけ.
this.queueService.userWebhookDeliver(merged, params.type, contents, { attempts: 1 });
this.queueService.userWebhookDeliver(merged, type, contents, { attempts: 1 });
};
const dummyNote1 = generateDummyNote({
@ -361,31 +361,31 @@ export class WebhookTestService {
switch (params.type) {
case 'note': {
send({ note: toPackedNote(dummyNote1) });
send('note', { note: toPackedNote(dummyNote1) });
break;
}
case 'reply': {
send({ note: toPackedNote(dummyReply1) });
send('reply', { note: toPackedNote(dummyReply1) });
break;
}
case 'renote': {
send({ note: toPackedNote(dummyRenote1) });
send('renote', { note: toPackedNote(dummyRenote1) });
break;
}
case 'mention': {
send({ note: toPackedNote(dummyMention1) });
send('mention', { note: toPackedNote(dummyMention1) });
break;
}
case 'follow': {
send({ user: toPackedUserDetailedNotMe(dummyUser1) });
send('follow', { user: toPackedUserDetailedNotMe(dummyUser1) });
break;
}
case 'followed': {
send({ user: toPackedUserDetailedNotMe(dummyUser2) });
send('followed', { user: toPackedUserLite(dummyUser2) });
break;
}
case 'unfollow': {
send({ user: toPackedUserDetailedNotMe(dummyUser3) });
send('unfollow', { user: toPackedUserDetailedNotMe(dummyUser3) });
break;
}
// まだ実装されていない (#9485)