Skip to content

Commit 3b1324b

Browse files
committed
fix(notification): missing unsubscribe code
1 parent 2bd8f7f commit 3b1324b

4 files changed

Lines changed: 13 additions & 10 deletions

File tree

internal/service/answer_service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7+
"github.com/answerdev/answer/pkg/token"
78
"time"
89

910
"github.com/answerdev/answer/internal/base/constant"
@@ -22,7 +23,6 @@ import (
2223
"github.com/answerdev/answer/internal/service/revision_common"
2324
"github.com/answerdev/answer/internal/service/role"
2425
usercommon "github.com/answerdev/answer/internal/service/user_common"
25-
"github.com/answerdev/answer/pkg/encryption"
2626
"github.com/answerdev/answer/pkg/uid"
2727
"github.com/segmentfault/pacman/errors"
2828
"github.com/segmentfault/pacman/log"
@@ -626,7 +626,7 @@ func (as *AnswerService) notificationAnswerTheQuestion(ctx context.Context,
626626
QuestionID: questionID,
627627
AnswerID: answerID,
628628
AnswerSummary: answerSummary,
629-
UnsubscribeCode: encryption.MD5(receiverUserInfo.Pass),
629+
UnsubscribeCode: token.GenerateToken(),
630630
}
631631
answerUser, _, _ := as.userCommon.GetUserBasicInfoByID(ctx, answerUserID)
632632
if answerUser != nil {

internal/service/comment/comment_service.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package comment
22

33
import (
44
"context"
5+
"github.com/answerdev/answer/pkg/token"
56
"time"
67

78
"github.com/answerdev/answer/internal/base/constant"
@@ -17,7 +18,6 @@ import (
1718
"github.com/answerdev/answer/internal/service/object_info"
1819
"github.com/answerdev/answer/internal/service/permission"
1920
usercommon "github.com/answerdev/answer/internal/service/user_common"
20-
"github.com/answerdev/answer/pkg/encryption"
2121
"github.com/answerdev/answer/pkg/htmltext"
2222
"github.com/answerdev/answer/pkg/uid"
2323
"github.com/jinzhu/copier"
@@ -508,7 +508,7 @@ func (cs *CommentService) notificationQuestionComment(ctx context.Context, quest
508508
QuestionID: questionID,
509509
CommentID: commentID,
510510
CommentSummary: commentSummary,
511-
UnsubscribeCode: encryption.MD5(receiverUserInfo.Pass),
511+
UnsubscribeCode: token.GenerateToken(),
512512
}
513513
commentUser, _, _ := cs.userCommon.GetUserBasicInfoByID(ctx, commentUserID)
514514
if commentUser != nil {
@@ -556,7 +556,7 @@ func (cs *CommentService) notificationAnswerComment(ctx context.Context,
556556
AnswerID: answerID,
557557
CommentID: commentID,
558558
CommentSummary: commentSummary,
559-
UnsubscribeCode: encryption.MD5(receiverUserInfo.Pass),
559+
UnsubscribeCode: token.GenerateToken(),
560560
}
561561
commentUser, _, _ := cs.userCommon.GetUserBasicInfoByID(ctx, commentUserID)
562562
if commentUser != nil {

internal/service/notification/new_question_notification.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"github.com/answerdev/answer/internal/base/constant"
66
"github.com/answerdev/answer/internal/schema"
7+
"github.com/answerdev/answer/pkg/token"
78
"github.com/segmentfault/pacman/i18n"
89
"github.com/segmentfault/pacman/log"
910
"time"
@@ -31,9 +32,11 @@ func (ns *ExternalNotificationService) handleNewQuestionNotification(ctx context
3132
switch channel.Key {
3233
case constant.EmailChannel:
3334
ns.sendNewQuestionNotificationEmail(ctx, subscriber.UserID, &schema.NewQuestionTemplateRawData{
34-
QuestionTitle: msg.NewQuestionTemplateRawData.QuestionTitle,
35-
QuestionID: msg.NewQuestionTemplateRawData.QuestionID,
36-
Tags: msg.NewQuestionTemplateRawData.Tags,
35+
QuestionTitle: msg.NewQuestionTemplateRawData.QuestionTitle,
36+
QuestionID: msg.NewQuestionTemplateRawData.QuestionID,
37+
UnsubscribeCode: token.GenerateToken(),
38+
Tags: msg.NewQuestionTemplateRawData.Tags,
39+
TagIDs: msg.NewQuestionTemplateRawData.TagIDs,
3740
})
3841
}
3942
}

internal/service/question_service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"github.com/answerdev/answer/internal/service/notification"
77
"github.com/answerdev/answer/internal/service/siteinfo_common"
8+
"github.com/answerdev/answer/pkg/token"
89
"strings"
910
"time"
1011

@@ -28,7 +29,6 @@ import (
2829
tagcommon "github.com/answerdev/answer/internal/service/tag_common"
2930
usercommon "github.com/answerdev/answer/internal/service/user_common"
3031
"github.com/answerdev/answer/pkg/converter"
31-
"github.com/answerdev/answer/pkg/encryption"
3232
"github.com/answerdev/answer/pkg/htmltext"
3333
"github.com/answerdev/answer/pkg/uid"
3434
"github.com/jinzhu/copier"
@@ -663,7 +663,7 @@ func (qs *QuestionService) notificationInviteUser(
663663
InviterDisplayName: inviter.DisplayName,
664664
QuestionTitle: questionTitle,
665665
QuestionID: questionID,
666-
UnsubscribeCode: encryption.MD5(receiverUserInfo.Pass),
666+
UnsubscribeCode: token.GenerateToken(),
667667
}
668668
externalNotificationMsg.NewInviteAnswerTemplateRawData = rawData
669669
qs.externalNotificationQueueService.Send(ctx, externalNotificationMsg)

0 commit comments

Comments
 (0)