Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix(notification): missing unsubscribe code

LinkinStars3b1324b83b08
diff --git a/internal/service/answer_service.go b/internal/service/answer_service.go
index 52f6adca..4c0e57b6 100644
--- a/internal/service/answer_service.go
+++ b/internal/service/answer_service.go
@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
+ "github.com/answerdev/answer/pkg/token"
"time"
"github.com/answerdev/answer/internal/base/constant"
@@ -22,7 +23,6 @@ import (
"github.com/answerdev/answer/internal/service/revision_common"
"github.com/answerdev/answer/internal/service/role"
usercommon "github.com/answerdev/answer/internal/service/user_common"
- "github.com/answerdev/answer/pkg/encryption"
"github.com/answerdev/answer/pkg/uid"
"github.com/segmentfault/pacman/errors"
"github.com/segmentfault/pacman/log"
@@ -626,7 +626,7 @@ func (as *AnswerService) notificationAnswerTheQuestion(ctx context.Context,
QuestionID: questionID,
AnswerID: answerID,
AnswerSummary: answerSummary,
- UnsubscribeCode: encryption.MD5(receiverUserInfo.Pass),
+ UnsubscribeCode: token.GenerateToken(),
}
answerUser, _, _ := as.userCommon.GetUserBasicInfoByID(ctx, answerUserID)
if answerUser != nil {
diff --git a/internal/service/comment/comment_service.go b/internal/service/comment/comment_service.go
index 7756ef21..295572f1 100644
--- a/internal/service/comment/comment_service.go
+++ b/internal/service/comment/comment_service.go
@@ -2,6 +2,7 @@ package comment
import (
"context"
+ "github.com/answerdev/answer/pkg/token"
"time"
"github.com/answerdev/answer/internal/base/constant"
@@ -17,7 +18,6 @@ import (
"github.com/answerdev/answer/internal/service/object_info"
"github.com/answerdev/answer/internal/service/permission"
usercommon "github.com/answerdev/answer/internal/service/user_common"
- "github.com/answerdev/answer/pkg/encryption"
"github.com/answerdev/answer/pkg/htmltext"
"github.com/answerdev/answer/pkg/uid"
"github.com/jinzhu/copier"
@@ -508,7 +508,7 @@ func (cs *CommentService) notificationQuestionComment(ctx context.Context, quest
QuestionID: questionID,
CommentID: commentID,
CommentSummary: commentSummary,
- UnsubscribeCode: encryption.MD5(receiverUserInfo.Pass),
+ UnsubscribeCode: token.GenerateToken(),
}
commentUser, _, _ := cs.userCommon.GetUserBasicInfoByID(ctx, commentUserID)
if commentUser != nil {
@@ -556,7 +556,7 @@ func (cs *CommentService) notificationAnswerComment(ctx context.Context,
AnswerID: answerID,
CommentID: commentID,
CommentSummary: commentSummary,
- UnsubscribeCode: encryption.MD5(receiverUserInfo.Pass),
+ UnsubscribeCode: token.GenerateToken(),
}
commentUser, _, _ := cs.userCommon.GetUserBasicInfoByID(ctx, commentUserID)
if commentUser != nil {
diff --git a/internal/service/notification/new_question_notification.go b/internal/service/notification/new_question_notification.go
index 86c8bf32..8533ada3 100644
--- a/internal/service/notification/new_question_notification.go
+++ b/internal/service/notification/new_question_notification.go
@@ -4,6 +4,7 @@ import (
"context"
"github.com/answerdev/answer/internal/base/constant"
"github.com/answerdev/answer/internal/schema"
+ "github.com/answerdev/answer/pkg/token"
"github.com/segmentfault/pacman/i18n"
"github.com/segmentfault/pacman/log"
"time"
@@ -31,9 +32,11 @@ func (ns *ExternalNotificationService) handleNewQuestionNotification(ctx context
switch channel.Key {
case constant.EmailChannel:
ns.sendNewQuestionNotificationEmail(ctx, subscriber.UserID, &schema.NewQuestionTemplateRawData{
- QuestionTitle: msg.NewQuestionTemplateRawData.QuestionTitle,
- QuestionID: msg.NewQuestionTemplateRawData.QuestionID,
- Tags: msg.NewQuestionTemplateRawData.Tags,
+ QuestionTitle: msg.NewQuestionTemplateRawData.QuestionTitle,
+ QuestionID: msg.NewQuestionTemplateRawData.QuestionID,
+ UnsubscribeCode: token.GenerateToken(),
+ Tags: msg.NewQuestionTemplateRawData.Tags,
+ TagIDs: msg.NewQuestionTemplateRawData.TagIDs,
})
}
}
diff --git a/internal/service/question_service.go b/internal/service/question_service.go
index 3af393e0..866b2a47 100644
--- a/internal/service/question_service.go
+++ b/internal/service/question_service.go
@@ -5,6 +5,7 @@ import (
"fmt"
"github.com/answerdev/answer/internal/service/notification"
"github.com/answerdev/answer/internal/service/siteinfo_common"
+ "github.com/answerdev/answer/pkg/token"
"strings"
"time"
@@ -28,7 +29,6 @@ import (
tagcommon "github.com/answerdev/answer/internal/service/tag_common"
usercommon "github.com/answerdev/answer/internal/service/user_common"
"github.com/answerdev/answer/pkg/converter"
- "github.com/answerdev/answer/pkg/encryption"
"github.com/answerdev/answer/pkg/htmltext"
"github.com/answerdev/answer/pkg/uid"
"github.com/jinzhu/copier"
@@ -663,7 +663,7 @@ func (qs *QuestionService) notificationInviteUser(
InviterDisplayName: inviter.DisplayName,
QuestionTitle: questionTitle,
QuestionID: questionID,
- UnsubscribeCode: encryption.MD5(receiverUserInfo.Pass),
+ UnsubscribeCode: token.GenerateToken(),
}
externalNotificationMsg.NewInviteAnswerTemplateRawData = rawData
qs.externalNotificationQueueService.Send(ctx, externalNotificationMsg)