aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sync.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sync.js')
-rw-r--r--lib/sync.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/sync.js b/lib/sync.js
index 97207752..9e2fc31c 100644
--- a/lib/sync.js
+++ b/lib/sync.js
@@ -13,6 +13,7 @@ import ln from "./ln";
import lnd from "./lnd";
import bc from "./bitcoin";
import lq from "./liquid";
+import { adminAuth } from "$lib/passport";
const init = async () => {
try {
@@ -382,3 +383,32 @@ app.get("/conversions", async (req, res) => {
.filter(c => !payments.includes(c))
);
});
+
+app.post("/renameImages", adminAuth, async (req, res) => {
+ let d = './uploads/';
+ fs.readdir(d, (err, files) => {
+ files.forEach(async file => {
+ try {
+ let m = file.match(/(.*)-profile/);
+
+ let username;
+
+ if (m && m[1]) username = m[1];
+ else m = file.match(/(.*)-banner/);
+ if (m && m[1]) username = m[1];
+
+ console.log(username);
+
+ if (username) {
+ let { uuid } = await db.User.findOne({ where: { username } });
+ fs.rename(d + file, d + uuid + file.replace(username, ""), function(err) {
+ if (err) console.log("ERROR: " + err);
+ });
+ }
+ } catch (e) {
+ console.log(e);
+ }
+ });
+ });
+ res.send({});
+});