2022-02-27 11:07:39 +09:00
|
|
|
import renderDelete from '@/remote/activitypub/renderer/delete.js';
|
|
|
|
import { renderActivity } from '@/remote/activitypub/renderer/index.js';
|
|
|
|
import { deliver } from '@/queue/index.js';
|
|
|
|
import config from '@/config/index.js';
|
|
|
|
import { User } from '@/models/entities/user.js';
|
|
|
|
import { Users, Followings } from '@/models/index.js';
|
2019-07-18 02:03:28 +09:00
|
|
|
import { Not, IsNull } from 'typeorm';
|
2022-03-25 16:35:24 +09:00
|
|
|
import { publishInternalEvent } from '@/services/stream.js';
|
2019-07-18 02:03:28 +09:00
|
|
|
|
2021-03-24 11:05:37 +09:00
|
|
|
export async function doPostSuspend(user: { id: User['id']; host: User['host'] }) {
|
2022-03-25 16:27:41 +09:00
|
|
|
publishInternalEvent('userChangeSuspendedState', { id: user.id, isSuspended: true });
|
|
|
|
|
2019-07-18 02:03:28 +09:00
|
|
|
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()) },
|
2021-12-09 23:58:30 +09:00
|
|
|
{ followeeSharedInbox: Not(IsNull()) },
|
2019-07-18 02:03:28 +09:00
|
|
|
],
|
2021-12-09 23:58:30 +09:00
|
|
|
select: ['followerSharedInbox', 'followeeSharedInbox'],
|
2019-07-18 02:03:28 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
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) {
|
2021-03-24 11:05:37 +09:00
|
|
|
deliver(user, content, inbox);
|
2019-07-18 02:03:28 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|