mirror of
https://iceshrimp.dev/iceshrimp/iceshrimp
synced 2024-12-24 19:48:08 +09:00
4d341c5918
* wip * wip * wip * wip * wip * Update define.ts * Update update.ts * Update user.ts * wip * wip * Update request.ts * URL * wip * wip * wip * wip * Update invite.ts * Update create.ts
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import renderDelete from '../remote/activitypub/renderer/delete';
|
|
import { renderActivity } from '../remote/activitypub/renderer';
|
|
import { deliver } from '../queue';
|
|
import config from '@/config';
|
|
import { User } from '../models/entities/user';
|
|
import { Users, Followings } from '../models';
|
|
import { Not, IsNull } from 'typeorm';
|
|
|
|
export async function doPostSuspend(user: { id: User['id']; host: User['host'] }) {
|
|
if (Users.isLocalUser(user)) {
|
|
// 知り得る全SharedInboxにDelete配信
|
|
const content = renderActivity(renderDelete(`${config.url}/users/${user.id}`, user));
|
|
|
|
const queue: string[] = [];
|
|
|
|
const followings = await Followings.find({
|
|
where: [
|
|
{ followerSharedInbox: Not(IsNull()) },
|
|
{ followeeSharedInbox: Not(IsNull()) }
|
|
],
|
|
select: ['followerSharedInbox', 'followeeSharedInbox']
|
|
});
|
|
|
|
const inboxes = followings.map(x => x.followerSharedInbox || x.followeeSharedInbox);
|
|
|
|
for (const inbox of inboxes) {
|
|
if (inbox != null && !queue.includes(inbox)) queue.push(inbox);
|
|
}
|
|
|
|
for (const inbox of queue) {
|
|
deliver(user, content, inbox);
|
|
}
|
|
}
|
|
}
|