This commit is contained in:
Flummi
2022-03-24 16:13:51 +01:00
parent abcea99fe0
commit 9c516f7712
2 changed files with 38 additions and 22 deletions

View File

@ -85,16 +85,16 @@ export default (router, tpl) => {
});
// adminzeugs
group.get(/\/admin\/tags\/add$/, auth, async (req, res) => {
if(!req.url.qs.postid || !req.url.qs.tag) {
group.post(/\/admin\/tags\/add$/, auth, async (req, res) => {
if(!req.post.postid || !req.post.tag) {
return res.reply({ body: JSON.stringify({
success: false,
msg: "missing postid or tag"
})});
}
const postid = +req.url.qs.postid;
const tag = req.url.qs.tag?.trim();
const postid = +req.post.postid;
const tag = req.post.tag?.trim();
if(tag.length >= 45) {
return res.reply({ body: JSON.stringify({
@ -136,16 +136,16 @@ export default (router, tpl) => {
})});
});
group.get(/\/admin\/tags\/delete$/, auth, async (req, res) => {
if(!req.url.qs.postid || !req.url.qs.tagid) {
group.post(/\/admin\/tags\/delete$/, auth, async (req, res) => {
if(!req.post.postid || !req.post.tagid) {
return res.reply({ body: JSON.stringify({
success: false,
msg: "missing postid or tag"
})});
}
const postid = +req.url.qs.postid;
const tagid = +req.url.qs.tagid;
const postid = +req.post.postid;
const tagid = +req.post.tagid;
const tags = await lib.getTags(postid);
@ -206,14 +206,14 @@ export default (router, tpl) => {
})});
});
group.get(/\/admin\/deletepost$/, auth, async (req, res) => {
if(!req.url.qs.postid) {
group.post(/\/admin\/deletepost$/, auth, async (req, res) => {
if(!req.post.postid) {
return res.reply({ body: JSON.stringify({
success: true,
msg: "no postid"
})});
}
const postid = +req.url.qs.postid;
const postid = +req.post.postid;
await sql("items").where("id", postid).del();
res.reply({ body: JSON.stringify({
@ -221,8 +221,8 @@ export default (router, tpl) => {
})});
});
group.get(/\/admin\/togglefav$/, auth, async (req, res) => {
const postid = +req.url.qs.postid;
group.post(/\/admin\/togglefav$/, auth, async (req, res) => {
const postid = +req.post.postid;
let favs = await sql('favorites').select('user_id').where('item_id', postid);