summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/notes/reposts.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-11-02 03:32:24 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-11-02 03:32:24 +0900
commit931bdc6aace5e7aa71ffdfb470e208ead78a2a53 (patch)
treeeee6d7bf5f5480b883bb601517b4d9db03f31e9f /src/server/api/endpoints/notes/reposts.ts
parentRefactoring (diff)
downloadsharkey-931bdc6aace5e7aa71ffdfb470e208ead78a2a53.tar.gz
sharkey-931bdc6aace5e7aa71ffdfb470e208ead78a2a53.tar.bz2
sharkey-931bdc6aace5e7aa71ffdfb470e208ead78a2a53.zip
Refactoring, Clean up and bug fixes
Diffstat (limited to 'src/server/api/endpoints/notes/reposts.ts')
-rw-r--r--src/server/api/endpoints/notes/reposts.ts66
1 files changed, 0 insertions, 66 deletions
diff --git a/src/server/api/endpoints/notes/reposts.ts b/src/server/api/endpoints/notes/reposts.ts
deleted file mode 100644
index 2c6e1a499f..0000000000
--- a/src/server/api/endpoints/notes/reposts.ts
+++ /dev/null
@@ -1,66 +0,0 @@
-import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
-import Note, { packMany } from '../../../../models/note';
-import { ILocalUser } from '../../../../models/user';
-
-/**
- * Show a renotes of a note
- */
-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');
-
- // Get 'limit' parameter
- const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
- if (limitErr) return rej('invalid limit param');
-
- // Get 'sinceId' parameter
- const [sinceId, sinceIdErr] = $.type(ID).optional.get(params.sinceId);
- if (sinceIdErr) return rej('invalid sinceId param');
-
- // Get 'untilId' parameter
- const [untilId, untilIdErr] = $.type(ID).optional.get(params.untilId);
- if (untilIdErr) return rej('invalid untilId param');
-
- // Check if both of sinceId and untilId is specified
- if (sinceId && untilId) {
- return rej('cannot set sinceId and untilId');
- }
-
- // Lookup note
- const note = await Note.findOne({
- _id: noteId
- });
-
- if (note === null) {
- return rej('note not found');
- }
-
- // Construct query
- const sort = {
- _id: -1
- };
- const query = {
- renoteId: note._id
- } as any;
- if (sinceId) {
- sort._id = 1;
- query._id = {
- $gt: sinceId
- };
- } else if (untilId) {
- query._id = {
- $lt: untilId
- };
- }
-
- // Issue query
- const renotes = await Note
- .find(query, {
- limit: limit,
- sort: sort
- });
-
- // Serialize
- res(await packMany(renotes, user));
-});