Send Delete activity on suspend (#5165)
* Send Delete Person activity * Delete activityの後にフォロー解除する * アカウント削除でもDelete activity
This commit is contained in:
parent
ef44eda69e
commit
9c4e64b7b5
|
@ -5,6 +5,7 @@ import deleteFollowing from '../../../../services/following/delete';
|
||||||
import { Users, Followings } from '../../../../models';
|
import { Users, Followings } from '../../../../models';
|
||||||
import { User } from '../../../../models/entities/user';
|
import { User } from '../../../../models/entities/user';
|
||||||
import { insertModerationLog } from '../../../../services/insert-moderation-log';
|
import { insertModerationLog } from '../../../../services/insert-moderation-log';
|
||||||
|
import { doPostSuspend } from '../../../../services/suspend-user';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -51,7 +52,10 @@ export default define(meta, async (ps, me) => {
|
||||||
targetId: user.id,
|
targetId: user.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
unFollowAll(user);
|
(async () => {
|
||||||
|
await doPostSuspend(user).catch(e => {});
|
||||||
|
await unFollowAll(user).catch(e => {});
|
||||||
|
})();
|
||||||
});
|
});
|
||||||
|
|
||||||
async function unFollowAll(follower: User) {
|
async function unFollowAll(follower: User) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { ID } from '../../../../misc/cafy-id';
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { Users } from '../../../../models';
|
import { Users } from '../../../../models';
|
||||||
import { insertModerationLog } from '../../../../services/insert-moderation-log';
|
import { insertModerationLog } from '../../../../services/insert-moderation-log';
|
||||||
|
import { doPostUnsuspend } from '../../../../services/unsuspend-user';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -40,4 +41,6 @@ export default define(meta, async (ps, me) => {
|
||||||
insertModerationLog(me, 'unsuspend', {
|
insertModerationLog(me, 'unsuspend', {
|
||||||
targetId: user.id,
|
targetId: user.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
doPostUnsuspend(user);
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,6 +3,7 @@ import * as bcrypt from 'bcryptjs';
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { Users, UserProfiles } from '../../../../models';
|
import { Users, UserProfiles } from '../../../../models';
|
||||||
import { ensure } from '../../../../prelude/ensure';
|
import { ensure } from '../../../../prelude/ensure';
|
||||||
|
import { doPostSuspend } from '../../../../services/suspend-user';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
|
@ -26,5 +27,8 @@ export default define(meta, async (ps, user) => {
|
||||||
throw new Error('incorrect password');
|
throw new Error('incorrect password');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 物理削除する前にDelete activityを送信する
|
||||||
|
await doPostSuspend(user).catch(e => {});
|
||||||
|
|
||||||
await Users.delete(user.id);
|
await Users.delete(user.id);
|
||||||
});
|
});
|
||||||
|
|
34
src/services/suspend-user.ts
Normal file
34
src/services/suspend-user.ts
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
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: User) {
|
||||||
|
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 as any, content, inbox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
35
src/services/unsuspend-user.ts
Normal file
35
src/services/unsuspend-user.ts
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
import renderDelete from '../remote/activitypub/renderer/delete';
|
||||||
|
import renderUndo from '../remote/activitypub/renderer/undo';
|
||||||
|
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 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()) },
|
||||||
|
{ 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 as any, content, inbox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue