mirror of https://gitee.com/answerdev/answer.git
Merge branch 'feat/1.2.0/user' into test
This commit is contained in:
commit
b2115339d9
|
@ -29,18 +29,16 @@ type GetObjectTimelineResp struct {
|
|||
|
||||
// ActObjectTimeline act object timeline
|
||||
type ActObjectTimeline struct {
|
||||
ActivityID string `json:"activity_id"`
|
||||
RevisionID string `json:"revision_id"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
ActivityType string `json:"activity_type"`
|
||||
Username string `json:"username"`
|
||||
UserDisplayName string `json:"user_display_name"`
|
||||
Comment string `json:"comment"`
|
||||
ObjectID string `json:"object_id"`
|
||||
ObjectType string `json:"object_type"`
|
||||
Cancelled bool `json:"cancelled"`
|
||||
CancelledAt int64 `json:"cancelled_at"`
|
||||
UserID string `json:"id"`
|
||||
ActivityID string `json:"activity_id"`
|
||||
RevisionID string `json:"revision_id"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
ActivityType string `json:"activity_type"`
|
||||
Comment string `json:"comment"`
|
||||
ObjectID string `json:"object_id"`
|
||||
ObjectType string `json:"object_type"`
|
||||
Cancelled bool `json:"cancelled"`
|
||||
CancelledAt int64 `json:"cancelled_at"`
|
||||
UserInfo *UserBasicInfo `json:"user_info,omitempty"`
|
||||
}
|
||||
|
||||
// ActObjectInfo act object info
|
||||
|
|
|
@ -369,6 +369,7 @@ type QuestionPageRespOperator struct {
|
|||
Username string `json:"username"`
|
||||
Rank int `json:"rank"`
|
||||
DisplayName string `json:"display_name"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type AdminQuestionPageReq struct {
|
||||
|
|
|
@ -91,6 +91,7 @@ func (as *ActivityService) GetObjectTimeline(ctx context.Context, req *schema.Ge
|
|||
CreatedAt: act.CreatedAt.Unix(),
|
||||
Cancelled: act.Cancelled == entity.ActivityCancelled,
|
||||
ObjectID: act.ObjectID,
|
||||
UserInfo: &schema.UserBasicInfo{},
|
||||
}
|
||||
item.ObjectType, _ = obj.GetObjectTypeStrByObjectID(act.ObjectID)
|
||||
if item.Cancelled {
|
||||
|
@ -120,13 +121,13 @@ func (as *ActivityService) GetObjectTimeline(ctx context.Context, req *schema.Ge
|
|||
|
||||
// if activity is down vote, only admin can see who does it.
|
||||
if item.ActivityType == constant.ActDownVote && !req.IsAdmin {
|
||||
item.Username = "N/A"
|
||||
item.UserDisplayName = "N/A"
|
||||
item.UserInfo.Username = "N/A"
|
||||
item.UserInfo.DisplayName = "N/A"
|
||||
} else {
|
||||
if act.TriggerUserID > 0 {
|
||||
item.UserID = fmt.Sprintf("%d", act.TriggerUserID)
|
||||
item.UserInfo.ID = fmt.Sprintf("%d", act.TriggerUserID)
|
||||
} else {
|
||||
item.UserID = act.UserID
|
||||
item.UserInfo.ID = act.UserID
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,10 +210,10 @@ func (as *ActivityService) formatTimelineUserInfo(ctx context.Context, timeline
|
|||
userExist := make(map[string]bool)
|
||||
userIDs := make([]string, 0)
|
||||
for _, info := range timeline {
|
||||
if len(info.UserID) == 0 || userExist[info.UserID] {
|
||||
if len(info.UserInfo.ID) == 0 || userExist[info.UserInfo.ID] {
|
||||
continue
|
||||
}
|
||||
userIDs = append(userIDs, info.UserID)
|
||||
userIDs = append(userIDs, info.UserInfo.ID)
|
||||
}
|
||||
if len(userIDs) == 0 {
|
||||
return
|
||||
|
@ -223,13 +224,10 @@ func (as *ActivityService) formatTimelineUserInfo(ctx context.Context, timeline
|
|||
return
|
||||
}
|
||||
for _, info := range timeline {
|
||||
if len(info.UserID) == 0 {
|
||||
if len(info.UserInfo.ID) == 0 {
|
||||
continue
|
||||
}
|
||||
if userInfo, ok := userInfoMapping[info.UserID]; ok {
|
||||
info.Username = userInfo.Username
|
||||
info.UserDisplayName = userInfo.DisplayName
|
||||
}
|
||||
info.UserInfo = userInfoMapping[info.UserInfo.ID]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -387,6 +387,7 @@ func (qs *QuestionCommon) FormatQuestionsPage(
|
|||
item.Operator.DisplayName = userInfo.DisplayName
|
||||
item.Operator.Username = userInfo.Username
|
||||
item.Operator.Rank = userInfo.Rank
|
||||
item.Operator.Status = userInfo.Status
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -124,6 +124,9 @@ func (vs *VoteService) VoteDown(ctx context.Context, req *schema.VoteReq) (resp
|
|||
voteDownOperationInfo := vs.createVoteOperationInfo(ctx, req.UserID, false, objectInfo)
|
||||
if req.IsCancel {
|
||||
err = vs.voteRepo.CancelVote(ctx, voteDownOperationInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
// cancel vote up if exist
|
||||
err = vs.voteRepo.CancelVote(ctx, vs.createVoteOperationInfo(ctx, req.UserID, true, objectInfo))
|
||||
|
@ -131,6 +134,9 @@ func (vs *VoteService) VoteDown(ctx context.Context, req *schema.VoteReq) (resp
|
|||
return nil, err
|
||||
}
|
||||
err = vs.voteRepo.Vote(ctx, voteDownOperationInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
resp = &schema.VoteResp{}
|
||||
|
|
|
@ -1 +1 @@
|
|||
github.com/answerdev/plugins/connector/basic@latest
|
||||
github.com/answerdev/answer-basic-connector@latest
|
Loading…
Reference in New Issue