only push to websub hub in prod mode

This commit is contained in:
2025-07-15 14:20:49 +02:00
parent 611563fe5b
commit f309cd87d1

View File

@ -4,6 +4,7 @@ import type { Post } from '$lib//mastodon/response';
import { Logger } from '$lib/log';
import { Feed } from 'feed';
import fs from 'fs/promises';
const { PROD } = import.meta.env;
const logger = new Logger('RSS');
@ -50,16 +51,14 @@ export function createFeed(posts: Post[]): Feed {
}
export async function saveAtomFeed(feed: Feed) {
await fs.writeFile('feed.xml', feed.atom1(), { encoding: 'utf8' });
if (!WEBSUB_HUB) {
if (!WEBSUB_HUB || !PROD) {
logger.info('Skipping Websub publish. hub configured?', WEBSUB_HUB, 'Production?', PROD);
return;
}
try {
const param = new FormData();
param.append('hub.mode', 'publish');
param.append('hub.url', `${BASE_URL}/feed.xml`);
//const params = new URLSearchParams();
//params.append('hub.mode', 'publish');
//params.append('hub.url', `${BASE_URL}/feed.xml`);
await fetch(WEBSUB_HUB, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },