Fix for OOO bug that reply message does not get inserted consistently. (#9742)

Этот коммит содержится в:
Chris Duarte
2018-10-30 14:30:15 -07:00
коммит произвёл Christopher Speller
родитель 5d6c686d80
Коммит f23eeb56c7
3 изменённых файлов: 8 добавлений и 18 удалений

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

@@ -8,7 +8,7 @@ import (
"github.com/mattermost/mattermost-server/model"
)
func (a *App) SendAutoResponse(channel *model.Channel, receiver *model.User, rootId string) {
func (a *App) SendAutoResponse(channel *model.Channel, receiver *model.User) {
if receiver == nil || receiver.NotifyProps == nil {
return
}
@@ -20,8 +20,8 @@ func (a *App) SendAutoResponse(channel *model.Channel, receiver *model.User, roo
autoResponderPost := &model.Post{
ChannelId: channel.Id,
Message: message,
RootId: rootId,
ParentId: rootId,
RootId: "",
ParentId: "",
Type: model.POST_AUTO_RESPONDER,
UserId: receiver.Id,
}

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

@@ -94,28 +94,25 @@ func TestSendAutoResponseSuccess(t *testing.T) {
userUpdated1, err := th.App.PatchUser(user.Id, patch, true)
require.Nil(t, err)
firstPost, _ := th.App.CreatePost(&model.Post{
th.App.CreatePost(&model.Post{
ChannelId: th.BasicChannel.Id,
Message: "zz" + model.NewId() + "a",
UserId: th.BasicUser.Id},
th.BasicChannel,
false)
th.App.SendAutoResponse(th.BasicChannel, userUpdated1, firstPost.Id)
th.App.SendAutoResponse(th.BasicChannel, userUpdated1)
if list, err := th.App.GetPosts(th.BasicChannel.Id, 0, 1); err != nil {
require.Nil(t, err)
} else {
autoResponderPostFound := false
autoResponderIsComment := false
for _, post := range list.Posts {
if post.Type == model.POST_AUTO_RESPONDER {
autoResponderIsComment = post.RootId == firstPost.Id
autoResponderPostFound = true
}
}
assert.True(t, autoResponderPostFound)
assert.True(t, autoResponderIsComment)
}
}
@@ -134,27 +131,24 @@ func TestSendAutoResponseFailure(t *testing.T) {
userUpdated1, err := th.App.PatchUser(user.Id, patch, true)
require.Nil(t, err)
firstPost, _ := th.App.CreatePost(&model.Post{
th.App.CreatePost(&model.Post{
ChannelId: th.BasicChannel.Id,
Message: "zz" + model.NewId() + "a",
UserId: th.BasicUser.Id},
th.BasicChannel,
false)
th.App.SendAutoResponse(th.BasicChannel, userUpdated1, firstPost.Id)
th.App.SendAutoResponse(th.BasicChannel, userUpdated1)
if list, err := th.App.GetPosts(th.BasicChannel.Id, 0, 1); err != nil {
require.Nil(t, err)
} else {
autoResponderPostFound := false
autoResponderIsComment := false
for _, post := range list.Posts {
if post.Type == model.POST_AUTO_RESPONDER {
autoResponderIsComment = post.RootId == firstPost.Id
autoResponderPostFound = true
}
}
assert.False(t, autoResponderPostFound)
assert.False(t, autoResponderIsComment)
}
}

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

@@ -79,11 +79,7 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
if post.Type != model.POST_AUTO_RESPONDER {
a.Go(func() {
rootId := post.Id
if post.RootId != "" && post.RootId != post.Id {
rootId = post.RootId
}
a.SendAutoResponse(channel, otherUser, rootId)
a.SendAutoResponse(channel, otherUser)
})
}