mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
fix(api): 🐛 Improve notification text
This commit is contained in:
parent
1c543723fb
commit
3484b1e1a1
2 changed files with 17 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import type { ContentFormat } from "@versia/federation/types";
|
||||
import { lookup } from "mime-types";
|
||||
import { config } from "~/packages/config-manager";
|
||||
import { htmlToText as htmlToTextLib } from "html-to-text";
|
||||
|
||||
export const getBestContentType = (
|
||||
content?: ContentFormat | null,
|
||||
|
|
@ -77,3 +78,17 @@ export const mimeLookup = (url: string): Promise<string> => {
|
|||
|
||||
return fetchLookup;
|
||||
};
|
||||
|
||||
export const htmlToText = (html: string): string => {
|
||||
return htmlToTextLib(html, {
|
||||
selectors: [
|
||||
{
|
||||
selector: "a",
|
||||
options: {
|
||||
hideLinkHrefIfSameAsText: true,
|
||||
ignoreHref: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue