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