feat: define type, prep for company announcements

This commit is contained in:
2025-12-23 12:57:20 -08:00
parent e462c9472d
commit 5b99450b7c
7 changed files with 66 additions and 25 deletions
+3 -2
View File
@@ -12,6 +12,7 @@ import { announceOnReddit } from "../modules/announceOnReddit.js";
import { announceOnTwitter } from "../modules/announceOnTwitter.js";
import { getIpFromRequest } from "../modules/getIpFromRequest.js";
import { summarisePost } from "../modules/summarisePost.js";
import { isAnnouncementType } from "../utils/typeguards.js";
import type { FastifyPluginAsync } from "fastify";
const oneDay = 24 * 60 * 60 * 1000;
@@ -73,10 +74,10 @@ export const announcementRoutes: FastifyPluginAsync = async(server) => {
});
}
if (type !== "products" && type !== "community") {
if (!isAnnouncementType(type)) {
return await reply.status(400).send({
error:
"Invalid announcement type. Available types: products, community.",
`Invalid announcement type. Available types: products, community, company.`,
});
}