From 860a322c3637ba8933639a84fc8f335c4c6323fb Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 9 Nov 2017 02:55:03 +0900 Subject: [PATCH] [API] Improve drive/files --- src/api/endpoints/drive/files.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/api/endpoints/drive/files.ts b/src/api/endpoints/drive/files.ts index 53b48a8be..b2e094775 100644 --- a/src/api/endpoints/drive/files.ts +++ b/src/api/endpoints/drive/files.ts @@ -35,6 +35,10 @@ module.exports = async (params, user, app) => { const [folderId = null, folderIdErr] = $(params.folder_id).optional.nullable.id().$; if (folderIdErr) throw 'invalid folder_id param'; + // Get 'type' parameter + const [type, typeErr] = $(params.type).optional.string().match(/^[a-zA-Z\/\-\*]+$/).$; + if (typeErr) throw 'invalid type param'; + // Construct query const sort = { _id: -1 @@ -53,6 +57,9 @@ module.exports = async (params, user, app) => { $lt: maxId }; } + if (type) { + query.contentType = new RegExp(`^${type.replace(/\*/g, '.+?')}$`); + } // Issue query const files = await DriveFile