zet-lib 1.4.23 → 1.4.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/zAppRouter.js +28 -5
- package/lib/zRoute.js +25 -2
- package/package.json +1 -1
package/lib/zAppRouter.js
CHANGED
|
@@ -2080,11 +2080,34 @@ router.post("/zdropbox-file/:index", handleTokenRefresh, async (req, res) => {
|
|
|
2080
2080
|
});
|
|
2081
2081
|
link = response.result.link;
|
|
2082
2082
|
} catch (error) {
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2083
|
+
setTimeout(async () => {
|
|
2084
|
+
try {
|
|
2085
|
+
const response = await dbx.filesGetTemporaryLink({
|
|
2086
|
+
path: pathFile,
|
|
2087
|
+
});
|
|
2088
|
+
link = response.result.link;
|
|
2089
|
+
const mockFile = {
|
|
2090
|
+
name: metadata.result.name,
|
|
2091
|
+
id: metadata.result,
|
|
2092
|
+
path: metadata.result.path_display,
|
|
2093
|
+
link: link,
|
|
2094
|
+
isImage: metadata.result.name.match(/\.(jpg|jpeg|png|gif)$/i),
|
|
2095
|
+
size: metadata.result.size,
|
|
2096
|
+
modified: metadata.result.server_modified,
|
|
2097
|
+
accepted: true,
|
|
2098
|
+
index: req.params.index,
|
|
2099
|
+
};
|
|
2100
|
+
//console.log(mockFile)
|
|
2101
|
+
datas = mockFile;
|
|
2102
|
+
res.json(datas);
|
|
2103
|
+
} catch (e) {
|
|
2104
|
+
console.error("Error getting temporary link:", error);
|
|
2105
|
+
io.to(room).emit(
|
|
2106
|
+
"errormessage",
|
|
2107
|
+
`Please reload your browser, Error getting temporary link: ${error.message}`
|
|
2108
|
+
);
|
|
2109
|
+
}
|
|
2110
|
+
}, 2000);
|
|
2088
2111
|
}
|
|
2089
2112
|
const mockFile = {
|
|
2090
2113
|
name: metadata.result.name,
|
package/lib/zRoute.js
CHANGED
|
@@ -5059,7 +5059,7 @@ zRoute.deleteSQL = async (table, id, company_id) => {
|
|
|
5059
5059
|
throw Error("Data is locked");
|
|
5060
5060
|
} else {
|
|
5061
5061
|
//delete all files
|
|
5062
|
-
zRoute.deleteFiles(table, results[0]);
|
|
5062
|
+
await zRoute.deleteFiles(table, results[0]);
|
|
5063
5063
|
await connection.delete({ table: table, where: where });
|
|
5064
5064
|
zRoute.modelsCacheRenew(table, company_id);
|
|
5065
5065
|
}
|
|
@@ -5072,7 +5072,7 @@ zRoute.deleteSQL = async (table, id, company_id) => {
|
|
|
5072
5072
|
}
|
|
5073
5073
|
};
|
|
5074
5074
|
|
|
5075
|
-
zRoute.deleteFiles = (table, result) => {
|
|
5075
|
+
zRoute.deleteFiles = async (table, result) => {
|
|
5076
5076
|
try {
|
|
5077
5077
|
//check if has files then remove it
|
|
5078
5078
|
const MYMODELS = myCache.get("MYMODELS");
|
|
@@ -5093,6 +5093,29 @@ zRoute.deleteFiles = (table, result) => {
|
|
|
5093
5093
|
fs.remove(dir + result[key], () => {});
|
|
5094
5094
|
}
|
|
5095
5095
|
}
|
|
5096
|
+
if (widgets[key].name == "dropbox") {
|
|
5097
|
+
if (result[key]) {
|
|
5098
|
+
let dbx = new Dropbox({
|
|
5099
|
+
accessToken: process.env.DROPBOX_ACCESS_TOKEN,
|
|
5100
|
+
refreshToken: process.env.DROPBOX_REFRESH_TOKEN,
|
|
5101
|
+
clientId: process.env.DROPBOX_CLIENT_ID,
|
|
5102
|
+
clientSecret: process.env.DROPBOX_CLIENT_SECRET,
|
|
5103
|
+
fetch: fetch,
|
|
5104
|
+
});
|
|
5105
|
+
const files = result[key];
|
|
5106
|
+
const dropboxPath = `/${table}/${key}`;
|
|
5107
|
+
for (const file of files) {
|
|
5108
|
+
let filePath = `${dropboxPath}/${file}`;
|
|
5109
|
+
try {
|
|
5110
|
+
await dbx.filesDeleteV2({
|
|
5111
|
+
path: filePath,
|
|
5112
|
+
});
|
|
5113
|
+
} catch (e) {
|
|
5114
|
+
console.log(e);
|
|
5115
|
+
}
|
|
5116
|
+
}
|
|
5117
|
+
}
|
|
5118
|
+
}
|
|
5096
5119
|
}
|
|
5097
5120
|
} catch (e) {
|
|
5098
5121
|
console.log(e);
|