summaryrefslogtreecommitdiff
path: root/src/services/create-notification.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2021-02-13 12:28:26 +0900
committersyuilo <syuilotan@yahoo.co.jp>2021-02-13 12:28:26 +0900
commitebadd7fd3f255af3dd5035afe1d0d75337fa39a4 (patch)
tree5a441d13c74092560b913b5eef4ff4252f128fd5 /src/services/create-notification.ts
parentMerge pull request #7187 from syuilo/dependabot/npm_and_yarn/typescript-4.1.5 (diff)
downloadsharkey-ebadd7fd3f255af3dd5035afe1d0d75337fa39a4.tar.gz
sharkey-ebadd7fd3f255af3dd5035afe1d0d75337fa39a4.tar.bz2
sharkey-ebadd7fd3f255af3dd5035afe1d0d75337fa39a4.zip
wip: email notification
Diffstat (limited to 'src/services/create-notification.ts')
-rw-r--r--src/services/create-notification.ts27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/services/create-notification.ts b/src/services/create-notification.ts
index 5dddaa5727..6cd116040a 100644
--- a/src/services/create-notification.ts
+++ b/src/services/create-notification.ts
@@ -4,6 +4,7 @@ import { Notifications, Mutings, UserProfiles } from '../models';
import { genId } from '../misc/gen-id';
import { User } from '../models/entities/user';
import { Notification } from '../models/entities/notification';
+import { sendEmailNotification } from './send-email-notification';
export async function createNotification(
notifieeId: User['id'],
@@ -38,20 +39,22 @@ export async function createNotification(
setTimeout(async () => {
const fresh = await Notifications.findOne(notification.id);
if (fresh == null) return; // 既に削除されているかもしれない
- if (!fresh.isRead) {
- //#region ただしミュートしているユーザーからの通知なら無視
- const mutings = await Mutings.find({
- muterId: notifieeId
- });
- if (data.notifierId && mutings.map(m => m.muteeId).includes(data.notifierId)) {
- return;
- }
- //#endregion
+ if (fresh.isRead) return;
- publishMainStream(notifieeId, 'unreadNotification', packed);
-
- pushSw(notifieeId, 'notification', packed);
+ //#region ただしミュートしているユーザーからの通知なら無視
+ const mutings = await Mutings.find({
+ muterId: notifieeId
+ });
+ if (data.notifierId && mutings.map(m => m.muteeId).includes(data.notifierId)) {
+ return;
}
+ //#endregion
+
+ publishMainStream(notifieeId, 'unreadNotification', packed);
+
+ pushSw(notifieeId, 'notification', packed);
+ if (type === 'follow') sendEmailNotification.follow(notifieeId, data);
+ if (type === 'receiveFollowRequest') sendEmailNotification.receiveFollowRequest(notifieeId, data);
}, 2000);
return notification;