add local move follower migration
This commit is contained in:
parent
25fc88afd6
commit
5a2bd3d379
@ -58,9 +58,6 @@ export default async (actor: CacheableRemoteUser, activity: IMove): Promise<stri
|
||||
followeeId: followee.id,
|
||||
});
|
||||
|
||||
//TODO remove this
|
||||
console.log(followings);
|
||||
|
||||
followings.forEach(async following => {
|
||||
//if follower is local
|
||||
if (!following.followerHost) {
|
||||
@ -71,13 +68,7 @@ export default async (actor: CacheableRemoteUser, activity: IMove): Promise<stri
|
||||
await deleteFollowing(follower!, followee);
|
||||
try {
|
||||
await create(follower!, followeeNew);
|
||||
} catch (e) {
|
||||
if (e instanceof IdentifiableError) {
|
||||
if (e.id === '710e8fb0-b8c3-4922-be49-d5d93d8e6a6e') return meta.errors.blocking;
|
||||
if (e.id === '3338392a-f764-498d-8855-db939dcf8c48') return meta.errors.blocked;
|
||||
}
|
||||
return e;
|
||||
}
|
||||
} catch (e) { /* empty */ }
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -7,7 +7,10 @@ import { genId } from '@/misc/gen-id.js';
|
||||
import define from '../../define.js';
|
||||
import { ApiError } from '../../error.js';
|
||||
import { apiLogger } from '../../logger.js';
|
||||
import { Users } from '@/models/index.js';
|
||||
import deleteFollowing from '@/services/following/delete.js';
|
||||
import create from '@/services/following/create.js';
|
||||
import { getUser } from '@/server/api/common/getters.js';
|
||||
import { Followings, Users } from '@/models/index.js';
|
||||
import { UserProfiles } from '@/models/index.js';
|
||||
import config from '@/config/index.js';
|
||||
import { publishMainStream } from '@/services/stream.js';
|
||||
@ -44,6 +47,11 @@ export const meta = {
|
||||
code: 'NOT_ADMIN_FORBIDDEN',
|
||||
id: '4362e8dc-731f-4ad8-a694-be2a88922a24',
|
||||
},
|
||||
noSuchUser: {
|
||||
message: 'No such user.',
|
||||
code: 'NO_SUCH_USER',
|
||||
id: 'fcd2eef9-a9b2-4c4f-8624-038099e90aa5',
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
@ -121,5 +129,23 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||
// Publish meUpdated event
|
||||
publishMainStream(user.id, 'meUpdated', iObj);
|
||||
|
||||
const followings = await Followings.findBy({
|
||||
followeeId: user.id,
|
||||
});
|
||||
|
||||
followings.forEach(async following => {
|
||||
//if follower is local
|
||||
if (!following.followerHost) {
|
||||
const follower = await getUser(following.followerId).catch(e => {
|
||||
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
|
||||
throw e;
|
||||
});
|
||||
await deleteFollowing(follower!, user);
|
||||
try {
|
||||
await create(follower!, moveTo);
|
||||
} catch (e) { /* empty */ }
|
||||
}
|
||||
});
|
||||
|
||||
return iObj;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user