moving stuff and refactoring
This commit is contained in:
@@ -4,9 +4,10 @@ import { APIError, attemptAPIAction } from "@/util/api/error";
|
||||
import { sequelize, Bucket, Auth, Post, PostTag, Tag, User, dbSync } from "@/models";
|
||||
import { cookies } from "next/headers";
|
||||
import { Attachment } from "@/models";
|
||||
import { UUID, randomUUID } from "crypto";
|
||||
import { UUID } from "crypto";
|
||||
import { mkdir, mkdirSync, writeFile } from "fs";
|
||||
import { where } from "@sequelize/core";
|
||||
import { addToNewBucketForPost } from "../../lib/actions/entityManagement/attachment/attachmentActions";
|
||||
|
||||
async function writeFilesToFS(uuid: UUID, files: any[]): Promise<{ success: boolean, filePaths: string[] }> {
|
||||
|
||||
@@ -49,14 +50,6 @@ async function writeFilesToFS(uuid: UUID, files: any[]): Promise<{ success: bool
|
||||
}
|
||||
}
|
||||
|
||||
async function addToNewBucketForPost(postid: number): Promise<Bucket> {
|
||||
Post.sync();
|
||||
const post = await Post.findOne({ where: { id: postid } });
|
||||
|
||||
if (!post) throw new APIError({ status: 500, responseText: "invalid postid" });
|
||||
const bucket = await post.createBucket({ id: randomUUID() });
|
||||
return bucket;
|
||||
}
|
||||
async function addToExistingBucket(bucketid: number): Promise<Bucket> {
|
||||
const bucket = await Bucket.findOne({
|
||||
where: { id: bucketid }, include: { association: Bucket.associations.posts }
|
||||
|
||||
Reference in New Issue
Block a user