more housekeeping

This commit is contained in:
orangecoding
2026-06-03 10:19:50 +02:00
parent c29387c85d
commit e95ebb9624
8 changed files with 168 additions and 147 deletions

View File

@@ -7,6 +7,7 @@ import fetch from 'node-fetch';
import { getJob } from '../../services/storage/jobStorage.js';
import { markdown2Html } from '../../services/markdown.js';
import { normalizeImageUrl } from '../../utils.js';
import logger from '../../services/logger.js';
/**
* Generates an idempotent decimal color code. The input string-based color code is
@@ -67,19 +68,6 @@ const buildEmbed = (jobKey, listing, baseUrl) => {
},
];
const embed = {
title: title,
color: generateColorFromString(jobKey),
url: listing.link,
fields: fields,
};
if (listing.image) {
embed.image = {
url: normalizeImageUrl(listing.image),
};
}
if (baseUrl && listing.id) {
fields.push({
name: 'Open in Fredy',
@@ -88,6 +76,19 @@ const buildEmbed = (jobKey, listing, baseUrl) => {
});
}
const embed = {
title: title,
color: generateColorFromString(jobKey),
url: listing.link,
fields,
};
if (listing.image) {
embed.image = {
url: normalizeImageUrl(listing.image),
};
}
return embed;
};
@@ -119,7 +120,7 @@ export const send = ({ serviceName, newListings, notificationConfig, jobKey, bas
headers: { 'Content-Type': 'application/json' },
body,
}).catch((error) => {
console.error(`Error sending Discord webhook for chunk starting at ${i}:`, error);
logger.error(`Error sending Discord webhook for chunk starting at ${i}:`, error);
return Promise.reject(new Error(`Webhook failed: ${error.message}`));
});