[API] Improve drive/files
This commit is contained in:
		
							parent
							
								
									bdffc00dca
								
							
						
					
					
						commit
						860a322c36
					
				
					 1 changed files with 7 additions and 0 deletions
				
			
		| 
						 | 
					@ -35,6 +35,10 @@ module.exports = async (params, user, app) => {
 | 
				
			||||||
	const [folderId = null, folderIdErr] = $(params.folder_id).optional.nullable.id().$;
 | 
						const [folderId = null, folderIdErr] = $(params.folder_id).optional.nullable.id().$;
 | 
				
			||||||
	if (folderIdErr) throw 'invalid folder_id param';
 | 
						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
 | 
						// Construct query
 | 
				
			||||||
	const sort = {
 | 
						const sort = {
 | 
				
			||||||
		_id: -1
 | 
							_id: -1
 | 
				
			||||||
| 
						 | 
					@ -53,6 +57,9 @@ module.exports = async (params, user, app) => {
 | 
				
			||||||
			$lt: maxId
 | 
								$lt: maxId
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if (type) {
 | 
				
			||||||
 | 
							query.contentType = new RegExp(`^${type.replace(/\*/g, '.+?')}$`);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Issue query
 | 
						// Issue query
 | 
				
			||||||
	const files = await DriveFile
 | 
						const files = await DriveFile
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue