diff --git a/js/posts.js b/js/posts.js index 0e621fe..db15732 100644 --- a/js/posts.js +++ b/js/posts.js @@ -135,7 +135,7 @@ async function reply_link_clicked(reply_channel,reply_id) { } } -async function createPost(username,text,time,specialtext,postid,isbot,reply_id,add_on_top) { +async function createPost(username,text,time,specialtext,postid,isbot,reply_id,add_on_top,avatar_src) { if(!specialtext)specialtext="" const newDiv = createElement("div"); const newP = createElement("p"); @@ -173,7 +173,7 @@ async function createPost(username,text,time,specialtext,postid,isbot,reply_id,a avatar.height=25; avatar.classList.add("avatar") - avatar.src = await getavatar(username) + avatar.src = avatar_src || await getavatar(username) newA.appendChild(avatar) newA.appendChild(newUsername) @@ -265,7 +265,7 @@ async function main(){ highest_id = all_posts[0].post_id for(i in all_posts) { let item = all_posts[i] - await createPost(decodeURIComponent(item.post_user_name),decodeURIComponent(item.post_text),item.post_time,item.post_special_text,item.post_id,item.post_from_bot,item.post_reply_id,false) + await createPost(decodeURIComponent(item.post_user_name),decodeURIComponent(item.post_text),item.post_time,item.post_special_text,item.post_id,item.post_from_bot,item.post_reply_id,false,item.User_Avatar) } let links = document.getElementsByClassName("insertedlink") diff --git a/server.js b/server.js index 5316e97..d5a6c3d 100644 --- a/server.js +++ b/server.js @@ -564,7 +564,7 @@ router.get("/api/getPosts/*", async function (req, res) { router.get("/api/getPosts", async function (req, res) { res.set("Access-Control-Allow-Origin", "*"); if (req.query.channel != undefined) { - let sql = `select post_user_name,post_text,post_time,post_special_text,post_id,post_from_bot,post_reply_id from ipost.posts where post_receiver_name = ? group by post_id order by post_id desc limit 30;`; + let sql = `select post_user_name,post_text,post_time,post_special_text,post_id,post_from_bot,post_reply_id,User_Avatar from ipost.posts inner join ipost.users on (User_Name = post_user_name) where post_receiver_name = ? group by post_id order by post_id desc limit 30;`; con.query(sql, [encodeURIComponent(req.query.channel)], function (err, result) { if (err) throw err;