mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 19:14:16 +00:00
implement /indecent_prediction
endpoint
This commit is contained in:
parent
494a16ff52
commit
003fad7cd0
@ -3,10 +3,40 @@ import { Schematized } from "../../lib"
|
|||||||
|
|
||||||
import { FeaturedWallpaper } from "../../models"
|
import { FeaturedWallpaper } from "../../models"
|
||||||
|
|
||||||
|
import IndecentPrediction from "../../utils/indecent-prediction"
|
||||||
|
import downloadFile from "../../utils/download-file"
|
||||||
|
|
||||||
export default class PublicController extends Controller {
|
export default class PublicController extends Controller {
|
||||||
static refName = "PublicController"
|
static refName = "PublicController"
|
||||||
|
|
||||||
get = {
|
get = {
|
||||||
|
"/indecent_prediction": {
|
||||||
|
fn: Schematized({
|
||||||
|
select: ["url"],
|
||||||
|
required: ["url"],
|
||||||
|
}, async (req, res) => {
|
||||||
|
const { url } = req.selection
|
||||||
|
|
||||||
|
const download = await downloadFile({ url })
|
||||||
|
|
||||||
|
const predictions = await IndecentPrediction({
|
||||||
|
image: download.destination,
|
||||||
|
}).catch((err) => {
|
||||||
|
res.status(500).json({
|
||||||
|
error: err.message,
|
||||||
|
})
|
||||||
|
|
||||||
|
return null
|
||||||
|
})
|
||||||
|
|
||||||
|
// delete cached file
|
||||||
|
await download.delete()
|
||||||
|
|
||||||
|
if (predictions) {
|
||||||
|
return res.json(predictions)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
"/posting_policy": {
|
"/posting_policy": {
|
||||||
middlewares: ["withOptionalAuthentication"],
|
middlewares: ["withOptionalAuthentication"],
|
||||||
fn: async (req, res) => {
|
fn: async (req, res) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user