mirror of https://gitee.com/answerdev/answer.git
Merge branch 'feat/1.1.0/report' of github.com:answerdev/answer into feat/1.1.0/report
This commit is contained in:
commit
4d1326f0df
|
@ -114,11 +114,11 @@ func (ns *NotificationCommon) AddNotification(ctx context.Context, msg *schema.N
|
|||
if 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 = rank
|
||||
if exist {
|
||||
|
@ -126,17 +126,14 @@ func (ns *NotificationCommon) AddNotification(ctx context.Context, msg *schema.N
|
|||
updateContent := &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.N
|
|||
|
||||
userBasicInfo, 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.N
|
|||
info.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 {
|
||||
|
|
Loading…
Reference in New Issue