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.

update Notification

aichy126bd079a0040a9
diff --git a/internal/repo/notification/notification_repo.go b/internal/repo/notification/notification_repo.go
index 994113fc..21b7bcff 100644
--- a/internal/repo/notification/notification_repo.go
+++ b/internal/repo/notification/notification_repo.go
@@ -96,10 +96,14 @@ func (nr *notificationRepo) GetNotificationPage(ctx context.Context, searchCond
session := nr.data.DB.NewSession()
session = session.Desc("updated_at")
+
cond := &entity.Notification{
UserID: searchCond.UserID,
Type: searchCond.Type,
}
+ if searchCond.InboxType > 0 {
+ cond.MsgType = searchCond.InboxType
+ }
total, err = pager.Help(searchCond.Page, searchCond.PageSize, &notificationList, cond, session)
if err != nil {
err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
diff --git a/internal/schema/notification_schema.go b/internal/schema/notification_schema.go
index fd9569ca..4e617efd 100644
--- a/internal/schema/notification_schema.go
+++ b/internal/schema/notification_schema.go
@@ -7,10 +7,10 @@ const (
NotificationRead = 2
NotificationStatusNormal = 1
NotificationStatusDelete = 10
- NotificationInboxTypeAll = 1
- NotificationInboxTypePosts = 2
+ NotificationInboxTypeAll = 0
+ NotificationInboxTypePosts = 1
+ NotificationInboxTypeVotes = 2
NotificationInboxTypeInvites = 3
- NotificationInboxTypeVotes = 4
)
var NotificationType = map[string]int{
diff --git a/internal/service/notification/notification_service.go b/internal/service/notification/notification_service.go
index 6402f395..6e7d09d6 100644
--- a/internal/service/notification/notification_service.go
+++ b/internal/service/notification/notification_service.go
@@ -125,9 +125,9 @@ func (ns *NotificationService) GetNotificationPage(ctx context.Context, searchCo
}
searchInboxType := schema.NotificationInboxTypeAll
if searchType == schema.NotificationTypeInbox {
- searchInboxType, ok = schema.NotificationInboxType[searchCond.InboxTypeStr]
- if !ok {
- return pager.NewPageModel(0, resp), nil
+ _, ok = schema.NotificationInboxType[searchCond.InboxTypeStr]
+ if ok {
+ searchInboxType = schema.NotificationInboxType[searchCond.InboxTypeStr]
}
}
searchCond.Type = searchType