diff --git a/api/src/config.js b/api/src/config.js index fc1d5d29..ea61475e 100644 --- a/api/src/config.js +++ b/api/src/config.js @@ -1,12 +1,13 @@ import { getVersion } from "@imput/version-info"; import { services } from "./processing/service-config.js"; +import { friendlyServiceName } from "./processing/service-alias.js"; const version = await getVersion(); const disabledServices = process.env.DISABLED_SERVICES?.split(',') || []; const enabledServices = new Set(Object.keys(services).filter(e => { if (!disabledServices.includes(e)) { - return e; + return friendlyServiceName(e); } })); diff --git a/api/src/processing/match.js b/api/src/processing/match.js index cd30ae70..b1e2538f 100644 --- a/api/src/processing/match.js +++ b/api/src/processing/match.js @@ -6,6 +6,8 @@ import { createResponse } from "../processing/request.js"; import { testers } from "./service-patterns.js"; import matchAction from "./match-action.js"; +import { friendlyServiceName } from "./service-alias.js"; + import bilibili from "./services/bilibili.js"; import reddit from "./services/reddit.js"; import twitter from "./services/twitter.js"; @@ -59,7 +61,7 @@ export default async function(host, patternMatch, obj) { return createResponse("error", { code: "error.api.link.unsupported", context: { - service: host + service: friendlyServiceName(host), } }); } @@ -273,14 +275,14 @@ export default async function(host, patternMatch, obj) { case "link.unsupported": case "content.video.unavailable": context = { - service: host, + service: friendlyServiceName(host), } break; } return createResponse("error", { code: `error.api.${r.error}`, - context + context, }) } @@ -301,7 +303,7 @@ export default async function(host, patternMatch, obj) { return createResponse("error", { code: "error.api.fetch.critical", context: { - service: host + service: friendlyServiceName(host), } }) } diff --git a/api/src/processing/service-alias.js b/api/src/processing/service-alias.js new file mode 100644 index 00000000..e8836c66 --- /dev/null +++ b/api/src/processing/service-alias.js @@ -0,0 +1,11 @@ +const friendlyNames = { + bsky: "bluesky", +} +const friendlyKeys = Object.keys(friendlyNames); + +export const friendlyServiceName = (service) => { + if (service in friendlyKeys) { + return friendlyNames[service]; + } + return service; +}