Refactor
This commit is contained in:
@ -11,6 +11,7 @@ import { publishMessagingStream, publishMessagingIndexStream } from '../../../..
|
||||
import pushSw from '../../../../../services/push-notification';
|
||||
import define from '../../../define';
|
||||
import { ApiError } from '../../../error';
|
||||
import { getUser } from '../../../common/getters';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
@ -76,18 +77,11 @@ export default define(meta, async (ps, user) => {
|
||||
}
|
||||
|
||||
// Fetch recipient
|
||||
const recipient = await User.findOne({
|
||||
_id: ps.userId
|
||||
}, {
|
||||
fields: {
|
||||
_id: true
|
||||
}
|
||||
const recipient = await getUser(ps.userId).catch(e => {
|
||||
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
|
||||
throw e;
|
||||
});
|
||||
|
||||
if (recipient === null) {
|
||||
throw new ApiError(meta.errors.noSuchUser);
|
||||
}
|
||||
|
||||
let file = null;
|
||||
if (ps.fileId != null) {
|
||||
file = await DriveFile.findOne({
|
||||
|
Reference in New Issue
Block a user