2021-08-19 12:55:45 +00:00
|
|
|
import renderDelete from '@/remote/activitypub/renderer/delete';
|
|
|
|
import { renderActivity } from '@/remote/activitypub/renderer/index';
|
|
|
|
import { deliver } from '@/queue/index';
|
|
|
|
import config from '@/config/index';
|
|
|
|
import { User } from '@/models/entities/user';
|
|
|
|
import { Users, Followings } from '@/models/index';
|
2019-07-17 17:03:28 +00:00
|
|
|
import { Not, IsNull } from 'typeorm';
|
|
|
|
|
2021-03-24 02:05:37 +00:00
|
|
|
export async function doPostSuspend(user: { id: User['id']; host: User['host'] }) {
|
2019-07-17 17:03:28 +00: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 14:58:30 +00:00
|
|
|
{ followeeSharedInbox: Not(IsNull()) },
|
2019-07-17 17:03:28 +00:00
|
|
|
],
|
2021-12-09 14:58:30 +00:00
|
|
|
select: ['followerSharedInbox', 'followeeSharedInbox'],
|
2019-07-17 17:03:28 +00: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 02:05:37 +00:00
|
|
|
deliver(user, content, inbox);
|
2019-07-17 17:03:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|