summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/admin/drive/show-file.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/api/endpoints/admin/drive/show-file.ts')
-rw-r--r--src/server/api/endpoints/admin/drive/show-file.ts16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/server/api/endpoints/admin/drive/show-file.ts b/src/server/api/endpoints/admin/drive/show-file.ts
index 415bfc28b3..36403bb1c3 100644
--- a/src/server/api/endpoints/admin/drive/show-file.ts
+++ b/src/server/api/endpoints/admin/drive/show-file.ts
@@ -12,7 +12,11 @@ export const meta = {
params: {
fileId: {
- validator: $.type(ID),
+ validator: $.optional.type(ID),
+ },
+
+ url: {
+ validator: $.optional.str,
},
},
@@ -26,7 +30,15 @@ export const meta = {
};
export default define(meta, async (ps, me) => {
- const file = await DriveFiles.findOne(ps.fileId);
+ const file = ps.fileId ? await DriveFiles.findOne(ps.fileId) : await DriveFiles.findOne({
+ where: [{
+ url: ps.url
+ }, {
+ thumbnailUrl: ps.url
+ }, {
+ webpublicUrl: ps.url
+ }]
+ });
if (file == null) {
throw new ApiError(meta.errors.noSuchFile);