before i forget,

This commit is contained in:
May 2024-03-08 17:00:57 -08:00
parent b04414aeb9
commit e624e19802
2 changed files with 12 additions and 11 deletions

View file

@ -434,8 +434,9 @@ export class UploadStream extends Writable {
chunkSize: this.files.config.maxDiscordFileSize chunkSize: this.files.config.maxDiscordFileSize
} }
await this.files.write()
delete this.files.locks[this.uploadId!] delete this.files.locks[this.uploadId!]
await this.files.api.deleteMessages(ogf.messageids)
await this.files.write()
if (this.owner) Accounts.files.index(this.owner, this.uploadId!) if (this.owner) Accounts.files.index(this.owner, this.uploadId!)
return this.uploadId return this.uploadId
} }
@ -627,16 +628,16 @@ export default class Files {
async unlink(uploadId: string, noWrite: boolean = false): Promise<void> { async unlink(uploadId: string, noWrite: boolean = false): Promise<void> {
let target = this.files[uploadId] let target = this.files[uploadId]
if (!target) return if (!target) return
await this.api.deleteMessages(target.messageids)
if (target.owner) { if (target.owner) {
let id = files.deindex(target.owner, uploadId, noWrite) let id = files.deindex(target.owner, uploadId, noWrite)
if (id) await id if (id) await id
} }
await this.api.deleteMessages(target.messageids)
delete this.files[uploadId] delete this.files[uploadId]
if (noWrite) return
return this.write().catch((err) => { if (!noWrite) this.write().catch((err) => {
throw err throw err
}) })
} }

View file

@ -212,8 +212,8 @@ export default function (files: Files) {
requiresPermissions("manage"), requiresPermissions("manage"),
async (ctx) => { async (ctx) => {
const body = await ctx.req.json() as UserUpdateParameters const body = await ctx.req.json() as UserUpdateParameters
const actor = ctx.get("account")! as Accounts.Account const actor = ctx.get("account")!
const target = ctx.get("target")! as Accounts.Account const target = ctx.get("target")!
if (Array.isArray(body)) if (Array.isArray(body))
return ServeError(ctx, 400, "invalid body") return ServeError(ctx, 400, "invalid body")
@ -240,9 +240,7 @@ export default function (files: Files) {
) )
router.delete("/:user", requiresAccount, noAPIAccess, async (ctx) => { router.delete("/:user", requiresAccount, noAPIAccess, async (ctx) => {
let acc = ctx.req.param("user") == "me" ? ctx.get("account") : Accounts.getFromId(ctx.req.param("user")) let acc = ctx.get("target")
if (acc != ctx.get("account") && !ctx.get("account")?.admin) return ServeError(ctx, 403, "you are not an administrator")
if (!acc) return ServeError(ctx, 404, "account does not exist")
auth.AuthTokens.filter((e) => e.account == acc?.id).forEach( auth.AuthTokens.filter((e) => e.account == acc?.id).forEach(
(token) => { (token) => {
@ -266,5 +264,7 @@ export default function (files: Files) {
return ctx.text("account deleted") return ctx.text("account deleted")
}) })
router.get("/:user")
return router return router
} }