mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
use savePostData
method
This commit is contained in:
parent
ceb4bb9406
commit
c3ec2845f1
@ -56,7 +56,8 @@ export default class PostsController extends Controller {
|
||||
}
|
||||
|
||||
postData.likes.push(user_id)
|
||||
await postData.save()
|
||||
|
||||
await this.savePostData(postData)
|
||||
|
||||
global.wsInterface.io.emit(`post.like`, {
|
||||
...postData.toObject(),
|
||||
@ -77,7 +78,8 @@ export default class PostsController extends Controller {
|
||||
const postData = await Post.findById(post_id)
|
||||
|
||||
postData.likes = postData.likes.filter(id => id !== user_id)
|
||||
await postData.save()
|
||||
|
||||
await this.savePostData(postData)
|
||||
|
||||
global.wsInterface.io.emit(`post.unlike`, {
|
||||
...postData.toObject(),
|
||||
@ -131,6 +133,13 @@ export default class PostsController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
savePostData = async (post) => {
|
||||
await post.save()
|
||||
|
||||
global.wsInterface.io.emit(`post.dataUpdate`, post.toObject())
|
||||
global.wsInterface.io.emit(`post.dataUpdate.${post._id}`, post.toObject())
|
||||
}
|
||||
|
||||
get = {
|
||||
"/feed": Schematized({
|
||||
select: ["user_id"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user