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.
chore(notification): format all response error
LinkinStarse0cc9003097d
diff --git a/internal/service/notification_common/notification.go b/internal/service/notification_common/notification.goindex b22f6853..2bf0cf8c 100644--- a/internal/service/notification_common/notification.go+++ b/internal/service/notification_common/notification.go@@ -114,11 +114,11 @@ func (ns *NotificationCommon) AddNotification(ctx context.Context, msg *schema.Nif msg.Type == schema.NotificationTypeAchievement {notificationInfo, exist, err := ns.notificationRepo.GetByUserIdObjectIdTypeId(ctx, req.ReceiverUserID, req.ObjectInfo.ObjectID, req.Type)if err != nil {- return errors.InternalServer(reason.UnknownError).WithError(err).WithStack()+ return fmt.Errorf("get by user id object id type id error: %w", err)}rank, err := ns.activityRepo.GetUserIDObjectIDActivitySum(ctx, req.ReceiverUserID, req.ObjectInfo.ObjectID)if err != nil {- return errors.InternalServer(reason.UnknownError).WithError(err).WithStack()+ return fmt.Errorf("get user id object id activity sum error: %w", err)}req.Rank = rankif exist {@@ -126,17 +126,14 @@ func (ns *NotificationCommon) AddNotification(ctx context.Context, msg *schema.NupdateContent := &schema.NotificationContent{}err := json.Unmarshal([]byte(notificationInfo.Content), updateContent)if err != nil {- return errors.InternalServer(reason.UnknownError).WithError(err).WithStack()+ return fmt.Errorf("unmarshal notification content error: %w", err)}updateContent.Rank = rank- content, err := json.Marshal(updateContent)- if err != nil {- return errors.InternalServer(reason.UnknownError).WithError(err).WithStack()- }+ content, _ := json.Marshal(updateContent)notificationInfo.Content = string(content)err = ns.notificationRepo.UpdateNotificationContent(ctx, notificationInfo)if err != nil {- return errors.InternalServer(reason.UnknownError).WithError(err).WithStack()+ return fmt.Errorf("update notification content error: %w", err)}return nil}@@ -154,16 +151,13 @@ func (ns *NotificationCommon) AddNotification(ctx context.Context, msg *schema.NuserBasicInfo, exist, err := ns.userCommon.GetUserBasicInfoByID(ctx, req.TriggerUserID)if err != nil {- return errors.InternalServer(reason.UnknownError).WithError(err).WithStack()+ return fmt.Errorf("get user basic info error: %w", err)}if !exist {- return errors.InternalServer(reason.UserNotFound).WithError(err).WithStack()+ return fmt.Errorf("user not exist: %s", req.TriggerUserID)}req.UserInfo = userBasicInfo- content, err := json.Marshal(req)- if err != nil {- return errors.InternalServer(reason.UnknownError).WithError(err).WithStack()- }+ content, _ := json.Marshal(req)_, ok := constant.NotificationMsgTypeMapping[req.NotificationAction]if ok {info.MsgType = constant.NotificationMsgTypeMapping[req.NotificationAction]@@ -171,7 +165,7 @@ func (ns *NotificationCommon) AddNotification(ctx context.Context, msg *schema.Ninfo.Content = string(content)err = ns.notificationRepo.AddNotification(ctx, info)if err != nil {- return errors.InternalServer(reason.UnknownError).WithError(err).WithStack()+ return fmt.Errorf("add notification error: %w", err)}err = ns.addRedDot(ctx, info.UserID, info.Type)if err != nil {