yes
This commit is contained in:
@@ -5,7 +5,8 @@ const allowedMimes = [ "audio", "image", "video", "%" ];
|
||||
|
||||
router.get(/^\/random(\/image|\/video|\/audio)?$/, async (req, res) => {
|
||||
const mime = (allowedMimes.filter(n => req.url.split[1]?.startsWith(n))[0] ? req.url.split[1] : "") + "%";
|
||||
const rows = await sql("items").select("id").where("mime", "like", mime).orderByRaw("rand()").limit(1);
|
||||
const tmp = req.cookies.session ? "" : "id in (select item_id from tags_assign where tag_id = 1 group by item_id)";
|
||||
const rows = await sql("items").select("id").whereRaw(tmp).andWhere("mime", "like", mime).orderByRaw("rand()").limit(1);
|
||||
|
||||
res.redirect(`/${req.url.split[1] ? req.url.split[1] + "/" : ""}${rows[0].id}`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user