forked from FoundKeyGang/FoundKey
refactor
This commit is contained in:
parent
b8f785b89d
commit
3a04c66ee1
3 changed files with 12 additions and 4 deletions
|
@ -86,7 +86,9 @@ export default define(meta, async (ps, user, _, file, cleanup) => {
|
||||||
const driveFile = await addFile({ user, path: file.path, name, comment: ps.comment, folderId: ps.folderId, force: ps.force, sensitive: ps.isSensitive });
|
const driveFile = await addFile({ user, path: file.path, name, comment: ps.comment, folderId: ps.folderId, force: ps.force, sensitive: ps.isSensitive });
|
||||||
return await DriveFiles.pack(driveFile, { self: true });
|
return await DriveFiles.pack(driveFile, { self: true });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
apiLogger.error(e);
|
if (e instanceof Error || typeof e === 'string') {
|
||||||
|
apiLogger.error(e);
|
||||||
|
}
|
||||||
throw new ApiError();
|
throw new ApiError();
|
||||||
} finally {
|
} finally {
|
||||||
cleanup!();
|
cleanup!();
|
||||||
|
|
|
@ -6,6 +6,7 @@ import define from '../../define';
|
||||||
import { ApiError } from '../../error';
|
import { ApiError } from '../../error';
|
||||||
import { getUser } from '../../common/getters';
|
import { getUser } from '../../common/getters';
|
||||||
import { Followings, Users } from '@/models/index';
|
import { Followings, Users } from '@/models/index';
|
||||||
|
import { IdentifiableError } from '@/misc/identifiable-error';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['following', 'users'],
|
tags: ['following', 'users'],
|
||||||
|
@ -92,8 +93,10 @@ export default define(meta, async (ps, user) => {
|
||||||
try {
|
try {
|
||||||
await create(follower, followee);
|
await create(follower, followee);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.id === '710e8fb0-b8c3-4922-be49-d5d93d8e6a6e') throw new ApiError(meta.errors.blocking);
|
if (e instanceof IdentifiableError) {
|
||||||
if (e.id === '3338392a-f764-498d-8855-db939dcf8c48') throw new ApiError(meta.errors.blocked);
|
if (e.id === '710e8fb0-b8c3-4922-be49-d5d93d8e6a6e') throw new ApiError(meta.errors.blocking);
|
||||||
|
if (e.id === '3338392a-f764-498d-8855-db939dcf8c48') throw new ApiError(meta.errors.blocked);
|
||||||
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import define from '../../../define';
|
||||||
import { ApiError } from '../../../error';
|
import { ApiError } from '../../../error';
|
||||||
import { getUser } from '../../../common/getters';
|
import { getUser } from '../../../common/getters';
|
||||||
import { Users } from '@/models/index';
|
import { Users } from '@/models/index';
|
||||||
|
import { IdentifiableError } from '@/misc/identifiable-error';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['following', 'account'],
|
tags: ['following', 'account'],
|
||||||
|
@ -51,7 +52,9 @@ export default define(meta, async (ps, user) => {
|
||||||
try {
|
try {
|
||||||
await cancelFollowRequest(followee, user);
|
await cancelFollowRequest(followee, user);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.id === '17447091-ce07-46dd-b331-c1fd4f15b1e7') throw new ApiError(meta.errors.followRequestNotFound);
|
if (e instanceof IdentifiableError) {
|
||||||
|
if (e.id === '17447091-ce07-46dd-b331-c1fd4f15b1e7') throw new ApiError(meta.errors.followRequestNotFound);
|
||||||
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue