2021-08-19 14:55:45 +02:00
|
|
|
import renderDelete from '@/remote/activitypub/renderer/delete';
|
|
|
|
import renderUndo from '@/remote/activitypub/renderer/undo';
|
|
|
|
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 19:03:28 +02:00
|
|
|
import { Not, IsNull } from 'typeorm';
|
|
|
|
|
|
|
|
export async function doPostUnsuspend(user: User) {
|
|
|
|
if (Users.isLocalUser(user)) {
|
|
|
|
// 知り得る全SharedInboxにUndo Delete配信
|
|
|
|
const content = renderActivity(renderUndo(renderDelete(`${config.url}/users/${user.id}`, user), user));
|
|
|
|
|
|
|
|
const queue: string[] = [];
|
|
|
|
|
|
|
|
const followings = await Followings.find({
|
|
|
|
where: [
|
|
|
|
{ followerSharedInbox: Not(IsNull()) },
|
2021-12-09 15:58:30 +01:00
|
|
|
{ followeeSharedInbox: Not(IsNull()) },
|
2019-07-17 19:03:28 +02:00
|
|
|
],
|
2021-12-09 15:58:30 +01:00
|
|
|
select: ['followerSharedInbox', 'followeeSharedInbox'],
|
2019-07-17 19:03:28 +02: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) {
|
|
|
|
deliver(user as any, content, inbox);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|