chore: ba6959b8c1 のリモート対応

This commit is contained in:
syuilo 2021-10-14 01:55:39 +09:00
parent ff11db26a3
commit 31af6762b8
2 changed files with 11 additions and 6 deletions

View file

@ -66,10 +66,6 @@ export default define(meta, async (ps, user) => {
throw new ApiError(meta.errors.blockeeIsYourself);
}
if (user.isAdmin || user.isModerator) {
throw new ApiError(meta.errors.cannotBlockModerator);
}
// Get blockee
const blockee = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
@ -86,8 +82,12 @@ export default define(meta, async (ps, user) => {
throw new ApiError(meta.errors.alreadyBlocking);
}
// Create blocking
await create(blocker, blockee);
try {
await create(blocker, blockee);
} catch (e) {
if (e.id === 'e42b7890-5e4d-9d9c-d54b-cf4dd30adfb5') throw new ApiError(meta.errors.cannotBlockModerator);
throw e;
}
NoteWatchings.delete({
userId: blocker.id,

View file

@ -9,8 +9,13 @@ import { User } from '@/models/entities/user';
import { Blockings, Users, FollowRequests, Followings, UserListJoinings, UserLists } from '@/models/index';
import { perUserFollowingChart } from '@/services/chart/index';
import { genId } from '@/misc/gen-id';
import { IdentifiableError } from '@/misc/identifiable-error';
export default async function(blocker: User, blockee: User) {
if (blockee.isAdmin || blockee.isModerator) {
throw new IdentifiableError('e42b7890-5e4d-9d9c-d54b-cf4dd30adfb5');
}
await Promise.all([
cancelRequest(blocker, blockee),
cancelRequest(blockee, blocker),