mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-18 07:58:56 +01:00
33 lines
602 B
TypeScript
33 lines
602 B
TypeScript
|
/**
|
||
|
* Module dependencies
|
||
|
*/
|
||
|
import $ from 'cafy';
|
||
|
import Note, { pack } from '../../../../models/note';
|
||
|
|
||
|
/**
|
||
|
* Show a note
|
||
|
*
|
||
|
* @param {any} params
|
||
|
* @param {any} user
|
||
|
* @return {Promise<any>}
|
||
|
*/
|
||
|
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||
|
// Get 'noteId' parameter
|
||
|
const [noteId, noteIdErr] = $(params.noteId).id().$;
|
||
|
if (noteIdErr) return rej('invalid noteId param');
|
||
|
|
||
|
// Get note
|
||
|
const note = await Note.findOne({
|
||
|
_id: noteId
|
||
|
});
|
||
|
|
||
|
if (note === null) {
|
||
|
return rej('note not found');
|
||
|
}
|
||
|
|
||
|
// Serialize
|
||
|
res(await pack(note, user, {
|
||
|
detail: true
|
||
|
}));
|
||
|
});
|