SponsorBlockServer/test/mocks.ts

53 lines
1.2 KiB
TypeScript
Raw Normal View History

2021-07-12 08:43:46 +02:00
import express from "express";
2021-09-23 00:52:35 +02:00
import { config } from "../src/config";
2021-07-12 08:43:46 +02:00
import { Server } from "http";
2020-10-17 20:56:54 +02:00
const app = express();
2021-07-12 08:43:46 +02:00
app.post("/ReportChannelWebhook", (req, res) => {
2020-10-17 20:56:54 +02:00
res.sendStatus(200);
});
2021-07-12 08:43:46 +02:00
app.post("/FirstTimeSubmissionsWebhook", (req, res) => {
2020-10-17 20:56:54 +02:00
res.sendStatus(200);
});
2021-07-12 08:43:46 +02:00
app.post("/CompletelyIncorrectReportWebhook", (req, res) => {
2020-10-17 20:56:54 +02:00
res.sendStatus(200);
});
// Testing NeuralBlock
2021-07-12 08:43:46 +02:00
app.post("/NeuralBlockRejectWebhook", (req, res) => {
2020-10-17 20:56:54 +02:00
res.sendStatus(200);
});
2021-07-12 08:43:46 +02:00
app.get("/NeuralBlock/api/checkSponsorSegments", (req, res) => {
2020-10-17 20:56:54 +02:00
if (req.query.vid === "LevkAjUE6d4") {
res.json({
probabilities: [0.69],
});
return;
}
res.sendStatus(500);
});
//getSponsorSegments is no longer being used for automod
2021-07-12 08:43:46 +02:00
app.get("/NeuralBlock/api/getSponsorSegments", (req, res) => {
2020-10-17 20:56:54 +02:00
if (req.query.vid === "LevkAjUE6d4") {
res.json({
sponsorSegments: [[0.47, 7.549], [264.023, 317.293]],
});
return;
}
res.sendStatus(500);
});
// Testing webhooks
2021-07-12 08:43:46 +02:00
app.post("/CustomWebhook", (req, res) => {
2020-10-17 20:56:54 +02:00
res.sendStatus(200);
});
2021-07-05 09:14:05 +02:00
export function createMockServer(callback: () => void): Server {
2020-10-17 20:56:54 +02:00
return app.listen(config.mockPort, callback);
}