mirror of
https://github.com/outline/outline.git
synced 2026-11-25 23:24:06 +03:00
* feat: Add email headers to enhance threading * tsc * review * change comment mentioned email subject * paginated load * rename util method * add tests * group events * test for unsupported notification * typo * review
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { NotificationEventType } from "@shared/types";
|
|
import { getBaseDomain } from "@shared/utils/domains";
|
|
|
|
const Domain = getBaseDomain();
|
|
|
|
const EmailThreadSupportedNotifications = [
|
|
NotificationEventType.PublishDocument,
|
|
NotificationEventType.UpdateDocument,
|
|
NotificationEventType.MentionedInDocument,
|
|
NotificationEventType.CreateComment,
|
|
NotificationEventType.MentionedInComment,
|
|
];
|
|
|
|
// Gmail creates a new thread for every 100 messages.
|
|
export const MaxMessagesInEmailThread = 100;
|
|
|
|
export const isEmailThreadSupportedNotification = (
|
|
event: NotificationEventType
|
|
) => EmailThreadSupportedNotifications.includes(event);
|
|
|
|
export const getEmailThreadEventGroup = (
|
|
event: NotificationEventType
|
|
): NotificationEventType[] | undefined => {
|
|
switch (event) {
|
|
case NotificationEventType.PublishDocument:
|
|
case NotificationEventType.UpdateDocument:
|
|
return [
|
|
NotificationEventType.PublishDocument,
|
|
NotificationEventType.UpdateDocument,
|
|
];
|
|
case NotificationEventType.MentionedInDocument:
|
|
case NotificationEventType.MentionedInComment:
|
|
return [
|
|
NotificationEventType.MentionedInDocument,
|
|
NotificationEventType.MentionedInComment,
|
|
];
|
|
case NotificationEventType.CreateComment:
|
|
return [NotificationEventType.CreateComment];
|
|
default:
|
|
return;
|
|
}
|
|
};
|
|
|
|
export const getEmailMessageId = (text: string) => `<${text}@${Domain}>`;
|