This commit is contained in:
syuilo
2019-02-22 14:02:56 +09:00
parent e8d2959717
commit be3298639d
27 changed files with 98 additions and 173 deletions

View File

@ -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({