fix route name & owned files, add more s. chars

This commit is contained in:
split / May 2023-08-28 22:02:18 -07:00
parent 95597fd1e0
commit 4c47d641e5
2 changed files with 12 additions and 2 deletions

View file

@ -6,7 +6,7 @@ import { files } from "./accounts";
import * as Accounts from "./accounts"; import * as Accounts from "./accounts";
export let id_check_regex = /[A-Za-z0-9_\-\.\!]+/ export let id_check_regex = /[A-Za-z0-9_\-\.\!\=\:]+/
export let alphanum = Array.from("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890") export let alphanum = Array.from("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")
// bad solution but whatever // bad solution but whatever

View file

@ -190,7 +190,7 @@ adminRoutes.post("/transfer", parser, (req,res) => {
}) })
adminRoutes.post("/transfer", parser, (req,res) => { adminRoutes.post("/idchange", parser, (req,res) => {
if (typeof req.body.target !== "string" || typeof req.body.new !== "string") { if (typeof req.body.target !== "string" || typeof req.body.new !== "string") {
res.status(404) res.status(404)
@ -211,12 +211,22 @@ adminRoutes.post("/transfer", parser, (req,res) => {
return return
} }
if (targetFile.owner) {
Accounts.files.deindex(targetFile.owner, req.body.target)
Accounts.files.index(targetFile.owner, req.body.new)
}
delete files.files[req.body.target] delete files.files[req.body.target]
files.writeFile(req.body.new, targetFile).then(() => { files.writeFile(req.body.new, targetFile).then(() => {
res.send() res.send()
}).catch(() => { }).catch(() => {
files.files[req.body.target] = req.body.new files.files[req.body.target] = req.body.new
if (targetFile.owner) {
Accounts.files.deindex(targetFile.owner, req.body.new)
Accounts.files.index(targetFile.owner, req.body.target)
}
res.status(500) res.status(500)
res.send() res.send()
}) })