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
e8265a0ddf
|
@ -34,6 +34,8 @@ backend:
|
|||
other: Unpin
|
||||
show:
|
||||
other: List
|
||||
invite_someone_to_answer:
|
||||
other: Edit
|
||||
role:
|
||||
name:
|
||||
user:
|
||||
|
|
|
@ -109,7 +109,7 @@ func (cc *ConnectorController) ConnectorRedirect(connector plugin.Connector) (fn
|
|||
commonRouterPrefix, ConnectorRedirectRouterPrefix, connector.ConnectorSlugName())
|
||||
userInfo, err := connector.ConnectorReceiver(ctx, receiverURL)
|
||||
if err != nil {
|
||||
log.Errorf("connector received failed: %v", err)
|
||||
log.Errorf("connector received failed, error info: %v, response data is: %s", err, userInfo.MetaInfo)
|
||||
ctx.Redirect(http.StatusFound, "/50x")
|
||||
return
|
||||
}
|
||||
|
|
|
@ -196,6 +196,7 @@ func (qc *QuestionController) GetQuestion(ctx *gin.Context) {
|
|||
permission.QuestionUnPin,
|
||||
permission.QuestionHide,
|
||||
permission.QuestionShow,
|
||||
permission.AnswerInviteSomeoneToAnswer,
|
||||
})
|
||||
if err != nil {
|
||||
handler.HandleResponse(ctx, err, nil)
|
||||
|
@ -211,6 +212,7 @@ func (qc *QuestionController) GetQuestion(ctx *gin.Context) {
|
|||
req.CanUnPin = canList[5]
|
||||
req.CanHide = canList[6]
|
||||
req.CanShow = canList[7]
|
||||
req.CanInviteOtherToAnswer = canList[8]
|
||||
|
||||
info, err := qc.questionService.GetQuestionAndAddPV(ctx, id, userID, req)
|
||||
if err != nil {
|
||||
|
|
|
@ -122,6 +122,8 @@ type QuestionPermission struct {
|
|||
CanShow bool `json:"-"`
|
||||
// whether user can use reserved it
|
||||
CanUseReservedTag bool `json:"-"`
|
||||
// whether user can invite other user to answer this question
|
||||
CanInviteOtherToAnswer bool `json:"-"`
|
||||
}
|
||||
|
||||
type CheckCanQuestionUpdate struct {
|
||||
|
@ -211,7 +213,8 @@ type QuestionInfo struct {
|
|||
IsFollowed bool `json:"is_followed"`
|
||||
|
||||
// MemberActions
|
||||
MemberActions []*PermissionMemberAction `json:"member_actions"`
|
||||
MemberActions []*PermissionMemberAction `json:"member_actions"`
|
||||
ExtendsActions []*PermissionMemberAction `json:"extends_actions"`
|
||||
}
|
||||
|
||||
// UpdateQuestionResp update question resp
|
||||
|
|
|
@ -43,13 +43,14 @@ const (
|
|||
)
|
||||
|
||||
const (
|
||||
reportActionName = "action.report"
|
||||
editActionName = "action.edit"
|
||||
deleteActionName = "action.delete"
|
||||
closeActionName = "action.close"
|
||||
reopenActionName = "action.reopen"
|
||||
pinActionName = "action.pin"
|
||||
unpinActionName = "action.unpin"
|
||||
hideActionName = "action.hide"
|
||||
showActionName = "action.show"
|
||||
reportActionName = "action.report"
|
||||
editActionName = "action.edit"
|
||||
deleteActionName = "action.delete"
|
||||
closeActionName = "action.close"
|
||||
reopenActionName = "action.reopen"
|
||||
pinActionName = "action.pin"
|
||||
unpinActionName = "action.unpin"
|
||||
hideActionName = "action.hide"
|
||||
showActionName = "action.show"
|
||||
inviteSomeoneToAnswerActionName = "action.invite_someone_to_answer"
|
||||
)
|
||||
|
|
|
@ -81,3 +81,19 @@ func GetQuestionPermission(ctx context.Context, userID string, creatorUserID str
|
|||
}
|
||||
return actions
|
||||
}
|
||||
|
||||
// GetQuestionExtendsPermission get question extends permission
|
||||
func GetQuestionExtendsPermission(ctx context.Context, userID string, creatorUserID string,
|
||||
canInviteOtherToAnswer bool) (
|
||||
actions []*schema.PermissionMemberAction) {
|
||||
lang := handler.GetLangByCtx(ctx)
|
||||
actions = make([]*schema.PermissionMemberAction, 0)
|
||||
if canInviteOtherToAnswer || userID == creatorUserID {
|
||||
actions = append(actions, &schema.PermissionMemberAction{
|
||||
Action: "invite_other_to_answer",
|
||||
Name: translator.Tr(lang, inviteSomeoneToAnswerActionName),
|
||||
Type: "confirm",
|
||||
})
|
||||
}
|
||||
return actions
|
||||
}
|
||||
|
|
|
@ -859,6 +859,7 @@ func (qs *QuestionService) GetQuestion(ctx context.Context, questionID, userID s
|
|||
question.Description = htmltext.FetchExcerpt(question.HTML, "...", 240)
|
||||
question.MemberActions = permission.GetQuestionPermission(ctx, userID, question.UserID,
|
||||
per.CanEdit, per.CanDelete, per.CanClose, per.CanReopen, per.CanPin, per.CanHide, per.CanUnPin, per.CanShow)
|
||||
question.ExtendsActions = permission.GetQuestionExtendsPermission(ctx, userID, question.UserID, per.CanInviteOtherToAnswer)
|
||||
return question, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue