Merge branch 'feat/1.1.0/report' into test

This commit is contained in:
LinkinStars 2023-05-24 17:11:00 +08:00
commit 81fd961b58
7 changed files with 41 additions and 13 deletions

View File

@ -34,6 +34,8 @@ backend:
other: Unpin
show:
other: List
invite_someone_to_answer:
other: Edit
role:
name:
user:

View File

@ -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 {

View File

@ -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

View File

@ -123,9 +123,12 @@ func (ns *NotificationService) GetNotificationPage(ctx context.Context, searchCo
if !ok {
return pager.NewPageModel(0, resp), nil
}
searchInboxType, ok := schema.NotificationInboxType[searchCond.InboxTypeStr]
if !ok {
return pager.NewPageModel(0, resp), nil
searchInboxType := schema.NotificationInboxTypeAll
if searchType == schema.NotificationTypeInbox {
searchInboxType, ok = schema.NotificationInboxType[searchCond.InboxTypeStr]
if !ok {
return pager.NewPageModel(0, resp), nil
}
}
searchCond.Type = searchType
searchCond.InboxType = searchInboxType

View File

@ -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"
)

View File

@ -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
}

View File

@ -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
}