2019-01-19 12:07:12 -06:00
|
|
|
import * as mongo from 'mongodb';
|
2019-02-04 20:48:08 -06:00
|
|
|
import $ from 'cafy';
|
|
|
|
import ID, { transform } from '../../../../../misc/cafy-id';
|
2018-11-01 23:47:44 -05:00
|
|
|
import define from '../../../define';
|
2019-02-01 09:16:27 -06:00
|
|
|
import * as ms from 'ms';
|
2019-01-19 12:07:12 -06:00
|
|
|
import deleteReaction from '../../../../../services/note/reaction/delete';
|
|
|
|
import { IUser } from '../../../../../models/user';
|
|
|
|
import { getValiedNote } from '../../../common/getters';
|
2016-12-28 16:49:51 -06:00
|
|
|
|
2018-07-16 14:36:44 -05:00
|
|
|
export const meta = {
|
|
|
|
desc: {
|
2018-08-28 16:59:43 -05:00
|
|
|
'ja-JP': '指定した投稿へのリアクションを取り消します。',
|
|
|
|
'en-US': 'Unreact to a note.'
|
2018-07-16 14:36:44 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
requireCredential: true,
|
|
|
|
|
2018-11-01 13:32:24 -05:00
|
|
|
kind: 'reaction-write',
|
|
|
|
|
2018-12-26 08:05:47 -06:00
|
|
|
limit: {
|
|
|
|
duration: ms('1hour'),
|
|
|
|
max: 5,
|
|
|
|
minInterval: ms('3sec')
|
|
|
|
},
|
|
|
|
|
2018-11-01 13:32:24 -05:00
|
|
|
params: {
|
|
|
|
noteId: {
|
|
|
|
validator: $.type(ID),
|
|
|
|
transform: transform,
|
2018-11-03 08:49:36 -05:00
|
|
|
desc: {
|
|
|
|
'ja-JP': '対象の投稿のID',
|
|
|
|
'en-US': 'Target note ID'
|
|
|
|
}
|
2018-11-01 13:32:24 -05:00
|
|
|
},
|
|
|
|
}
|
2018-07-16 14:36:44 -05:00
|
|
|
};
|
|
|
|
|
2019-01-19 12:07:12 -06:00
|
|
|
export default define(meta, (ps, user) => new Promise((res, rej) => {
|
|
|
|
deleteReactionById(user, ps.noteId)
|
|
|
|
.then(r => res(r)).catch(e => rej(e));
|
2018-11-01 23:47:44 -05:00
|
|
|
}));
|
2019-01-19 12:07:12 -06:00
|
|
|
|
|
|
|
async function deleteReactionById(user: IUser, noteId: mongo.ObjectID) {
|
|
|
|
const note = await getValiedNote(noteId);
|
|
|
|
await deleteReaction(user, note);
|
|
|
|
}
|