MM-17224 - Bulk export fails due to missing user (#11738)
* don't fail on deleted users * test * logging * more fine grained error checking
Этот коммит содержится в:
коммит произвёл
Jesse Hallam
родитель
de88adfc0b
Коммит
89a79e2e9f
@@ -5,12 +5,15 @@ package app
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/mattermost/mattermost-server/store"
|
||||||
|
|
||||||
"github.com/mattermost/mattermost-server/mlog"
|
"github.com/mattermost/mattermost-server/mlog"
|
||||||
"github.com/mattermost/mattermost-server/model"
|
"github.com/mattermost/mattermost-server/model"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@@ -410,6 +413,10 @@ func (a *App) BuildPostReactions(postId string) (*[]ReactionImportData, *model.A
|
|||||||
var user *model.User
|
var user *model.User
|
||||||
user, err = a.Srv.Store.User().Get(reaction.UserId)
|
user, err = a.Srv.Store.User().Get(reaction.UserId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if err.Id == store.MISSING_ACCOUNT_ERROR { // this is a valid case, the user that reacted might've been deleted by now
|
||||||
|
mlog.Info(fmt.Sprintf("Skipping reactions by user %v, since the entity doesn't exist anymore", reaction.UserId))
|
||||||
|
continue
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
reactionsOfPost = append(reactionsOfPost, *ImportReactionFromPost(user, reaction))
|
reactionsOfPost = append(reactionsOfPost, *ImportReactionFromPost(user, reaction))
|
||||||
|
|||||||
@@ -18,15 +18,22 @@ func TestReactionsOfPost(t *testing.T) {
|
|||||||
|
|
||||||
post := th.BasicPost
|
post := th.BasicPost
|
||||||
post.HasReactions = true
|
post.HasReactions = true
|
||||||
|
th.BasicUser2.DeleteAt = 1234
|
||||||
reactionObject := model.Reaction{
|
reactionObject := model.Reaction{
|
||||||
UserId: th.BasicUser.Id,
|
UserId: th.BasicUser.Id,
|
||||||
PostId: post.Id,
|
PostId: post.Id,
|
||||||
EmojiName: "emoji",
|
EmojiName: "emoji",
|
||||||
CreateAt: model.GetMillis(),
|
CreateAt: model.GetMillis(),
|
||||||
}
|
}
|
||||||
|
reactionObjectDeleted := model.Reaction{
|
||||||
|
UserId: th.BasicUser2.Id,
|
||||||
|
PostId: post.Id,
|
||||||
|
EmojiName: "emoji",
|
||||||
|
CreateAt: model.GetMillis(),
|
||||||
|
}
|
||||||
|
|
||||||
th.App.SaveReactionForPost(&reactionObject)
|
th.App.SaveReactionForPost(&reactionObject)
|
||||||
|
th.App.SaveReactionForPost(&reactionObjectDeleted)
|
||||||
reactionsOfPost, err := th.App.BuildPostReactions(post.Id)
|
reactionsOfPost, err := th.App.BuildPostReactions(post.Id)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user