When thread deleted, delete its messages

This commit is contained in:
Akif9748 2022-08-31 15:14:14 +03:00
parent 98675863bb
commit 46d5eac8d8
4 changed files with 8 additions and 7 deletions

View file

@ -37,8 +37,8 @@ Akf-forum has got an API for AJAX, other clients etc. And, you can learn about A
| Page support, support message limit correct | 🟢 | MEDIUM | | Page support, support message limit correct | 🟢 | MEDIUM |
| Multi-theme support, black theme | 🟡 | LOW | | Multi-theme support, black theme | 🟡 | LOW |
| Search | 🔴 | MEDIUM | | Search | 🔴 | MEDIUM |
| Footer | 🔴 | LOW | | Footer | 🟢 | LOW |
- If thread deleted, not show its messages in API. ?
- Profile photos will store in database - Profile photos will store in database
- replacer function global - replacer function global
- author name of thread - author name of thread
@ -50,9 +50,9 @@ Akf-forum has got an API for AJAX, other clients etc. And, you can learn about A
- app.param for users in API - app.param for users in API
- message counts for API - message counts for API
- ZATEN SİLİNDİ BU KİŞİ & MESAJ - ZATEN SİLİNDİ BU KİŞİ & MESAJ
- about me button not working
- delete thread for threads area - delete thread for threads area
- delete admin request, moreover, add it to user patch delete 😳 - delete admin request, moreover, add it to user patch delete 😳
- user -> ips []
### API ### API
| To do | Is done? | To do | Is done?

View file

@ -72,7 +72,7 @@ app.delete("/:id/", async (req, res) => {
thread.deleted = true; thread.deleted = true;
await thread.save(); await thread.save();
await MessageModel.updateMany({ threadID: thread.id }, { deleted: true });
res.complate(thread); res.complate(thread);
}) })
@ -86,6 +86,7 @@ app.post("/:id/undelete", async (req, res) => {
thread.edited = true; thread.edited = true;
await thread.save(); await thread.save();
await MessageModel.updateMany({ threadID: thread.id }, { deleted: false });
res.complate(thread); res.complate(thread);

View file

@ -49,7 +49,7 @@ app.post("/:id/undelete/", async (req, res) => {
member.deleted = false; member.deleted = false;
await member.save(); await member.save();
res.complate(member.toObject({ virtuals: true })); res.complate(member);
}) })
@ -74,7 +74,7 @@ app.patch("/:id/", async (req, res) => {
await member.save(); await member.save();
res.complate(member.toObject({ virtuals: true })); res.complate(member);
}) })

View file

@ -76,7 +76,7 @@
body.name = prompt("Enter new username!"); body.name = prompt("Enter new username!");
else if (e.target.id == "edit_avatar") else if (e.target.id == "edit_avatar")
body.avatar = prompt("Enter new avatar URL!"); body.avatar = prompt("Enter new avatar URL!");
else if (e.target.id == "edit_avatar") else if (e.target.id == "edit_about")
body.about = prompt("Enter new about text!"); body.about = prompt("Enter new about text!");
else return; else return;
const res = await request(`/api/users/<%= member.id %>`, "PATCH", body); const res = await request(`/api/users/<%= member.id %>`, "PATCH", body);