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
@@ -76,8 +76,11 @@ func TestCreateBot(t *testing.T) {
|
||||
assert.Equal(t, "a bot", bot.Description)
|
||||
assert.Equal(t, th.BasicUser.Id, bot.OwnerId)
|
||||
|
||||
user, err := th.App.GetUser(bot.UserId)
|
||||
require.Nil(t, err)
|
||||
|
||||
// Check that a post was created to add bot to team and channels
|
||||
channel, err := th.App.GetOrCreateDirectChannel(bot.UserId, th.BasicUser.Id)
|
||||
channel, err := th.App.getOrCreateDirectChannelWithUser(user, th.BasicUser)
|
||||
require.Nil(t, err)
|
||||
posts, err := th.App.GetPosts(channel.Id, 0, 1)
|
||||
require.Nil(t, err)
|
||||
|
||||
Ссылка в новой задаче
Block a user