Skip to content

Commit 276e87a

Browse files
committed
feat(notification): self-questioning does not generate notifications
1 parent 85e370d commit 276e87a

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

i18n/en_US.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,16 @@ backend:
339339
other: Your answer has been deleted
340340
your_comment_was_deleted:
341341
other: Your comment has been deleted
342+
up_voted_question:
343+
other: upvoted question
344+
down_voted_question:
345+
other: downvoted question
346+
up_voted_answer:
347+
other: upvoted answer
348+
down_voted_answer:
349+
other: downvoted answer
350+
up_voted_comment:
351+
other: upvoted comment
342352

343353
# The following fields are used for interface presentation(Front-end)
344354
ui:

i18n/zh_CN.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,16 @@ backend:
329329
other: 你的答案已被删除
330330
your_comment_was_deleted:
331331
other: 你的评论已被删除
332+
up_voted_question:
333+
other: 赞了问题
334+
down_voted_question:
335+
other: 踩了问题
336+
up_voted_answer:
337+
other: 赞了答案
338+
down_voted_answer:
339+
other: 踩了答案
340+
up_voted_comment:
341+
other: 赞了评论
332342
#The following fields are used for interface presentation(Front-end)
333343
ui:
334344
how_to_format:

internal/repo/activity/answer_repo.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ func (ar *AnswerActivityRepo) AcceptAnswer(ctx context.Context,
202202
msg.TriggerUserID = questionUserID
203203
msg.ObjectType = constant.AnswerObjectType
204204
}
205-
notice_queue.AddNotification(msg)
205+
if msg.TriggerUserID != msg.ReceiverUserID {
206+
notice_queue.AddNotification(msg)
207+
}
206208
}
207209

208210
for _, act := range addActivityList {

internal/service/notification/notification_service.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ import (
55
"encoding/json"
66
"fmt"
77

8-
"github.com/answerdev/answer/internal/base/constant"
98
"github.com/answerdev/answer/internal/base/data"
9+
"github.com/answerdev/answer/internal/base/handler"
1010
"github.com/answerdev/answer/internal/base/pager"
1111
"github.com/answerdev/answer/internal/base/translator"
1212
"github.com/answerdev/answer/internal/schema"
1313
notficationcommon "github.com/answerdev/answer/internal/service/notification_common"
1414
"github.com/answerdev/answer/internal/service/revision_common"
1515
"github.com/answerdev/answer/pkg/uid"
1616
"github.com/jinzhu/copier"
17-
"github.com/segmentfault/pacman/i18n"
1817
"github.com/segmentfault/pacman/log"
1918
)
2019

@@ -134,7 +133,7 @@ func (ns *NotificationService) GetNotificationPage(ctx context.Context, searchCo
134133
log.Error("NotificationContent Unmarshal Error", err.Error())
135134
continue
136135
}
137-
lang, _ := ctx.Value(constant.AcceptLanguageFlag).(i18n.Language)
136+
lang := handler.GetLangByCtx(ctx)
138137
item.NotificationAction = translator.Tr(lang, item.NotificationAction)
139138
item.ID = notificationInfo.ID
140139
item.UpdateTime = notificationInfo.UpdatedAt.Unix()

0 commit comments

Comments
 (0)