MM-31182: Reuse the created bot user when creating a DM channel (#16894)
* MM-31182: Reuse the created bot user when creating a DM channel When creating a bot, we also create a DM channel between the owner and the bot. So we would hit a replica lag issue when trying to get the user from the replica instance immediately after creating it. This falls into the category of read-after-write within a single request. We fix this by passing the already created bot user during channel creation itself, thereby getting correctness and saving a DB query. While here, we also make some other cosmetic improvements: - Change userId to userID - Rename nErr to err https://mattermost.atlassian.net/browse/MM-31182 ```release-notes Fix a bug where creation of a bot would fail due to replica lag. ``` * use correct appError name
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
b3fad842fd
Коммит
d6033b7725
@@ -62,7 +62,11 @@ func (a *App) CreateBot(bot *model.Bot) (*model.Bot, *model.AppError) {
|
||||
} 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(savedBot.UserId, bot.OwnerId)
|
||||
botOwner, err := a.GetUser(bot.OwnerId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
channel, err := a.getOrCreateDirectChannelWithUser(user, botOwner)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user