mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
fix(formatters): use raster PNG forge icons Discord renders
- GitHub footer icon now uses fluidicon.png instead of favicon.ico —
Discord silently drops .ico embed footer icons (png/jpg/webp/gif only)
- Gitea instances use {origin}/assets/img/favicon.png (verified on
codeberg.org and gitea.com); links are still derived from the repo URL
- tests + docs updated to the new icon URLs
This commit is contained in:
parent
c58b800987
commit
c982356e0c
6 changed files with 25 additions and 22 deletions
|
|
@ -166,8 +166,9 @@ export function senderProfileUrl(repoUrl: string | undefined, login: string): st
|
|||
* The event's repository host (github.com for GitHub, the instance hostname
|
||||
* for Gitea) is matched case-insensitively against the configured hosts; the
|
||||
* first entry whose type and host both match wins. The footer label is the
|
||||
* entry's display `name` (or its host when no name is set). Link/favicon are
|
||||
* derived from the repository URL.
|
||||
* entry's display `name` (or its host when no name is set). Link is derived
|
||||
* from the repository URL; the footer icon uses a raster PNG Discord can
|
||||
* render (GitHub's fluidicon, Gitea's /assets/img/favicon.png).
|
||||
*/
|
||||
export function forgeInfo(event: WebhookEvent, sources?: ForgeSource[]): NeutralForge | undefined {
|
||||
const repoUrl = (event.payload.repository as { html_url?: string } | undefined)?.html_url;
|
||||
|
|
@ -187,20 +188,22 @@ export function forgeInfo(event: WebhookEvent, sources?: ForgeSource[]): Neutral
|
|||
if (!source) return undefined;
|
||||
|
||||
const label = source.name?.trim() || source.host;
|
||||
const githubIcon = "https://github.com/fluidicon.png";
|
||||
if (repoUrl) {
|
||||
try {
|
||||
const origin = new URL(repoUrl).origin;
|
||||
return { name: label, url: origin, iconUrl: `${origin}/favicon.ico` };
|
||||
return {
|
||||
name: label,
|
||||
url: origin,
|
||||
iconUrl:
|
||||
event.provider === "github" ? githubIcon : `${origin}/assets/img/favicon.png`,
|
||||
};
|
||||
} catch {
|
||||
// unparseable repo URL — name only
|
||||
}
|
||||
}
|
||||
if (event.provider === "github") {
|
||||
return {
|
||||
name: label,
|
||||
url: "https://github.com",
|
||||
iconUrl: "https://github.com/favicon.ico",
|
||||
};
|
||||
return { name: label, url: "https://github.com", iconUrl: githubIcon };
|
||||
}
|
||||
return { name: label };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue