Skip to content

Commit

Permalink
[MM-14727] Added error handling for when fetching a bot owner's user …
Browse files Browse the repository at this point in the history
…fails
  • Loading branch information
Wipeout55 committed Jun 11, 2019
1 parent ebe36b1 commit c8629da
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package app
import (
"github.com/mattermost/mattermost-server/mlog"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/store"
"github.com/mattermost/mattermost-server/utils"
)

Expand All @@ -24,8 +25,11 @@ func (a *App) CreateBot(bot *model.Bot) (*model.Bot, *model.AppError) {
}

// Get the owner of the bot, if one exists. If not, don't send a message
ownerUser, _ := a.Srv.Store.User().Get(bot.OwnerId)
if ownerUser != nil {
ownerUser, err := a.Srv.Store.User().Get(bot.OwnerId)
if err != nil && err.Id != store.MISSING_ACCOUNT_ERROR {
mlog.Error(err.Error())
return nil, err
} else if ownerUser != nil {
// Send a message to the bot's creator to inform them that the bot needs to be added
// to a team and channel after it's created
channel, err := a.GetOrCreateDirectChannel(result.Data.(*model.Bot).UserId, bot.OwnerId)
Expand Down

0 comments on commit c8629da

Please sign in to comment.