update to use AppError.Where() to differentiate errors (#24379)

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Scott Bishel
2023-09-08 08:17:58 -06:00
коммит произвёл GitHub
родитель 2d1848bf14
Коммит 15faf4a69c
4 изменённых файлов: 13 добавлений и 13 удалений

Просмотреть файл

@@ -263,7 +263,7 @@ func (a *App) SessionHasPermissionToUserOrBot(session model.Session, userID stri
if err == nil {
return true
}
if err.Id == "store.sql_bot.get.missing.app_error" && err.Unwrap() != nil {
if err.Id == "store.sql_bot.get.missing.app_error" && err.Where == "SqlBotStore.Get" {
if a.SessionHasPermissionToUser(session, userID) {
return true
}
@@ -385,7 +385,7 @@ func (a *App) SessionHasPermissionToManageBot(session model.Session, botUserId s
if !a.SessionHasPermissionTo(session, model.PermissionReadBots) {
// If the user doesn't have permission to read bots, pretend as if
// the bot doesn't exist at all.
return model.MakeBotNotFoundError(botUserId)
return model.MakeBotNotFoundError("permissions", botUserId)
}
return a.MakePermissionError(&session, []*model.Permission{model.PermissionManageBots})
}
@@ -394,7 +394,7 @@ func (a *App) SessionHasPermissionToManageBot(session model.Session, botUserId s
if !a.SessionHasPermissionTo(session, model.PermissionReadOthersBots) {
// If the user doesn't have permission to read others' bots,
// pretend as if the bot doesn't exist at all.
return model.MakeBotNotFoundError(botUserId)
return model.MakeBotNotFoundError("permissions", botUserId)
}
return a.MakePermissionError(&session, []*model.Permission{model.PermissionManageOthersBots})
}