From 30c4b87c70756e1e05cd3a321f1332fdae67a472 Mon Sep 17 00:00:00 2001 From: Moe Date: Sun, 8 Dec 2024 21:11:20 -0800 Subject: [PATCH] Add API Endpoints uploaderFields,addStorage,hardwareAccels,storageLocations + languages + make userInfo endpoint only ke, uid, mail, and details --- libs/webServerPaths.js | 76 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/libs/webServerPaths.js b/libs/webServerPaths.js index b5a43bfb..4981ddbf 100644 --- a/libs/webServerPaths.js +++ b/libs/webServerPaths.js @@ -163,9 +163,20 @@ module.exports = function(s,config,lang,app,io){ app.get(config.webPaths.apiPrefix+':auth/userInfo/:ke',function (req,res){ var response = {ok:false}; res.setHeader('Content-Type', 'application/json'); - s.auth(req.params,function(user){ + s.auth(req.params, async function(user){ response.ok = true - response.user = user + const { rows } = await s.knexQueryPromise({ + action: "select", + columns: "ke,uid,mail,details", + table: "Users", + where: [ + ['ke','=', req.params.ke], + ['uid','=', user.uid], + ] + }); + const userInfo = rows[0]; + userInfo.details = JSON.parse(userInfo.details) + response.user = userInfo; res.end(s.prettyPrint(response)); },res,req); }) @@ -2137,6 +2148,67 @@ module.exports = function(s,config,lang,app,io){ },res,req) }) /** + * API : Get Available Languages + */ + app.get(config.webPaths.apiPrefix+':auth/languages/:ke',function (req,res){ + s.auth(req.params,function(user){ + var endData = { + ok: true, + list: s.listOfPossibleLanguages + } + s.closeJsonResponse(res,endData) + },res,req) + }) + /** + * API : Get Storage Locations + */ + app.get(config.webPaths.apiPrefix+':auth/storageLocations/:ke',function (req,res){ + s.auth(req.params,function(user){ + const endData = { + ok: true, + list: s.listOfStorage + } + s.closeJsonResponse(res,endData) + },res,req) + }) + /** + * API : Get Hardware Acceleration choices + */ + app.get(config.webPaths.apiPrefix+':auth/hardwareAccels/:ke',function (req,res){ + s.auth(req.params,function(user){ + const endData = { + ok: true, + list: s.listOfHwAccels + } + s.closeJsonResponse(res,endData) + },res,req) + }) + /** + * API : Get Audio File choices + */ + app.get(config.webPaths.apiPrefix+':auth/addStorage/:ke',function (req,res){ + s.auth(req.params,function(user){ + const endData = { + ok: true, + list: s.dir.addStorage + } + s.closeJsonResponse(res,endData) + },res,req) + }) + /** + * API : Get Uploader choices + */ + app.get(config.webPaths.apiPrefix+':auth/uploaderFields/:ke',function (req,res){ + s.auth(req.params,function(user){ + const fields = s.definitions["Account Settings"].blocks["Uploaders"]; + const endData = { + ok: true, + fields + } + s.closeJsonResponse(res,endData) + },res,req) + }) + /** * Robots.txt */ app.get('/robots.txt', function (req,res){