fix: 修复客服权限与收件箱配置问题
This commit is contained in:
@@ -63,7 +63,20 @@ func (h *InboxHandler) List(c *gin.Context) {
|
||||
perPage := getPageSize(c)
|
||||
offset := (page - 1) * perPage
|
||||
|
||||
inboxes, _, svcErr := h.svc.ListByAccount(c.Request.Context(), accountID, offset, perPage)
|
||||
var (
|
||||
inboxes []model.Inbox
|
||||
svcErr error
|
||||
)
|
||||
if getRole(c) == "administrator" {
|
||||
inboxes, _, svcErr = h.svc.ListByAccount(c.Request.Context(), accountID, offset, perPage)
|
||||
} else {
|
||||
userID := getUserID(c)
|
||||
if userID == 0 {
|
||||
response.AbortWithStatusError(c, http.StatusUnauthorized, response.ErrUnauthorized, "current user is required")
|
||||
return
|
||||
}
|
||||
inboxes, _, svcErr = h.svc.ListByAccountAndUser(c.Request.Context(), accountID, userID, offset, perPage)
|
||||
}
|
||||
if svcErr != nil {
|
||||
c.JSON(http.StatusUnprocessableEntity, gin.H{"error": "failed to list inboxes"})
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user