Replies now send a message
This commit is contained in:
parent
34d7d516b5
commit
a71e551310
2 changed files with 18 additions and 2 deletions
|
@ -188,6 +188,24 @@ backend.postCreate = async ({content}, {user,db}) => {
|
||||||
if (reply)
|
if (reply)
|
||||||
reply = reply.url.split('/').pop();
|
reply = reply.url.split('/').pop();
|
||||||
|
|
||||||
|
if (reply) {
|
||||||
|
let replyData = (await db.all('SELECT * FROM post WHERE id = ?', [
|
||||||
|
reply
|
||||||
|
]));
|
||||||
|
|
||||||
|
let replyUser = '';
|
||||||
|
if (replyData && replyData[0])
|
||||||
|
replyUser = replyData[0].username;
|
||||||
|
|
||||||
|
await db.run('INSERT INTO messages (username, content, time,read) VALUES (?, ?, ?, ?)', [
|
||||||
|
replyUser,
|
||||||
|
`@${user} replied to #${reply} on #${id}`,
|
||||||
|
Math.floor(new Date() * 1000),
|
||||||
|
0
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
await db.run('INSERT INTO post (username, id, content, rating, reply, time) VALUES (?, ?, ?, ?, ?, ?)', [
|
await db.run('INSERT INTO post (username, id, content, rating, reply, time) VALUES (?, ?, ?, ?, ?, ?)', [
|
||||||
user,
|
user,
|
||||||
id,
|
id,
|
||||||
|
|
|
@ -104,8 +104,6 @@ let formatPostText = function(post) {
|
||||||
|
|
||||||
wasInc = inc;
|
wasInc = inc;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(newArr);
|
|
||||||
|
|
||||||
return newArr;
|
return newArr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue