refactor
This commit is contained in:
parent
b8f785b89d
commit
3a04c66ee1
@ -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 });
|
||||
return await DriveFiles.pack(driveFile, { self: true });
|
||||
} catch (e) {
|
||||
apiLogger.error(e);
|
||||
if (e instanceof Error || typeof e === 'string') {
|
||||
apiLogger.error(e);
|
||||
}
|
||||
throw new ApiError();
|
||||
} finally {
|
||||
cleanup!();
|
||||
|
@ -6,6 +6,7 @@ import define from '../../define';
|
||||
import { ApiError } from '../../error';
|
||||
import { getUser } from '../../common/getters';
|
||||
import { Followings, Users } from '@/models/index';
|
||||
import { IdentifiableError } from '@/misc/identifiable-error';
|
||||
|
||||
export const meta = {
|
||||
tags: ['following', 'users'],
|
||||
@ -92,8 +93,10 @@ export default define(meta, async (ps, user) => {
|
||||
try {
|
||||
await create(follower, followee);
|
||||
} catch (e) {
|
||||
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);
|
||||
if (e instanceof IdentifiableError) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import define from '../../../define';
|
||||
import { ApiError } from '../../../error';
|
||||
import { getUser } from '../../../common/getters';
|
||||
import { Users } from '@/models/index';
|
||||
import { IdentifiableError } from '@/misc/identifiable-error';
|
||||
|
||||
export const meta = {
|
||||
tags: ['following', 'account'],
|
||||
@ -51,7 +52,9 @@ export default define(meta, async (ps, user) => {
|
||||
try {
|
||||
await cancelFollowRequest(followee, user);
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user