Skip to content

Commit

Permalink
improve listHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
nkonev committed Jan 16, 2025
1 parent 0d64de6 commit 752ce12
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions storage/handlers/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,20 +383,22 @@ func (h *FilesHandler) listHandler(c echo.Context, public bool) error {
}

var userId *int64
var overrideChatId, overrideMessageId int64
if !public {
if userPrincipalDto == nil {
return c.NoContent(http.StatusUnauthorized)
} else {
userId = &userPrincipalDto.UserId
}
overrideChatId = utils.ChatIdNonExistent
overrideMessageId = utils.MessageIdNonExistent
} else { // userPrincipalDto == nil and userId == nil
overrideChatId = getOverrideChatIdPublic(c)
overrideMessageId = getOverrideMessageIdPublic(c)
}
// else userPrincipalDto == nil and userId == nil

fileItemUuid := c.QueryParam("fileItemUuid")

overrideChatId := getOverrideChatIdPublic(c)
overrideMessageId := getOverrideMessageIdPublic(c)

if ok, err := h.restClient.CheckAccessExtended(c.Request().Context(), userId, chatId, overrideChatId, overrideMessageId, fileItemUuid); err != nil {
return c.NoContent(http.StatusInternalServerError)
} else if !ok {
Expand Down

0 comments on commit 752ce12

Please sign in to comment.