ピン留めを解除することができるようにしたり
This commit is contained in:
parent
7b4c307c46
commit
59d67d3140
6 changed files with 128 additions and 46 deletions
|
@ -2,6 +2,7 @@ import $ from 'cafy'; import ID from '../../../../../misc/cafy-id';
|
|||
import Favorite from '../../../../../models/favorite';
|
||||
import Note from '../../../../../models/note';
|
||||
import { ILocalUser } from '../../../../../models/user';
|
||||
import getParams from '../../../get-params';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
|
@ -11,17 +12,24 @@ export const meta = {
|
|||
|
||||
requireCredential: true,
|
||||
|
||||
kind: 'favorite-write'
|
||||
kind: 'favorite-write',
|
||||
|
||||
params: {
|
||||
noteId: $.type(ID).note({
|
||||
desc: {
|
||||
'ja-JP': '対象の投稿のID'
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
||||
// Get 'noteId' parameter
|
||||
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
||||
if (noteIdErr) return rej('invalid noteId param');
|
||||
const [ps, psErr] = getParams(meta, params);
|
||||
if (psErr) return rej(psErr);
|
||||
|
||||
// Get favoritee
|
||||
const note = await Note.findOne({
|
||||
_id: noteId
|
||||
_id: ps.noteId
|
||||
});
|
||||
|
||||
if (note === null) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue