mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-24 11:15:11 +00:00
いい感じにした
This commit is contained in:
parent
30ad071575
commit
15fff96224
8 changed files with 32 additions and 23 deletions
|
@ -41,7 +41,7 @@ module.exports = (params, user, app) =>
|
|||
|
||||
// Get 'folder_id' parameter
|
||||
let folder = params.folder_id;
|
||||
if (folder === undefined || folder === null || folder === 'null') {
|
||||
if (folder === undefined || folder === null) {
|
||||
folder = null;
|
||||
} else {
|
||||
folder = new mongo.ObjectID(folder);
|
||||
|
|
|
@ -46,7 +46,7 @@ module.exports = (file, params, user) =>
|
|||
|
||||
// Get 'folder_id' parameter
|
||||
let folder = params.folder_id;
|
||||
if (folder === undefined || folder === null || folder === 'null') {
|
||||
if (folder === undefined || folder === null) {
|
||||
folder = null;
|
||||
} else {
|
||||
folder = new mongo.ObjectID(folder);
|
||||
|
|
|
@ -25,7 +25,7 @@ module.exports = (params, user) =>
|
|||
|
||||
// Get 'folder_id' parameter
|
||||
let folder = params.folder_id;
|
||||
if (folder === undefined || folder === null || folder === 'null') {
|
||||
if (folder === undefined || folder === null) {
|
||||
folder = null;
|
||||
} else {
|
||||
folder = new mongo.ObjectID(folder);
|
||||
|
|
|
@ -58,16 +58,18 @@ module.exports = (params, user) =>
|
|||
|
||||
// Get 'folder_id' parameter
|
||||
let folderId = params.folder_id;
|
||||
if (folderId !== undefined && folderId !== 'null') {
|
||||
folderId = new mongo.ObjectID(folderId);
|
||||
}
|
||||
|
||||
let folder = null;
|
||||
if (folderId !== undefined && folderId !== null) {
|
||||
if (folderId === 'null') {
|
||||
if (folderId !== undefined) {
|
||||
if (folderId === null) {
|
||||
file.folder_id = null;
|
||||
} else {
|
||||
folder = await DriveFolder
|
||||
// Validate id
|
||||
if (!mongo.ObjectID.isValid(folderId)) {
|
||||
return rej('incorrect folder_id');
|
||||
}
|
||||
|
||||
folderId = new mongo.ObjectID(folderId);
|
||||
|
||||
const folder = await DriveFolder
|
||||
.findOne({
|
||||
_id: folderId,
|
||||
user_id: user._id
|
||||
|
|
|
@ -41,7 +41,7 @@ module.exports = (params, user, app) =>
|
|||
|
||||
// Get 'folder_id' parameter
|
||||
let folder = params.folder_id;
|
||||
if (folder === undefined || folder === null || folder === 'null') {
|
||||
if (folder === undefined || folder === null) {
|
||||
folder = null;
|
||||
} else {
|
||||
folder = new mongo.ObjectID(folder);
|
||||
|
|
|
@ -25,7 +25,7 @@ module.exports = (params, user) =>
|
|||
|
||||
// Get 'parent_id' parameter
|
||||
let parentId = params.parent_id;
|
||||
if (parentId === undefined || parentId === null || parentId === 'null') {
|
||||
if (parentId === undefined || parentId === null) {
|
||||
parentId = null;
|
||||
} else {
|
||||
parentId = new mongo.ObjectID(parentId);
|
||||
|
|
|
@ -25,6 +25,11 @@ module.exports = (params, user) =>
|
|||
return rej('folder_id is required');
|
||||
}
|
||||
|
||||
// Validate id
|
||||
if (!mongo.ObjectID.isValid(folderId)) {
|
||||
return rej('incorrect folder_id');
|
||||
}
|
||||
|
||||
// Fetch folder
|
||||
const folder = await DriveFolder
|
||||
.findOne({
|
||||
|
@ -49,17 +54,19 @@ module.exports = (params, user) =>
|
|||
|
||||
// Get 'parent_id' parameter
|
||||
let parentId = params.parent_id;
|
||||
if (parentId !== undefined && parentId !== 'null') {
|
||||
parentId = new mongo.ObjectID(parentId);
|
||||
}
|
||||
|
||||
let parent = null;
|
||||
if (parentId !== undefined && parentId !== null) {
|
||||
if (parentId === 'null') {
|
||||
if (parentId !== undefined) {
|
||||
if (parentId === null) {
|
||||
folder.parent_id = null;
|
||||
} else {
|
||||
// Validate id
|
||||
if (!mongo.ObjectID.isValid(parentId)) {
|
||||
return rej('incorrect parent_id');
|
||||
}
|
||||
|
||||
parentId = new mongo.ObjectID(parentId);
|
||||
|
||||
// Get parent folder
|
||||
parent = await DriveFolder
|
||||
const parent = await DriveFolder
|
||||
.findOne({
|
||||
_id: parentId,
|
||||
user_id: user._id
|
||||
|
|
|
@ -407,7 +407,7 @@
|
|||
@remove-file file
|
||||
@api \drive/files/update do
|
||||
file_id: file
|
||||
folder_id: if @folder? then @folder.id else \null
|
||||
folder_id: if @folder? then @folder.id else null
|
||||
.then ~>
|
||||
# something
|
||||
.catch (err, text-status) ~>
|
||||
|
@ -424,7 +424,7 @@
|
|||
@remove-folder folder
|
||||
@api \drive/folders/update do
|
||||
folder_id: folder
|
||||
parent_id: if @folder? then @folder.id else \null
|
||||
parent_id: if @folder? then @folder.id else null
|
||||
.then ~>
|
||||
# something
|
||||
.catch (err) ~>
|
||||
|
|
Loading…
Reference in a new issue