tagid instead of tagname

This commit is contained in:
Flummi
2021-12-25 13:12:53 +01:00
parent d71eece80e
commit 9a3b494a94
2 changed files with 13 additions and 13 deletions

View File

@ -136,7 +136,7 @@ export default (router, tpl) => {
});
group.post(/\/admin\/tags\/delete$/, auth, async (req, res) => {
if(!req.post.postid || !req.post.tag) {
if(!req.post.postid || !req.post.tagid) {
return res.reply({ body: JSON.stringify({
success: false,
msg: "missing postid or tag"
@ -144,15 +144,14 @@ export default (router, tpl) => {
}
const postid = +req.post.postid;
const tag = req.post.tag;
const tagid = +req.post.tagid;
const tags = await lib.getTags(postid);
const tagid = tags.filter(t => t.tag === tag)[0]?.id ?? null;
if(!tagid || tagid?.length === 0) {
const tagcheck = tags.filter(t => t.id === tagid)[0]?.id ?? null;
if(!tagcheck || !tagid || tagid?.length === 0) {
return res.reply({ body: JSON.stringify({
success: false,
tag: tag,
msg: "tag is not assigned",
tags: await lib.getTags(postid)
})});
@ -165,7 +164,6 @@ export default (router, tpl) => {
return res.reply({ body: JSON.stringify({
success: reply,
tag: tag,
tagid: tagid,
tags: await lib.getTags(postid)
})});