diff options
Diffstat (limited to 'src/lib/thread.ts')
-rw-r--r-- | src/lib/thread.ts | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/src/lib/thread.ts b/src/lib/thread.ts index e0f0aa4..2199318 100644 --- a/src/lib/thread.ts +++ b/src/lib/thread.ts @@ -8,8 +8,8 @@ export async function processThreadIn(board: string, thread: Thread, comments = if(!thread || !board) return; let imageId: string = thread.imageId; - if(existsSync(`dist/client/images/${imageId}`)) - // if(existsSync(`public/images/${imageId}`)) + // if(existsSync(`dist/client/images/${imageId}`)) + if(existsSync(`public/images/${imageId}`)) thread.imageId = `/images/${imageId}`; else thread.imageId = await getImg(imageId); @@ -21,8 +21,8 @@ export async function processThreadIn(board: string, thread: Thread, comments = for(let comment of thread.comments) { let cimageId = comment.imageId; - if(existsSync(`dist/client/images/${cimageId}`)) - // if(existsSync(`public/images/${cimageId}`)) + // if(existsSync(`dist/client/images/${cimageId}`)) + if(existsSync(`public/images/${cimageId}`)) comment.imageId = `/images/${cimageId}`; else comment.imageId = await getImg(cimageId); @@ -32,22 +32,34 @@ export async function processThreadIn(board: string, thread: Thread, comments = } export async function processThreadOut(form: any): Thread { - let img = form.get('image').toString(); - - let t: Thread = {}; - t.id = uuidV4(); - t.ThreadName = form.get('ThreadName').toString(); - t.ThreadCreator = uuidV5(form.get('iphash'), uuidNIL); - t.ThreadText = form.get('ThreadText').toString(); - t.Comments = []; - t.CreationDate = Date.now(); - t.ImageId = await postImg(img); - t.FileType = getImgType(img); + let img = form.get('image'); + + let t: Thread = { + id: uuidV4(), + threadName: form.get('ThreadName'), + threadCreator: uuidV5(form.get('iphash'), uuidNIL), + threadText: form.get('ThreadText'), + comments: [], + creationDate: Date.now(), + imageId: await postImg(img), + fileType: getImgType(img), + } return t; } export async function processCommentOut(form: any): Comment { + let img = form.get('image'); + + let c: Comment = {}; + c.id = uuidV4(); + c.commentCreator = uuidV5(form.get('iphash'), uuidNIL); + c.commentText = form.get('CommentText'); + c.creationDate = Date.now(); + c.imageId = await postImg(img); + c.fileType = getImgType(img); + + return c; } function replaceURLs(text: string, board: string, OPtid?: string): string { |