aboutsummaryrefslogtreecommitdiff
path: root/src/lib/thread.ts
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2022-08-29 19:01:20 +0300
committerkartofen <mladenovnasko0@gmail.com>2022-08-29 19:01:20 +0300
commit8e4163e3f08e29f38fe87c59d8cfb91e0fa98063 (patch)
tree2b117f4bafa0a4d10252eef95ca868a247a081a1 /src/lib/thread.ts
parent9d952483f250a97cbeab4061fa1c4e68341b330f (diff)
everything works
Diffstat (limited to 'src/lib/thread.ts')
-rw-r--r--src/lib/thread.ts42
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 {