This commit is contained in:
Benjamin Toby
2025-07-28 07:23:45 +01:00
parent a429436939
commit 8ac8b8eb51
49 changed files with 475 additions and 177 deletions
@@ -26,6 +26,7 @@ export default async function handleSocialDb({
}: HandleSocialDbFunctionParams): Promise<APIResponseObject> {
try {
const finalDbName = database;
const MAX_IMAGE_STRING_LENGTH = 350;
const existingSocialUserQUery = `SELECT * FROM users WHERE email = ? AND social_login='1' AND social_platform = ? `;
const existingSocialUserValues = [email, social_platform];
@@ -127,6 +128,14 @@ export default async function handleSocialDb({
};
Object.keys(payload).forEach((key) => {
if (key.match(/image/)) {
const imageString = payload[key] as string | undefined;
if (
!imageString ||
imageString.length > MAX_IMAGE_STRING_LENGTH
)
return;
}
data[key] = payload[key];
});
@@ -1,11 +1,10 @@
// @ts-check
import { DSQL_TableSchemaType } from "../../types";
import decrypt from "../dsql/decrypt";
import defaultFieldsRegexp from "../dsql/default-fields-regexp";
type Param = {
unparsedResults: any[];
tableSchema?: import("../../types").DSQL_TableSchemaType;
tableSchema?: DSQL_TableSchemaType;
};
/**
@@ -15,23 +14,13 @@ type Param = {
* function, decrypts encrypted fields, and returns an updated array with no encrypted
* fields
*/
export default async function parseDbResults({
export default function parseDbResults({
unparsedResults,
tableSchema,
}: Param): Promise<any[] | null> {
/**
* Declare variables
*
* @description Declare "results" variable
*/
}: Param): any[] | null {
let parsedResults = [];
try {
/**
* Declare variables
*
* @description Declare "results" variable
*/
for (let pr = 0; pr < unparsedResults.length; pr++) {
let result = unparsedResults[pr];
@@ -39,7 +28,9 @@ export default async function parseDbResults({
for (let i = 0; i < resultFieldNames.length; i++) {
const resultFieldName = resultFieldNames[i];
let resultFieldSchema = tableSchema?.fields[i];
let resultFieldSchema = tableSchema?.fields.find(
(fld) => fld.fieldName == resultFieldName
);
if (resultFieldName?.match(defaultFieldsRegexp)) {
continue;
@@ -48,7 +39,6 @@ export default async function parseDbResults({
let value = result[resultFieldName];
if (typeof value !== "number" && !value) {
// parsedResults.push(result);
continue;
}
@@ -64,14 +54,8 @@ export default async function parseDbResults({
parsedResults.push(result);
}
/**
* Declare variables
*
* @description Declare "results" variable
*/
return parsedResults;
} catch (/** @type {any} */ error: any) {
console.log("ERROR in parseDbResults Function =>", error.message);
} catch (error: any) {
return unparsedResults;
}
}
@@ -27,6 +27,6 @@ export default async function dbGrabUserResource<
error: result?.error,
msg: result?.msg,
},
count: typeof result?.count == "number" ? result.count : undefined,
count: typeof result?.count == "number" ? result.count : null,
};
}