mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-25 08:53:08 +02:00
chore: ba6959b8c1
のリモート対応
This commit is contained in:
parent
46f3736f44
commit
8e2be5e9a7
2 changed files with 11 additions and 6 deletions
|
@ -66,10 +66,6 @@ export default define(meta, async (ps, user) => {
|
||||||
throw new ApiError(meta.errors.blockeeIsYourself);
|
throw new ApiError(meta.errors.blockeeIsYourself);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.isAdmin || user.isModerator) {
|
|
||||||
throw new ApiError(meta.errors.cannotBlockModerator);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get blockee
|
// Get blockee
|
||||||
const blockee = await getUser(ps.userId).catch(e => {
|
const blockee = await getUser(ps.userId).catch(e => {
|
||||||
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
|
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);
|
throw new ApiError(meta.errors.alreadyBlocking);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create blocking
|
try {
|
||||||
await create(blocker, blockee);
|
await create(blocker, blockee);
|
||||||
|
} catch (e) {
|
||||||
|
if (e.id === 'e42b7890-5e4d-9d9c-d54b-cf4dd30adfb5') throw new ApiError(meta.errors.cannotBlockModerator);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
NoteWatchings.delete({
|
NoteWatchings.delete({
|
||||||
userId: blocker.id,
|
userId: blocker.id,
|
||||||
|
|
|
@ -9,8 +9,13 @@ import { User } from '@/models/entities/user';
|
||||||
import { Blockings, Users, FollowRequests, Followings, UserListJoinings, UserLists } from '@/models/index';
|
import { Blockings, Users, FollowRequests, Followings, UserListJoinings, UserLists } from '@/models/index';
|
||||||
import { perUserFollowingChart } from '@/services/chart/index';
|
import { perUserFollowingChart } from '@/services/chart/index';
|
||||||
import { genId } from '@/misc/gen-id';
|
import { genId } from '@/misc/gen-id';
|
||||||
|
import { IdentifiableError } from '@/misc/identifiable-error';
|
||||||
|
|
||||||
export default async function(blocker: User, blockee: User) {
|
export default async function(blocker: User, blockee: User) {
|
||||||
|
if (blockee.isAdmin || blockee.isModerator) {
|
||||||
|
throw new IdentifiableError('e42b7890-5e4d-9d9c-d54b-cf4dd30adfb5');
|
||||||
|
}
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
cancelRequest(blocker, blockee),
|
cancelRequest(blocker, blockee),
|
||||||
cancelRequest(blockee, blocker),
|
cancelRequest(blockee, blocker),
|
||||||
|
|
Loading…
Reference in a new issue