You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by li...@apache.org on 2024/09/03 06:16:54 UTC
(incubator-answer) branch feat/1.4.0/badge updated (292dfe6d -> 2eaa7dba)
This is an automated email from the ASF dual-hosted git repository.
linkinstar pushed a change to branch feat/1.4.0/badge
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
from 292dfe6d feat(badge): feat badge description url
new 41d63bd2 feat(badge): delete red dot when no unread notification
add 2e626660 add pvc dataSource
add 5e5551a1 perf: remove invalid nil pointer check in Translate function
add 7d5bfaa3 perf: update check-asf-header.sh script to support Podman
add d63ce367 perf: remove extra characters in header.html
add c50e63dd fix(dev): delete test file
add 83155783 Revert "fix(dev): delete test file"
add 7d8e679d docs: enable wiki
add 15531f42 build swagger documentation on go generate
add 493d5c07 requested changes
add 701343e8 Fix error on multiple make generate runs (#1087)
add 63e1da69 refactor: add err handling for activeUser
new 2eaa7dba Merge remote-tracking branch 'origin/dev' into feat/1.4.0/badge
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.asf.yaml | 2 +-
Makefile | 2 ++
charts/templates/pvc.yaml | 8 ++++++-
charts/values.yaml | 8 ++++++-
cmd/answer/main.go | 7 ++++++
docs/docs.go | 8 +++----
docs/swagger.json | 6 +++++-
docs/swagger.yaml | 4 ++++
go.mod | 5 ++++-
go.sum | 6 ++++++
internal/repo/notification/notification_repo.go | 8 +++++++
internal/router/swagger_router.go | 4 ----
internal/service/content/user_service.go | 2 ++
.../service/notification/notification_service.go | 25 ++++++++++++++++------
.../service/notification_common/notification.go | 15 +++++++++++++
.../user_center_login_service.go | 8 +++++--
plugin/plugin.go | 2 +-
script/check-asf-header.sh | 13 ++++++++++-
ui/template/header.html | 4 ++--
19 files changed, 112 insertions(+), 25 deletions(-)
(incubator-answer) 01/02: feat(badge): delete red dot when no unread notification
Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
linkinstar pushed a commit to branch feat/1.4.0/badge
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit 41d63bd245cd59b3866c94bcd67c9dab6e02a192
Author: LinkinStars <li...@foxmail.com>
AuthorDate: Tue Sep 3 14:16:17 2024 +0800
feat(badge): delete red dot when no unread notification
---
internal/repo/notification/notification_repo.go | 8 +++++++
.../service/notification/notification_service.go | 25 ++++++++++++++++------
.../service/notification_common/notification.go | 15 +++++++++++++
3 files changed, 42 insertions(+), 6 deletions(-)
diff --git a/internal/repo/notification/notification_repo.go b/internal/repo/notification/notification_repo.go
index bd325ef2..5a2a6cc7 100644
--- a/internal/repo/notification/notification_repo.go
+++ b/internal/repo/notification/notification_repo.go
@@ -129,3 +129,11 @@ func (nr *notificationRepo) GetNotificationPage(ctx context.Context, searchCond
}
return
}
+
+func (nr *notificationRepo) CountNotificationByUser(ctx context.Context, cond *entity.Notification) (int64, error) {
+ count, err := nr.data.DB.Context(ctx).Count(cond)
+ if err != nil {
+ err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
+ }
+ return count, err
+}
diff --git a/internal/service/notification/notification_service.go b/internal/service/notification/notification_service.go
index b73d4fda..be2963fe 100644
--- a/internal/service/notification/notification_service.go
+++ b/internal/service/notification/notification_service.go
@@ -23,12 +23,6 @@ import (
"context"
"encoding/json"
"fmt"
- "github.com/apache/incubator-answer/internal/service/badge"
- "github.com/apache/incubator-answer/internal/service/report_common"
- "github.com/apache/incubator-answer/internal/service/review"
- usercommon "github.com/apache/incubator-answer/internal/service/user_common"
- "github.com/apache/incubator-answer/pkg/converter"
-
"github.com/apache/incubator-answer/internal/base/constant"
"github.com/apache/incubator-answer/internal/base/data"
"github.com/apache/incubator-answer/internal/base/handler"
@@ -36,8 +30,13 @@ import (
"github.com/apache/incubator-answer/internal/base/translator"
"github.com/apache/incubator-answer/internal/entity"
"github.com/apache/incubator-answer/internal/schema"
+ "github.com/apache/incubator-answer/internal/service/badge"
notficationcommon "github.com/apache/incubator-answer/internal/service/notification_common"
+ "github.com/apache/incubator-answer/internal/service/report_common"
+ "github.com/apache/incubator-answer/internal/service/review"
"github.com/apache/incubator-answer/internal/service/revision_common"
+ usercommon "github.com/apache/incubator-answer/internal/service/user_common"
+ "github.com/apache/incubator-answer/pkg/converter"
"github.com/apache/incubator-answer/pkg/uid"
"github.com/jinzhu/copier"
"github.com/segmentfault/pacman/log"
@@ -203,6 +202,20 @@ func (ns *NotificationService) ClearIDUnRead(ctx context.Context, userID string,
if err != nil {
log.Errorf("remove badge award alert cache failed: %v", err)
}
+
+ amount, err := ns.notificationRepo.CountNotificationByUser(ctx, &entity.Notification{
+ UserID: userID,
+ Type: notificationInfo.Type,
+ IsRead: schema.NotificationNotRead,
+ Status: schema.NotificationStatusNormal,
+ })
+ if err != nil {
+ log.Errorf("count notification failed: %v", err)
+ return nil
+ }
+ if amount == 0 {
+ _ = ns.notificationCommon.DeleteRedDot(ctx, userID, notificationInfo.Type)
+ }
return nil
}
diff --git a/internal/service/notification_common/notification.go b/internal/service/notification_common/notification.go
index a3129b3a..f3732fcf 100644
--- a/internal/service/notification_common/notification.go
+++ b/internal/service/notification_common/notification.go
@@ -54,6 +54,7 @@ type NotificationRepo interface {
GetByUserIdObjectIdTypeId(ctx context.Context, userID, objectID string, notificationType int) (*entity.Notification, bool, error)
UpdateNotificationContent(ctx context.Context, notification *entity.Notification) (err error)
GetById(ctx context.Context, id string) (*entity.Notification, bool, error)
+ CountNotificationByUser(ctx context.Context, cond *entity.Notification) (int64, error)
}
type NotificationCommon struct {
@@ -226,6 +227,20 @@ func (ns *NotificationCommon) addRedDot(ctx context.Context, userID string, noti
return nil
}
+func (ns *NotificationCommon) DeleteRedDot(ctx context.Context, userID string, notificationType int) error {
+ var key string
+ if notificationType == schema.NotificationTypeInbox {
+ key = fmt.Sprintf(constant.RedDotCacheKey, constant.NotificationTypeInbox, userID)
+ } else {
+ key = fmt.Sprintf(constant.RedDotCacheKey, constant.NotificationTypeAchievement, userID)
+ }
+ err := ns.data.Cache.Del(ctx, key)
+ if err != nil {
+ return errors.InternalServer(reason.UnknownError).WithError(err).WithStack()
+ }
+ return nil
+}
+
// AddBadgeAwardAlertCache add badge award alert cache
func (ns *NotificationCommon) AddBadgeAwardAlertCache(ctx context.Context, userID, notificationID, badgeID string) (err error) {
key := fmt.Sprintf(constant.RedDotCacheKey, constant.NotificationTypeBadgeAchievement, userID)
(incubator-answer) 02/02: Merge remote-tracking branch 'origin/dev' into feat/1.4.0/badge
Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
linkinstar pushed a commit to branch feat/1.4.0/badge
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit 2eaa7dba36fdb750a108b69726fb872a92911618
Merge: 41d63bd2 63e1da69
Author: LinkinStars <li...@foxmail.com>
AuthorDate: Tue Sep 3 14:16:24 2024 +0800
Merge remote-tracking branch 'origin/dev' into feat/1.4.0/badge
.asf.yaml | 2 +-
Makefile | 2 ++
charts/templates/pvc.yaml | 8 +++++++-
charts/values.yaml | 8 +++++++-
cmd/answer/main.go | 7 +++++++
docs/docs.go | 8 ++++----
docs/swagger.json | 6 +++++-
docs/swagger.yaml | 4 ++++
go.mod | 5 ++++-
go.sum | 6 ++++++
internal/router/swagger_router.go | 4 ----
internal/service/content/user_service.go | 2 ++
.../user_external_login/user_center_login_service.go | 8 ++++++--
plugin/plugin.go | 2 +-
script/check-asf-header.sh | 13 ++++++++++++-
ui/template/header.html | 4 ++--
16 files changed, 70 insertions(+), 19 deletions(-)