feat: Webhook (#8457)
* feat: introduce webhook * wip * wip * wip * Update CHANGELOG.md
This commit is contained in:
@ -15,6 +15,8 @@ import { genId } from '@/misc/gen-id.js';
|
||||
import { createNotification } from '../create-notification.js';
|
||||
import { isDuplicateKeyValueError } from '@/misc/is-duplicate-key-value-error.js';
|
||||
import { Packed } from '@/misc/schema.js';
|
||||
import { getActiveWebhooks } from '@/misc/webhook-cache.js';
|
||||
import { webhookDeliver } from '@/queue/index.js';
|
||||
|
||||
const logger = new Logger('following/create');
|
||||
|
||||
@ -89,15 +91,33 @@ export async function insertFollowingDoc(followee: { id: User['id']; host: User[
|
||||
if (Users.isLocalUser(follower)) {
|
||||
Users.pack(followee.id, follower, {
|
||||
detail: true,
|
||||
}).then(packed => {
|
||||
}).then(async packed => {
|
||||
publishUserEvent(follower.id, 'follow', packed as Packed<"UserDetailedNotMe">);
|
||||
publishMainStream(follower.id, 'follow', packed as Packed<"UserDetailedNotMe">);
|
||||
|
||||
const webhooks = (await getActiveWebhooks()).filter(x => x.userId === follower.id && x.on.includes('follow'));
|
||||
for (const webhook of webhooks) {
|
||||
webhookDeliver(webhook, {
|
||||
type: 'follow',
|
||||
user: packed,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Publish followed event
|
||||
if (Users.isLocalUser(followee)) {
|
||||
Users.pack(follower.id, followee).then(packed => publishMainStream(followee.id, 'followed', packed));
|
||||
Users.pack(follower.id, followee).then(async packed => {
|
||||
publishMainStream(followee.id, 'followed', packed)
|
||||
|
||||
const webhooks = (await getActiveWebhooks()).filter(x => x.userId === followee.id && x.on.includes('followed'));
|
||||
for (const webhook of webhooks) {
|
||||
webhookDeliver(webhook, {
|
||||
type: 'followed',
|
||||
user: packed,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 通知を作成
|
||||
createNotification(followee.id, 'follow', {
|
||||
|
Reference in New Issue
Block a user