email refactor
This commit is contained in:
@@ -4,7 +4,7 @@ const { ForumPost, ForumComment, PostTag, User } = require('../models');
|
||||
const { authenticateToken } = require('../middleware/auth');
|
||||
const { uploadForumPostImages, uploadForumCommentImages } = require('../middleware/upload');
|
||||
const logger = require('../utils/logger');
|
||||
const emailService = require('../services/emailService');
|
||||
const emailServices = require('../services/email');
|
||||
const router = express.Router();
|
||||
|
||||
// Helper function to build nested comment tree
|
||||
@@ -489,7 +489,7 @@ router.patch('/posts/:id/accept-answer', authenticateToken, async (req, res) =>
|
||||
|
||||
// Only send email if not marking your own comment as answer
|
||||
if (comment && comment.authorId !== req.user.id) {
|
||||
await emailService.sendForumAnswerAcceptedNotification(
|
||||
await emailServices.forum.sendForumAnswerAcceptedNotification(
|
||||
comment.author,
|
||||
postAuthor,
|
||||
post,
|
||||
@@ -617,7 +617,7 @@ router.post('/posts/:id/comments', authenticateToken, uploadForumCommentImages,
|
||||
|
||||
// Send reply notification if not replying to yourself
|
||||
if (parentComment && parentComment.authorId !== req.user.id) {
|
||||
await emailService.sendForumReplyNotification(
|
||||
await emailServices.forum.sendForumReplyNotification(
|
||||
parentComment.author,
|
||||
commenter,
|
||||
postWithAuthor,
|
||||
@@ -629,7 +629,7 @@ router.post('/posts/:id/comments', authenticateToken, uploadForumCommentImages,
|
||||
} else {
|
||||
// Send comment notification to post author if not commenting on your own post
|
||||
if (postWithAuthor.authorId !== req.user.id) {
|
||||
await emailService.sendForumCommentNotification(
|
||||
await emailServices.forum.sendForumCommentNotification(
|
||||
postWithAuthor.author,
|
||||
commenter,
|
||||
postWithAuthor,
|
||||
@@ -662,7 +662,7 @@ router.post('/posts/:id/comments', authenticateToken, uploadForumCommentImages,
|
||||
// Send thread activity notifications to all unique participants
|
||||
for (const participant of participants) {
|
||||
if (participant.author) {
|
||||
await emailService.sendForumThreadActivityNotification(
|
||||
await emailServices.forum.sendForumThreadActivityNotification(
|
||||
participant.author,
|
||||
commenter,
|
||||
postWithAuthor,
|
||||
|
||||
Reference in New Issue
Block a user