mirror of
https://github.com/versia-pub/server.git
synced 2026-01-26 20:26:01 +01:00
fix(api): 🐛 Improve notification text
This commit is contained in:
parent
1c543723fb
commit
3484b1e1a1
|
|
@ -1,6 +1,5 @@
|
||||||
import { Note, PushSubscription, Token, User } from "@versia/kit/db";
|
import { Note, PushSubscription, Token, User } from "@versia/kit/db";
|
||||||
import { Worker } from "bullmq";
|
import { Worker } from "bullmq";
|
||||||
import { htmlToText } from "html-to-text";
|
|
||||||
import { sendNotification } from "web-push";
|
import { sendNotification } from "web-push";
|
||||||
import { config } from "~/packages/config-manager";
|
import { config } from "~/packages/config-manager";
|
||||||
import { connection } from "~/utils/redis.ts";
|
import { connection } from "~/utils/redis.ts";
|
||||||
|
|
@ -9,6 +8,7 @@ import {
|
||||||
type PushJobType,
|
type PushJobType,
|
||||||
pushQueue,
|
pushQueue,
|
||||||
} from "../queues/push.ts";
|
} from "../queues/push.ts";
|
||||||
|
import { htmlToText } from "@/content_types.ts";
|
||||||
|
|
||||||
export const getPushWorker = (): Worker<PushJobData, void, PushJobType> =>
|
export const getPushWorker = (): Worker<PushJobData, void, PushJobType> =>
|
||||||
new Worker<PushJobData, void, PushJobType>(
|
new Worker<PushJobData, void, PushJobType>(
|
||||||
|
|
@ -70,7 +70,7 @@ export const getPushWorker = (): Worker<PushJobData, void, PushJobType> =>
|
||||||
case "reply":
|
case "reply":
|
||||||
title = `${name} replied to you`;
|
title = `${name} replied to you`;
|
||||||
break;
|
break;
|
||||||
case "like":
|
case "favourite":
|
||||||
title = `${name} liked your note`;
|
title = `${name} liked your note`;
|
||||||
break;
|
break;
|
||||||
case "reblog":
|
case "reblog":
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import type { ContentFormat } from "@versia/federation/types";
|
import type { ContentFormat } from "@versia/federation/types";
|
||||||
import { lookup } from "mime-types";
|
import { lookup } from "mime-types";
|
||||||
import { config } from "~/packages/config-manager";
|
import { config } from "~/packages/config-manager";
|
||||||
|
import { htmlToText as htmlToTextLib } from "html-to-text";
|
||||||
|
|
||||||
export const getBestContentType = (
|
export const getBestContentType = (
|
||||||
content?: ContentFormat | null,
|
content?: ContentFormat | null,
|
||||||
|
|
@ -77,3 +78,17 @@ export const mimeLookup = (url: string): Promise<string> => {
|
||||||
|
|
||||||
return fetchLookup;
|
return fetchLookup;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const htmlToText = (html: string): string => {
|
||||||
|
return htmlToTextLib(html, {
|
||||||
|
selectors: [
|
||||||
|
{
|
||||||
|
selector: "a",
|
||||||
|
options: {
|
||||||
|
hideLinkHrefIfSameAsText: true,
|
||||||
|
ignoreHref: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue