Revert "refactor"
This reverts commit 6e79b93a5316bf51d05dd432fabdcba5ea95b53f.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import * as React from "react";
|
||||
import { NotificationEventType } from "@shared/types";
|
||||
import { Collection, Notification, User } from "@server/models";
|
||||
import { Collection, User } from "@server/models";
|
||||
import NotificationSettingsHelper from "@server/models/helpers/NotificationSettingsHelper";
|
||||
import BaseEmail, { EmailProps } from "./BaseEmail";
|
||||
import Body from "./components/Body";
|
||||
@@ -32,20 +32,6 @@ export default class CollectionCreatedEmail extends BaseEmail<
|
||||
InputProps,
|
||||
BeforeSend
|
||||
> {
|
||||
public constructor(notification: Notification) {
|
||||
super(
|
||||
{
|
||||
to: notification.user.email,
|
||||
userId: notification.userId,
|
||||
collectionId: notification.collectionId,
|
||||
teamUrl: notification.team.url,
|
||||
},
|
||||
{
|
||||
notificationId: notification.id,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
protected async beforeSend({ userId, collectionId }: Props) {
|
||||
const collection = await Collection.scope("withUser").findByPk(
|
||||
collectionId
|
||||
|
||||
@@ -3,13 +3,7 @@ import * as React from "react";
|
||||
import { NotificationEventType } from "@shared/types";
|
||||
import { Day } from "@shared/utils/time";
|
||||
import env from "@server/env";
|
||||
import {
|
||||
Collection,
|
||||
Comment,
|
||||
Document,
|
||||
Notification,
|
||||
User,
|
||||
} from "@server/models";
|
||||
import { Collection, Comment, Document, User } from "@server/models";
|
||||
import DocumentHelper from "@server/models/helpers/DocumentHelper";
|
||||
import NotificationSettingsHelper from "@server/models/helpers/NotificationSettingsHelper";
|
||||
import ProsemirrorHelper from "@server/models/helpers/ProsemirrorHelper";
|
||||
@@ -50,22 +44,6 @@ export default class CommentCreatedEmail extends BaseEmail<
|
||||
InputProps,
|
||||
BeforeSend
|
||||
> {
|
||||
public constructor(notification: Notification) {
|
||||
super(
|
||||
{
|
||||
to: notification.user.email,
|
||||
userId: notification.userId,
|
||||
documentId: notification.documentId,
|
||||
teamUrl: notification.team.url,
|
||||
actorName: notification.actor.name,
|
||||
commentId: notification.commentId,
|
||||
},
|
||||
{
|
||||
notificationId: notification.id,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
protected async beforeSend({ documentId, userId, commentId }: InputProps) {
|
||||
const document = await Document.unscoped().findByPk(documentId);
|
||||
if (!document) {
|
||||
|
||||
@@ -3,13 +3,7 @@ import * as React from "react";
|
||||
import { NotificationEventType } from "@shared/types";
|
||||
import { Day } from "@shared/utils/time";
|
||||
import env from "@server/env";
|
||||
import {
|
||||
Collection,
|
||||
Comment,
|
||||
Document,
|
||||
Notification,
|
||||
User,
|
||||
} from "@server/models";
|
||||
import { Collection, Comment, Document, User } from "@server/models";
|
||||
import DocumentHelper from "@server/models/helpers/DocumentHelper";
|
||||
import NotificationSettingsHelper from "@server/models/helpers/NotificationSettingsHelper";
|
||||
import ProsemirrorHelper from "@server/models/helpers/ProsemirrorHelper";
|
||||
@@ -48,22 +42,6 @@ export default class CommentMentionedEmail extends BaseEmail<
|
||||
InputProps,
|
||||
BeforeSend
|
||||
> {
|
||||
public constructor(notification: Notification) {
|
||||
super(
|
||||
{
|
||||
to: notification.user.email,
|
||||
userId: notification.userId,
|
||||
documentId: notification.documentId,
|
||||
teamUrl: notification.team.url,
|
||||
actorName: notification.actor.name,
|
||||
commentId: notification.commentId,
|
||||
},
|
||||
{
|
||||
notificationId: notification.id,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
protected async beforeSend({ documentId, commentId, userId }: InputProps) {
|
||||
const document = await Document.unscoped().findByPk(documentId);
|
||||
if (!document) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as React from "react";
|
||||
import { Document, Notification } from "@server/models";
|
||||
import { Document } from "@server/models";
|
||||
import BaseEmail, { EmailProps } from "./BaseEmail";
|
||||
import Body from "./components/Body";
|
||||
import Button from "./components/Button";
|
||||
@@ -26,20 +26,6 @@ export default class DocumentMentionedEmail extends BaseEmail<
|
||||
InputProps,
|
||||
BeforeSend
|
||||
> {
|
||||
public constructor(notification: Notification) {
|
||||
super(
|
||||
{
|
||||
to: notification.user.email,
|
||||
documentId: notification.documentId,
|
||||
teamUrl: notification.team.url,
|
||||
actorName: notification.actor.name,
|
||||
},
|
||||
{
|
||||
notificationId: notification.id,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
protected async beforeSend({ documentId }: InputProps) {
|
||||
const document = await Document.unscoped().findByPk(documentId);
|
||||
if (!document) {
|
||||
|
||||
@@ -3,13 +3,7 @@ import * as React from "react";
|
||||
import { NotificationEventType } from "@shared/types";
|
||||
import { Day } from "@shared/utils/time";
|
||||
import env from "@server/env";
|
||||
import {
|
||||
Document,
|
||||
Collection,
|
||||
User,
|
||||
Revision,
|
||||
Notification,
|
||||
} from "@server/models";
|
||||
import { Document, Collection, User, Revision } from "@server/models";
|
||||
import DocumentHelper from "@server/models/helpers/DocumentHelper";
|
||||
import NotificationSettingsHelper from "@server/models/helpers/NotificationSettingsHelper";
|
||||
import BaseEmail, { EmailProps } from "./BaseEmail";
|
||||
@@ -50,25 +44,6 @@ export default class DocumentPublishedOrUpdatedEmail extends BaseEmail<
|
||||
InputProps,
|
||||
BeforeSend
|
||||
> {
|
||||
public constructor(notification: Notification) {
|
||||
super(
|
||||
{
|
||||
to: notification.user.email,
|
||||
userId: notification.userId,
|
||||
eventType: notification.event as
|
||||
| NotificationEventType.PublishDocument
|
||||
| NotificationEventType.UpdateDocument,
|
||||
revisionId: notification.revisionId,
|
||||
documentId: notification.documentId,
|
||||
teamUrl: notification.team.url,
|
||||
actorName: notification.actor.name,
|
||||
},
|
||||
{
|
||||
notificationId: notification.id,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
protected async beforeSend({
|
||||
documentId,
|
||||
revisionId,
|
||||
|
||||
@@ -21,30 +21,79 @@ export default class NotificationsProcessor extends BaseProcessor {
|
||||
return;
|
||||
}
|
||||
|
||||
const notificationId = notification.id;
|
||||
|
||||
switch (notification.event) {
|
||||
case NotificationEventType.UpdateDocument:
|
||||
case NotificationEventType.PublishDocument: {
|
||||
await new DocumentPublishedOrUpdatedEmail(notification).schedule();
|
||||
await new DocumentPublishedOrUpdatedEmail(
|
||||
{
|
||||
to: notification.user.email,
|
||||
userId: notification.userId,
|
||||
eventType: notification.event,
|
||||
revisionId: notification.revisionId,
|
||||
documentId: notification.documentId,
|
||||
teamUrl: notification.team.url,
|
||||
actorName: notification.actor.name,
|
||||
},
|
||||
{ notificationId }
|
||||
).schedule();
|
||||
return;
|
||||
}
|
||||
|
||||
case NotificationEventType.MentionedInDocument: {
|
||||
await new DocumentMentionedEmail(notification).schedule();
|
||||
await new DocumentMentionedEmail(
|
||||
{
|
||||
to: notification.user.email,
|
||||
documentId: notification.documentId,
|
||||
teamUrl: notification.team.url,
|
||||
actorName: notification.actor.name,
|
||||
},
|
||||
{ notificationId }
|
||||
).schedule();
|
||||
return;
|
||||
}
|
||||
|
||||
case NotificationEventType.MentionedInComment: {
|
||||
await new CommentMentionedEmail(notification).schedule();
|
||||
await new CommentMentionedEmail(
|
||||
{
|
||||
to: notification.user.email,
|
||||
userId: notification.userId,
|
||||
documentId: notification.documentId,
|
||||
teamUrl: notification.team.url,
|
||||
actorName: notification.actor.name,
|
||||
commentId: notification.commentId,
|
||||
},
|
||||
{ notificationId: notification.id }
|
||||
).schedule();
|
||||
return;
|
||||
}
|
||||
|
||||
case NotificationEventType.CreateCollection: {
|
||||
await new CollectionCreatedEmail(notification).schedule();
|
||||
await new CollectionCreatedEmail(
|
||||
{
|
||||
to: notification.user.email,
|
||||
userId: notification.userId,
|
||||
collectionId: notification.collectionId,
|
||||
teamUrl: notification.team.url,
|
||||
},
|
||||
{ notificationId: notification.id }
|
||||
).schedule();
|
||||
return;
|
||||
}
|
||||
|
||||
case NotificationEventType.CreateComment: {
|
||||
await new CommentCreatedEmail(notification).schedule();
|
||||
await new CommentCreatedEmail(
|
||||
{
|
||||
to: notification.user.email,
|
||||
userId: notification.userId,
|
||||
documentId: notification.documentId,
|
||||
teamUrl: notification.team.url,
|
||||
actorName: notification.actor.name,
|
||||
commentId: notification.commentId,
|
||||
},
|
||||
{ notificationId: notification.id }
|
||||
).schedule();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user