Poststore migration part3 (#15505)
* Migration completed * Order in translations file * Fix: lints * Trigger CI * Fix message key * Change mlog.Error for mlog.Warn * Fix imports * Adding translations needed for EE * Trigger CI * Fix merge with master Co-authored-by: Agniva De Sarker <agnivade@yahoo.co.in> Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
cd7d68effb
Коммит
8118cac350
@@ -1989,8 +1989,8 @@ func TestPermanentDeleteAllUsers(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
require.Greater(t, len(users), 0)
|
||||
|
||||
postCount, err := th.App.Srv().Store.Post().AnalyticsPostCount("", false, false)
|
||||
require.Nil(t, err)
|
||||
postCount, nErr := th.App.Srv().Store.Post().AnalyticsPostCount("", false, false)
|
||||
require.Nil(t, nErr)
|
||||
require.Greater(t, postCount, int64(0))
|
||||
|
||||
// Delete all users and their posts
|
||||
@@ -2002,8 +2002,8 @@ func TestPermanentDeleteAllUsers(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
require.Len(t, users, 0)
|
||||
|
||||
postCount, err = th.App.Srv().Store.Post().AnalyticsPostCount("", false, false)
|
||||
require.Nil(t, err)
|
||||
postCount, nErr = th.App.Srv().Store.Post().AnalyticsPostCount("", false, false)
|
||||
require.Nil(t, nErr)
|
||||
require.Equal(t, postCount, int64(0))
|
||||
|
||||
// Check that the channel and team created by the user were not deleted
|
||||
|
||||
@@ -79,7 +79,7 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
postChan = make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
count, err2 := a.Srv().Store.Post().AnalyticsPostCount(teamId, false, false)
|
||||
postChan <- store.StoreResult{Data: count, Err: err2}
|
||||
postChan <- store.StoreResult{Data: count, NErr: err2}
|
||||
close(postChan)
|
||||
}()
|
||||
}
|
||||
@@ -121,8 +121,8 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
rows[2].Value = -1
|
||||
} else {
|
||||
r = <-postChan
|
||||
if r.Err != nil {
|
||||
return nil, r.Err
|
||||
if r.NErr != nil {
|
||||
return nil, model.NewAppError("GetAnalytics", "app.post.analytics_posts_count.app_error", nil, r.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
rows[2].Value = float64(r.Data.(int64))
|
||||
}
|
||||
@@ -198,28 +198,43 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
rows := model.AnalyticsRows{&model.AnalyticsRow{Name: "", Value: -1}}
|
||||
return rows, nil
|
||||
}
|
||||
return a.Srv().Store.Post().AnalyticsPostCountsByDay(&model.AnalyticsPostCountsOptions{
|
||||
analyticsRows, nErr := a.Srv().Store.Post().AnalyticsPostCountsByDay(&model.AnalyticsPostCountsOptions{
|
||||
TeamId: teamId,
|
||||
BotsOnly: true,
|
||||
YesterdayOnly: false,
|
||||
})
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("GetAnalytics", "app.post.analytics_posts_count_by_day.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return analyticsRows, nil
|
||||
} else if name == "post_counts_day" {
|
||||
if skipIntensiveQueries {
|
||||
rows := model.AnalyticsRows{&model.AnalyticsRow{Name: "", Value: -1}}
|
||||
return rows, nil
|
||||
}
|
||||
return a.Srv().Store.Post().AnalyticsPostCountsByDay(&model.AnalyticsPostCountsOptions{
|
||||
analyticsRows, nErr := a.Srv().Store.Post().AnalyticsPostCountsByDay(&model.AnalyticsPostCountsOptions{
|
||||
TeamId: teamId,
|
||||
BotsOnly: false,
|
||||
YesterdayOnly: false,
|
||||
})
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("GetAnalytics", "app.post.analytics_posts_count_by_day.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return analyticsRows, nil
|
||||
} else if name == "user_counts_with_posts_day" {
|
||||
if skipIntensiveQueries {
|
||||
rows := model.AnalyticsRows{&model.AnalyticsRow{Name: "", Value: -1}}
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
return a.Srv().Store.Post().AnalyticsUserCountsWithPostsByDay(teamId)
|
||||
analyticsRows, nErr := a.Srv().Store.Post().AnalyticsUserCountsWithPostsByDay(teamId)
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("GetAnalytics", "app.post.analytics_user_counts_posts_by_day.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return analyticsRows, nil
|
||||
} else if name == "extra_counts" {
|
||||
var rows model.AnalyticsRows = make([]*model.AnalyticsRow, 6)
|
||||
rows[0] = &model.AnalyticsRow{Name: "file_post_count", Value: 0}
|
||||
@@ -264,14 +279,14 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
fileChan = make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
count, err2 := a.Srv().Store.Post().AnalyticsPostCount(teamId, true, false)
|
||||
fileChan <- store.StoreResult{Data: count, Err: err2}
|
||||
fileChan <- store.StoreResult{Data: count, NErr: err2}
|
||||
close(fileChan)
|
||||
}()
|
||||
|
||||
hashtagChan = make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
count, err2 := a.Srv().Store.Post().AnalyticsPostCount(teamId, false, true)
|
||||
hashtagChan <- store.StoreResult{Data: count, Err: err2}
|
||||
hashtagChan <- store.StoreResult{Data: count, NErr: err2}
|
||||
close(hashtagChan)
|
||||
}()
|
||||
}
|
||||
@@ -280,8 +295,8 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
rows[0].Value = -1
|
||||
} else {
|
||||
r := <-fileChan
|
||||
if r.Err != nil {
|
||||
return nil, r.Err
|
||||
if r.NErr != nil {
|
||||
return nil, model.NewAppError("GetAnalytics", "app.post.analytics_posts_count.app_error", nil, r.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
rows[0].Value = float64(r.Data.(int64))
|
||||
}
|
||||
@@ -290,8 +305,8 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
rows[1].Value = -1
|
||||
} else {
|
||||
r := <-hashtagChan
|
||||
if r.Err != nil {
|
||||
return nil, r.Err
|
||||
if r.NErr != nil {
|
||||
return nil, model.NewAppError("GetAnalytics", "app.post.analytics_posts_count.app_error", nil, r.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
rows[1].Value = float64(r.Data.(int64))
|
||||
}
|
||||
|
||||
@@ -596,8 +596,8 @@ func TestAddChannelMemberNoUserRequestor(t *testing.T) {
|
||||
}
|
||||
assert.Equal(t, groupUserIds, channelMemberHistoryUserIds)
|
||||
|
||||
postList, err := th.App.Srv().Store.Post().GetPosts(model.GetPostsOptions{ChannelId: channel.Id, Page: 0, PerPage: 1}, false)
|
||||
require.Nil(t, err)
|
||||
postList, nErr := th.App.Srv().Store.Post().GetPosts(model.GetPostsOptions{ChannelId: channel.Id, Page: 0, PerPage: 1}, false)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
if assert.Len(t, postList.Order, 1) {
|
||||
post := postList.Posts[postList.Order[0]]
|
||||
|
||||
@@ -338,9 +338,9 @@ func (a *App) exportAllPosts(writer io.Writer) *model.AppError {
|
||||
afterId := strings.Repeat("0", 26)
|
||||
|
||||
for {
|
||||
posts, err := a.Srv().Store.Post().GetParentsForExportAfter(1000, afterId)
|
||||
if err != nil {
|
||||
return err
|
||||
posts, nErr := a.Srv().Store.Post().GetParentsForExportAfter(1000, afterId)
|
||||
if nErr != nil {
|
||||
return model.NewAppError("exportAllPosts", "app.post.get_posts.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if len(posts) == 0 {
|
||||
@@ -357,6 +357,7 @@ func (a *App) exportAllPosts(writer io.Writer) *model.AppError {
|
||||
|
||||
postLine := ImportLineForPost(post)
|
||||
|
||||
var err *model.AppError
|
||||
postLine.Post.Replies, err = a.buildPostReplies(post.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -380,17 +381,18 @@ func (a *App) exportAllPosts(writer io.Writer) *model.AppError {
|
||||
func (a *App) buildPostReplies(postId string) (*[]ReplyImportData, *model.AppError) {
|
||||
var replies []ReplyImportData
|
||||
|
||||
replyPosts, err := a.Srv().Store.Post().GetRepliesForExport(postId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
replyPosts, nErr := a.Srv().Store.Post().GetRepliesForExport(postId)
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("buildPostReplies", "app.post.get_posts.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
for _, reply := range replyPosts {
|
||||
replyImportObject := ImportReplyFromPost(reply)
|
||||
if reply.HasReactions {
|
||||
replyImportObject.Reactions, err = a.BuildPostReactions(reply.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var appErr *model.AppError
|
||||
replyImportObject.Reactions, appErr = a.BuildPostReactions(reply.Id)
|
||||
if appErr != nil {
|
||||
return nil, appErr
|
||||
}
|
||||
}
|
||||
replies = append(replies, *replyImportObject)
|
||||
@@ -545,7 +547,7 @@ func (a *App) exportAllDirectPosts(writer io.Writer) *model.AppError {
|
||||
for {
|
||||
posts, err := a.Srv().Store.Post().GetDirectPostParentsForExportAfter(1000, afterId)
|
||||
if err != nil {
|
||||
return err
|
||||
return model.NewAppError("exportAllDirectPosts", "app.post.get_direct_posts.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if len(posts) == 0 {
|
||||
|
||||
@@ -533,8 +533,8 @@ func TestExportDMPostWithSelf(t *testing.T) {
|
||||
err := th1.App.BulkExport(&b, "somefile", "somePath", "someDir")
|
||||
require.Nil(t, err)
|
||||
|
||||
posts, err := th1.App.Srv().Store.Post().GetDirectPostParentsForExportAfter(1000, "0000000")
|
||||
require.Nil(t, err)
|
||||
posts, nErr := th1.App.Srv().Store.Post().GetDirectPostParentsForExportAfter(1000, "0000000")
|
||||
require.Nil(t, nErr)
|
||||
assert.Equal(t, 1, len(posts))
|
||||
|
||||
th1.TearDown()
|
||||
@@ -542,8 +542,8 @@ func TestExportDMPostWithSelf(t *testing.T) {
|
||||
th2 := Setup(t)
|
||||
defer th2.TearDown()
|
||||
|
||||
posts, err = th2.App.Srv().Store.Post().GetDirectPostParentsForExportAfter(1000, "0000000")
|
||||
require.Nil(t, err)
|
||||
posts, nErr = th2.App.Srv().Store.Post().GetDirectPostParentsForExportAfter(1000, "0000000")
|
||||
require.Nil(t, nErr)
|
||||
assert.Equal(t, 0, len(posts))
|
||||
|
||||
// import the exported posts
|
||||
@@ -551,8 +551,8 @@ func TestExportDMPostWithSelf(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 0, i)
|
||||
|
||||
posts, err = th2.App.Srv().Store.Post().GetDirectPostParentsForExportAfter(1000, "0000000")
|
||||
require.Nil(t, err)
|
||||
posts, nErr = th2.App.Srv().Store.Post().GetDirectPostParentsForExportAfter(1000, "0000000")
|
||||
require.Nil(t, nErr)
|
||||
assert.Equal(t, 1, len(posts))
|
||||
assert.Equal(t, 1, len((*posts[0].ChannelMembers)))
|
||||
assert.Equal(t, th1.BasicUser.Username, (*posts[0].ChannelMembers)[0])
|
||||
|
||||
@@ -1031,9 +1031,9 @@ func (a *App) importReplies(data []ReplyImportData, post *model.Post, teamId str
|
||||
user := users[*replyData.User]
|
||||
|
||||
// Check if this post already exists.
|
||||
replies, err := a.Srv().Store.Post().GetPostsCreatedAt(post.ChannelId, *replyData.CreateAt)
|
||||
if err != nil {
|
||||
return err
|
||||
replies, nErr := a.Srv().Store.Post().GetPostsCreatedAt(post.ChannelId, *replyData.CreateAt)
|
||||
if nErr != nil {
|
||||
return model.NewAppError("importReplies", "app.post.get_posts_created_at.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
var reply *model.Post
|
||||
@@ -1091,8 +1091,8 @@ func (a *App) importReplies(data []ReplyImportData, post *model.Post, teamId str
|
||||
}
|
||||
}
|
||||
|
||||
if _, _, err := a.Srv().Store.Post().OverwriteMultiple(postsForOverwriteList); err != nil {
|
||||
return err
|
||||
if _, _, nErr := a.Srv().Store.Post().OverwriteMultiple(postsForOverwriteList); nErr != nil {
|
||||
return model.NewAppError("importReplies", "app.post.overwrite.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
for _, postWithData := range postsWithData {
|
||||
@@ -1278,9 +1278,9 @@ func (a *App) importMultiplePostLines(lines []LineImportWorkerData, dryRun bool)
|
||||
user := users[*line.Post.User]
|
||||
|
||||
// Check if this post already exists.
|
||||
posts, appErr := a.Srv().Store.Post().GetPostsCreatedAt(channel.Id, *line.Post.CreateAt)
|
||||
if appErr != nil {
|
||||
return line.LineNumber, appErr
|
||||
posts, nErr := a.Srv().Store.Post().GetPostsCreatedAt(channel.Id, *line.Post.CreateAt)
|
||||
if nErr != nil {
|
||||
return line.LineNumber, model.NewAppError("importMultiplePostLines", "app.post.get_posts_created_at.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
var post *model.Post
|
||||
@@ -1357,10 +1357,10 @@ func (a *App) importMultiplePostLines(lines []LineImportWorkerData, dryRun bool)
|
||||
if idx != -1 && idx < len(postsForOverwriteList) {
|
||||
post := postsForOverwriteList[idx]
|
||||
if lineNumber, ok := postsForOverwriteMap[getPostStrID(post)]; ok {
|
||||
return lineNumber, err
|
||||
return lineNumber, model.NewAppError("importMultiplePostLines", "app.post.overwrite.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
return 0, err
|
||||
return 0, model.NewAppError("importMultiplePostLines", "app.post.overwrite.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
for _, postWithData := range postsWithData {
|
||||
@@ -1574,9 +1574,9 @@ func (a *App) importMultipleDirectPostLines(lines []LineImportWorkerData, dryRun
|
||||
user := users[*line.DirectPost.User]
|
||||
|
||||
// Check if this post already exists.
|
||||
posts, err := a.Srv().Store.Post().GetPostsCreatedAt(channel.Id, *line.DirectPost.CreateAt)
|
||||
if err != nil {
|
||||
return line.LineNumber, err
|
||||
posts, nErr := a.Srv().Store.Post().GetPostsCreatedAt(channel.Id, *line.DirectPost.CreateAt)
|
||||
if nErr != nil {
|
||||
return line.LineNumber, model.NewAppError("BulkImport", "app.post.get_posts_created_at.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
var post *model.Post
|
||||
@@ -1652,10 +1652,10 @@ func (a *App) importMultipleDirectPostLines(lines []LineImportWorkerData, dryRun
|
||||
if idx != -1 && idx < len(postsForOverwriteList) {
|
||||
post := postsForOverwriteList[idx]
|
||||
if lineNumber, ok := postsForOverwriteMap[getPostStrID(post)]; ok {
|
||||
return lineNumber, err
|
||||
return lineNumber, model.NewAppError("importMultiplePostLines", "app.post.overwrite.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
return 0, err
|
||||
return 0, model.NewAppError("importMultiplePostLines", "app.post.overwrite.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
for _, postWithData := range postsWithData {
|
||||
|
||||
@@ -1958,8 +1958,8 @@ func TestImportimportMultiplePostLines(t *testing.T) {
|
||||
require.Nil(t, err, "Failed to get user from database.")
|
||||
|
||||
// Count the number of posts in the testing team.
|
||||
initialPostCount, err := th.App.Srv().Store.Post().AnalyticsPostCount(team.Id, false, false)
|
||||
require.Nil(t, err)
|
||||
initialPostCount, nErr := th.App.Srv().Store.Post().AnalyticsPostCount(team.Id, false, false)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// Try adding an invalid post in dry run mode.
|
||||
data := LineImportWorkerData{
|
||||
@@ -2092,8 +2092,8 @@ func TestImportimportMultiplePostLines(t *testing.T) {
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 1, team.Id)
|
||||
|
||||
// Check the post values.
|
||||
posts, err := th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, time)
|
||||
require.Nil(t, err)
|
||||
posts, nErr := th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, time)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
require.Len(t, posts, 1, "Unexpected number of posts found.")
|
||||
|
||||
@@ -2120,8 +2120,8 @@ func TestImportimportMultiplePostLines(t *testing.T) {
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 1, team.Id)
|
||||
|
||||
// Check the post values.
|
||||
posts, err = th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, time)
|
||||
require.Nil(t, err)
|
||||
posts, nErr = th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, time)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
require.Len(t, posts, 1, "Unexpected number of posts found.")
|
||||
|
||||
@@ -2185,8 +2185,8 @@ func TestImportimportMultiplePostLines(t *testing.T) {
|
||||
assert.Equal(t, 0, errLine)
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 4, team.Id)
|
||||
|
||||
posts, err = th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, hashtagTime)
|
||||
require.Nil(t, err)
|
||||
posts, nErr = th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, hashtagTime)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
require.Len(t, posts, 1, "Unexpected number of posts found.")
|
||||
|
||||
@@ -2230,8 +2230,8 @@ func TestImportimportMultiplePostLines(t *testing.T) {
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 5, team.Id)
|
||||
|
||||
// Check the post values.
|
||||
posts, err = th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, flagsTime)
|
||||
require.Nil(t, err)
|
||||
posts, nErr = th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, flagsTime)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
require.Len(t, posts, 1, "Unexpected number of posts found.")
|
||||
|
||||
@@ -2269,8 +2269,8 @@ func TestImportimportMultiplePostLines(t *testing.T) {
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 6, team.Id)
|
||||
|
||||
// Check the post values.
|
||||
posts, err = th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, reactionPostTime)
|
||||
require.Nil(t, err)
|
||||
posts, nErr = th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, reactionPostTime)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
require.Len(t, posts, 1, "Unexpected number of posts found.")
|
||||
|
||||
@@ -2310,8 +2310,8 @@ func TestImportimportMultiplePostLines(t *testing.T) {
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 8, team.Id)
|
||||
|
||||
// Check the post values.
|
||||
posts, err = th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, replyPostTime)
|
||||
require.Nil(t, err)
|
||||
posts, nErr = th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, replyPostTime)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
require.Len(t, posts, 1, "Unexpected number of posts found.")
|
||||
|
||||
@@ -2320,8 +2320,8 @@ func TestImportimportMultiplePostLines(t *testing.T) {
|
||||
require.False(t, postBool, "Post properties not as expected")
|
||||
|
||||
// Check the reply values.
|
||||
replies, err := th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, replyTime)
|
||||
require.Nil(t, err)
|
||||
replies, nErr := th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, replyTime)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
require.Len(t, replies, 1, "Unexpected number of posts found.")
|
||||
|
||||
@@ -2447,8 +2447,8 @@ func TestImportImportPost(t *testing.T) {
|
||||
require.Nil(t, appErr, "Failed to get user from database.")
|
||||
|
||||
// Count the number of posts in the testing team.
|
||||
initialPostCount, appErr := th.App.Srv().Store.Post().AnalyticsPostCount(team.Id, false, false)
|
||||
require.Nil(t, appErr)
|
||||
initialPostCount, nErr := th.App.Srv().Store.Post().AnalyticsPostCount(team.Id, false, false)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
time := model.GetMillis()
|
||||
hashtagTime := time + 2
|
||||
@@ -2585,8 +2585,8 @@ func TestImportImportPost(t *testing.T) {
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 1, team.Id)
|
||||
|
||||
// Check the post values.
|
||||
posts, err := th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, time)
|
||||
require.Nil(t, err)
|
||||
posts, nErr := th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, time)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
require.Len(t, posts, 1, "Unexpected number of posts found.")
|
||||
|
||||
@@ -2614,8 +2614,8 @@ func TestImportImportPost(t *testing.T) {
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 1, team.Id)
|
||||
|
||||
// Check the post values.
|
||||
posts, err := th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, time)
|
||||
require.Nil(t, err)
|
||||
posts, nErr := th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, time)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
require.Len(t, posts, 1, "Unexpected number of posts found.")
|
||||
|
||||
@@ -2681,8 +2681,8 @@ func TestImportImportPost(t *testing.T) {
|
||||
assert.Equal(t, 0, errLine)
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 4, team.Id)
|
||||
|
||||
posts, err := th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, hashtagTime)
|
||||
require.Nil(t, err)
|
||||
posts, nErr := th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, hashtagTime)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
require.Len(t, posts, 1, "Unexpected number of posts found.")
|
||||
|
||||
@@ -2719,8 +2719,8 @@ func TestImportImportPost(t *testing.T) {
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 5, team.Id)
|
||||
|
||||
// Check the post values.
|
||||
posts, err := th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, flagsTime)
|
||||
require.Nil(t, err)
|
||||
posts, nErr := th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, flagsTime)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
require.Len(t, posts, 1, "Unexpected number of posts found.")
|
||||
|
||||
@@ -2759,8 +2759,8 @@ func TestImportImportPost(t *testing.T) {
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 6, team.Id)
|
||||
|
||||
// Check the post values.
|
||||
posts, err := th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, reactionPostTime)
|
||||
require.Nil(t, err)
|
||||
posts, nErr := th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, reactionPostTime)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
require.Len(t, posts, 1, "Unexpected number of posts found.")
|
||||
|
||||
@@ -2799,8 +2799,8 @@ func TestImportImportPost(t *testing.T) {
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 8, team.Id)
|
||||
|
||||
// Check the post values.
|
||||
posts, err := th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, replyPostTime)
|
||||
require.Nil(t, err)
|
||||
posts, nErr := th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, replyPostTime)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
require.Len(t, posts, 1, "Unexpected number of posts found.")
|
||||
|
||||
@@ -2809,8 +2809,8 @@ func TestImportImportPost(t *testing.T) {
|
||||
require.False(t, postBool, "Post properties not as expected")
|
||||
|
||||
// Check the reply values.
|
||||
replies, err := th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, replyTime)
|
||||
require.Nil(t, err)
|
||||
replies, nErr := th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, replyTime)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
require.Len(t, replies, 1, "Unexpected number of posts found.")
|
||||
|
||||
@@ -3087,8 +3087,8 @@ func TestImportImportDirectPost(t *testing.T) {
|
||||
directChannel = channel
|
||||
|
||||
// Get the number of posts in the system.
|
||||
result, appErr := th.App.Srv().Store.Post().AnalyticsPostCount("", false, false)
|
||||
require.Nil(t, appErr)
|
||||
result, err := th.App.Srv().Store.Post().AnalyticsPostCount("", false, false)
|
||||
require.Nil(t, err)
|
||||
initialPostCount := result
|
||||
initialDate := model.GetMillis()
|
||||
|
||||
@@ -3175,8 +3175,8 @@ func TestImportImportDirectPost(t *testing.T) {
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 1, "")
|
||||
|
||||
// Check the post values.
|
||||
posts, err := th.App.Srv().Store.Post().GetPostsCreatedAt(directChannel.Id, *data.DirectPost.CreateAt)
|
||||
require.Nil(t, err)
|
||||
posts, nErr := th.App.Srv().Store.Post().GetPostsCreatedAt(directChannel.Id, *data.DirectPost.CreateAt)
|
||||
require.Nil(t, nErr)
|
||||
require.Len(t, posts, 1)
|
||||
|
||||
post := posts[0]
|
||||
@@ -3206,8 +3206,8 @@ func TestImportImportDirectPost(t *testing.T) {
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 1, "")
|
||||
|
||||
// Check the post values.
|
||||
posts, err := th.App.Srv().Store.Post().GetPostsCreatedAt(directChannel.Id, *data.DirectPost.CreateAt)
|
||||
require.Nil(t, err)
|
||||
posts, nErr := th.App.Srv().Store.Post().GetPostsCreatedAt(directChannel.Id, *data.DirectPost.CreateAt)
|
||||
require.Nil(t, nErr)
|
||||
require.Len(t, posts, 1)
|
||||
|
||||
post := posts[0]
|
||||
@@ -3278,8 +3278,8 @@ func TestImportImportDirectPost(t *testing.T) {
|
||||
require.Equal(t, 0, errLine)
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 4, "")
|
||||
|
||||
posts, err := th.App.Srv().Store.Post().GetPostsCreatedAt(directChannel.Id, *data.DirectPost.CreateAt)
|
||||
require.Nil(t, err)
|
||||
posts, nErr := th.App.Srv().Store.Post().GetPostsCreatedAt(directChannel.Id, *data.DirectPost.CreateAt)
|
||||
require.Nil(t, nErr)
|
||||
require.Len(t, posts, 1)
|
||||
|
||||
post := posts[0]
|
||||
@@ -3314,8 +3314,8 @@ func TestImportImportDirectPost(t *testing.T) {
|
||||
require.Equal(t, 0, errLine)
|
||||
|
||||
// Check the post values.
|
||||
posts, err := th.App.Srv().Store.Post().GetPostsCreatedAt(directChannel.Id, *data.DirectPost.CreateAt)
|
||||
require.Nil(t, err)
|
||||
posts, nErr := th.App.Srv().Store.Post().GetPostsCreatedAt(directChannel.Id, *data.DirectPost.CreateAt)
|
||||
require.Nil(t, nErr)
|
||||
require.Len(t, posts, 1)
|
||||
|
||||
post := posts[0]
|
||||
@@ -3349,8 +3349,8 @@ func TestImportImportDirectPost(t *testing.T) {
|
||||
groupChannel = channel
|
||||
|
||||
// Get the number of posts in the system.
|
||||
result, appErr = th.App.Srv().Store.Post().AnalyticsPostCount("", false, false)
|
||||
require.Nil(t, appErr)
|
||||
result, nErr := th.App.Srv().Store.Post().AnalyticsPostCount("", false, false)
|
||||
require.Nil(t, nErr)
|
||||
initialPostCount = result
|
||||
|
||||
t.Run("Try adding an invalid post in dry run mode", func(t *testing.T) {
|
||||
@@ -3441,8 +3441,8 @@ func TestImportImportDirectPost(t *testing.T) {
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 1, "")
|
||||
|
||||
// Check the post values.
|
||||
posts, err := th.App.Srv().Store.Post().GetPostsCreatedAt(groupChannel.Id, *data.DirectPost.CreateAt)
|
||||
require.Nil(t, err)
|
||||
posts, nErr := th.App.Srv().Store.Post().GetPostsCreatedAt(groupChannel.Id, *data.DirectPost.CreateAt)
|
||||
require.Nil(t, nErr)
|
||||
require.Len(t, posts, 1)
|
||||
|
||||
post := posts[0]
|
||||
@@ -3473,8 +3473,8 @@ func TestImportImportDirectPost(t *testing.T) {
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 1, "")
|
||||
|
||||
// Check the post values.
|
||||
posts, err := th.App.Srv().Store.Post().GetPostsCreatedAt(groupChannel.Id, *data.DirectPost.CreateAt)
|
||||
require.Nil(t, err)
|
||||
posts, nErr := th.App.Srv().Store.Post().GetPostsCreatedAt(groupChannel.Id, *data.DirectPost.CreateAt)
|
||||
require.Nil(t, nErr)
|
||||
require.Len(t, posts, 1)
|
||||
|
||||
post := posts[0]
|
||||
@@ -3548,8 +3548,8 @@ func TestImportImportDirectPost(t *testing.T) {
|
||||
require.Equal(t, 0, errLine)
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 4, "")
|
||||
|
||||
posts, err := th.App.Srv().Store.Post().GetPostsCreatedAt(groupChannel.Id, *data.DirectPost.CreateAt)
|
||||
require.Nil(t, err)
|
||||
posts, nErr := th.App.Srv().Store.Post().GetPostsCreatedAt(groupChannel.Id, *data.DirectPost.CreateAt)
|
||||
require.Nil(t, nErr)
|
||||
require.Len(t, posts, 1)
|
||||
|
||||
post := posts[0]
|
||||
@@ -3587,8 +3587,8 @@ func TestImportImportDirectPost(t *testing.T) {
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 5, "")
|
||||
|
||||
// Check the post values.
|
||||
posts, err := th.App.Srv().Store.Post().GetPostsCreatedAt(groupChannel.Id, *data.DirectPost.CreateAt)
|
||||
require.Nil(t, err)
|
||||
posts, nErr := th.App.Srv().Store.Post().GetPostsCreatedAt(groupChannel.Id, *data.DirectPost.CreateAt)
|
||||
require.Nil(t, nErr)
|
||||
require.Len(t, posts, 1)
|
||||
|
||||
post := posts[0]
|
||||
@@ -3626,8 +3626,8 @@ func TestImportImportDirectPost(t *testing.T) {
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 6, "")
|
||||
|
||||
// Check the post values.
|
||||
posts, err := th.App.Srv().Store.Post().GetPostsCreatedAt(groupChannel.Id, *data.DirectPost.CreateAt)
|
||||
require.Nil(t, err)
|
||||
posts, nErr := th.App.Srv().Store.Post().GetPostsCreatedAt(groupChannel.Id, *data.DirectPost.CreateAt)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
require.Len(t, posts, 1, "Unexpected number of posts found.")
|
||||
|
||||
@@ -3671,8 +3671,8 @@ func TestImportImportDirectPost(t *testing.T) {
|
||||
AssertAllPostsCount(t, th.App, initialPostCount, 8, "")
|
||||
|
||||
// Check the post values.
|
||||
posts, err := th.App.Srv().Store.Post().GetPostsCreatedAt(groupChannel.Id, *data.DirectPost.CreateAt)
|
||||
require.Nil(t, err)
|
||||
posts, nErr := th.App.Srv().Store.Post().GetPostsCreatedAt(groupChannel.Id, *data.DirectPost.CreateAt)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
require.Len(t, posts, 1, "Unexpected number of posts found.")
|
||||
|
||||
@@ -3681,8 +3681,8 @@ func TestImportImportDirectPost(t *testing.T) {
|
||||
require.False(t, postBool, "Post properties not as expected")
|
||||
|
||||
// Check the reply values.
|
||||
replies, err := th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, *replyTime)
|
||||
require.Nil(t, err)
|
||||
replies, nErr := th.App.Srv().Store.Post().GetPostsCreatedAt(channel.Id, *replyTime)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
require.Len(t, replies, 1, "Unexpected number of posts found.")
|
||||
|
||||
|
||||
47
app/post.go
47
app/post.go
@@ -365,7 +365,7 @@ func (a *App) attachFilesToPost(post *model.Post) *model.AppError {
|
||||
post.FileIds = attachedIds
|
||||
|
||||
if _, err := a.Srv().Store.Post().Overwrite(post); err != nil {
|
||||
return err
|
||||
return model.NewAppError("attachFilesToPost", "app.post.overwrite.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -669,11 +669,33 @@ func (a *App) PatchPost(postId string, patch *model.PostPatch) (*model.Post, *mo
|
||||
}
|
||||
|
||||
func (a *App) GetPostsPage(options model.GetPostsOptions) (*model.PostList, *model.AppError) {
|
||||
return a.Srv().Store.Post().GetPosts(options, false)
|
||||
postList, err := a.Srv().Store.Post().GetPosts(options, false)
|
||||
if err != nil {
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(err, &invErr):
|
||||
return nil, model.NewAppError("GetPostsPage", "app.post.get_posts.app_error", nil, invErr.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
return nil, model.NewAppError("GetPostsPage", "app.post.get_root_posts.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
return postList, nil
|
||||
}
|
||||
|
||||
func (a *App) GetPosts(channelId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
return a.Srv().Store.Post().GetPosts(model.GetPostsOptions{ChannelId: channelId, Page: offset, PerPage: limit}, true)
|
||||
postList, err := a.Srv().Store.Post().GetPosts(model.GetPostsOptions{ChannelId: channelId, Page: offset, PerPage: limit}, true)
|
||||
if err != nil {
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(err, &invErr):
|
||||
return nil, model.NewAppError("GetPosts", "app.post.get_posts.app_error", nil, invErr.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
return nil, model.NewAppError("GetPosts", "app.post.get_root_posts.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
return postList, nil
|
||||
}
|
||||
|
||||
func (a *App) GetPostsEtag(channelId string) string {
|
||||
@@ -1085,7 +1107,7 @@ func (a *App) searchPostsInTeam(teamId string, userId string, paramsList []*mode
|
||||
go func(params *model.SearchParams) {
|
||||
defer wg.Done()
|
||||
postList, err := a.Srv().Store.Post().Search(teamId, userId, params)
|
||||
pchan <- store.StoreResult{Data: postList, Err: err}
|
||||
pchan <- store.StoreResult{Data: postList, NErr: err}
|
||||
}(params)
|
||||
}
|
||||
|
||||
@@ -1095,8 +1117,8 @@ func (a *App) searchPostsInTeam(teamId string, userId string, paramsList []*mode
|
||||
posts := model.NewPostList()
|
||||
|
||||
for result := range pchan {
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
if result.NErr != nil {
|
||||
return nil, model.NewAppError("searchPostsInTeam", "app.post.search.app_error", nil, result.NErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
data := result.Data.(*model.PostList)
|
||||
posts.Extend(data)
|
||||
@@ -1140,7 +1162,6 @@ func (a *App) SearchPostsInTeam(teamId string, paramsList []*model.SearchParams)
|
||||
|
||||
func (a *App) SearchPostsInTeamForUser(terms string, userId string, teamId string, isOrSearch bool, includeDeletedChannels bool, timeZoneOffset int, page, perPage int) (*model.PostSearchResults, *model.AppError) {
|
||||
var postSearchResults *model.PostSearchResults
|
||||
var err *model.AppError
|
||||
paramsList := model.ParseSearchParams(strings.TrimSpace(terms), timeZoneOffset)
|
||||
includeDeleted := includeDeletedChannels && *a.Config().TeamSettings.ExperimentalViewArchivedChannels
|
||||
|
||||
@@ -1172,9 +1193,15 @@ func (a *App) SearchPostsInTeamForUser(terms string, userId string, teamId strin
|
||||
return model.MakePostSearchResults(model.NewPostList(), nil), nil
|
||||
}
|
||||
|
||||
postSearchResults, err = a.Srv().Store.Post().SearchPostsInTeamForUser(finalParamsList, userId, teamId, page, perPage)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
postSearchResults, nErr := a.Srv().Store.Post().SearchPostsInTeamForUser(finalParamsList, userId, teamId, page, perPage)
|
||||
if nErr != nil {
|
||||
var appErr *model.AppError
|
||||
switch {
|
||||
case errors.As(nErr, &appErr):
|
||||
return nil, appErr
|
||||
default:
|
||||
return nil, model.NewAppError("SearchPostsInTeamForUser", "app.post.search.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
return postSearchResults, nil
|
||||
|
||||
@@ -4,20 +4,21 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"github.com/mattermost/mattermost-server/v5/store"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/store"
|
||||
|
||||
"github.com/Masterminds/semver/v3"
|
||||
"github.com/mattermost/mattermost-server/v5/config"
|
||||
"github.com/mattermost/mattermost-server/v5/mlog"
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
"github.com/mattermost/mattermost-server/v5/utils"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/reflog/dateconstraints"
|
||||
date_constraints "github.com/reflog/dateconstraints"
|
||||
)
|
||||
|
||||
const MAX_REPEAT_VIEWINGS = 3
|
||||
@@ -274,9 +275,9 @@ func (a *App) UpdateProductNotices() *model.AppError {
|
||||
}
|
||||
mlog.Debug("Will fetch notices from", mlog.String("url", NOTICES_JSON_URL), mlog.Bool("skip_cache", skip))
|
||||
var appErr *model.AppError
|
||||
cachedPostCount, appErr = a.Srv().Store.Post().AnalyticsPostCount("", false, false)
|
||||
if appErr != nil {
|
||||
mlog.Error("Failed to fetch post count", mlog.String("error", appErr.Error()))
|
||||
cachedPostCount, err = a.Srv().Store.Post().AnalyticsPostCount("", false, false)
|
||||
if err != nil {
|
||||
mlog.Error("Failed to fetch post count", mlog.String("error", err.Error()))
|
||||
}
|
||||
|
||||
cachedUserCount, appErr = a.Srv().Store.User().Count(model.UserCountOptions{IncludeDeleted: true})
|
||||
|
||||
108
i18n/en.json
108
i18n/en.json
@@ -4566,6 +4566,18 @@
|
||||
"id": "app.plugin_store.save.app_error",
|
||||
"translation": "Could not save or update plugin key value."
|
||||
},
|
||||
{
|
||||
"id": "app.post.analytics_posts_count.app_error",
|
||||
"translation": "Unable to get post counts."
|
||||
},
|
||||
{
|
||||
"id": "app.post.analytics_posts_count_by_day.app_error",
|
||||
"translation": "Unable to get post counts by day."
|
||||
},
|
||||
{
|
||||
"id": "app.post.analytics_user_counts_posts_by_day.app_error",
|
||||
"translation": "Unable to get user counts with posts."
|
||||
},
|
||||
{
|
||||
"id": "app.post.delete.app_error",
|
||||
"translation": "Unable to delete the post."
|
||||
@@ -4574,6 +4586,10 @@
|
||||
"id": "app.post.get.app_error",
|
||||
"translation": "Unable to get the post."
|
||||
},
|
||||
{
|
||||
"id": "app.post.get_direct_posts.app_error",
|
||||
"translation": "Unable to get direct posts."
|
||||
},
|
||||
{
|
||||
"id": "app.post.get_flagged_posts.app_error",
|
||||
"translation": "Unable to get the flagged posts."
|
||||
@@ -4586,14 +4602,34 @@
|
||||
"id": "app.post.get_post_id_around.app_error",
|
||||
"translation": "Unable to get post around time bound."
|
||||
},
|
||||
{
|
||||
"id": "app.post.get_posts.app_error",
|
||||
"translation": "Limit exceeded for paging."
|
||||
},
|
||||
{
|
||||
"id": "app.post.get_posts_around.get.app_error",
|
||||
"translation": "Unable to get the posts for the channel."
|
||||
},
|
||||
{
|
||||
"id": "app.post.get_posts_batch_for_indexing.get.app_error",
|
||||
"translation": "Unable to get the posts batch for indexing."
|
||||
},
|
||||
{
|
||||
"id": "app.post.get_posts_created_at.app_error",
|
||||
"translation": "Unable to get the posts for the channel."
|
||||
},
|
||||
{
|
||||
"id": "app.post.get_posts_since.app_error",
|
||||
"translation": "Unable to get the posts for the channel."
|
||||
},
|
||||
{
|
||||
"id": "app.post.get_root_posts.app_error",
|
||||
"translation": "Unable to get the posts for the channel."
|
||||
},
|
||||
{
|
||||
"id": "app.post.overwrite.app_error",
|
||||
"translation": "Unable to overwrite the Post."
|
||||
},
|
||||
{
|
||||
"id": "app.post.permanent_delete_by_channel.app_error",
|
||||
"translation": "Unable to delete the posts by channel."
|
||||
@@ -4610,6 +4646,10 @@
|
||||
"id": "app.post.save.existing.app_error",
|
||||
"translation": "You cannot update an existing Post."
|
||||
},
|
||||
{
|
||||
"id": "app.post.search.app_error",
|
||||
"translation": "Error searching posts"
|
||||
},
|
||||
{
|
||||
"id": "app.post.update.app_error",
|
||||
"translation": "Unable to update the Post."
|
||||
@@ -5490,6 +5530,10 @@
|
||||
"id": "ent.data_retention.generic.license.error",
|
||||
"translation": "Your license does not support Data Retention."
|
||||
},
|
||||
{
|
||||
"id": "ent.data_retention.posts_permanent_delete_batch.internal_error",
|
||||
"translation": "We encountered an error permanently deleting the batch of posts."
|
||||
},
|
||||
{
|
||||
"id": "ent.data_retention.reactions_batch.internal_error",
|
||||
"translation": "We encountered an error permanently deleting the batch of reactions."
|
||||
@@ -5590,6 +5634,10 @@
|
||||
"id": "ent.elasticsearch.not_started.error",
|
||||
"translation": "Elasticsearch is not started"
|
||||
},
|
||||
{
|
||||
"id": "ent.elasticsearch.post.get_posts_batch_for_indexing.error",
|
||||
"translation": "Unable to get the posts batch for indexing."
|
||||
},
|
||||
{
|
||||
"id": "ent.elasticsearch.purge_indexes.delete_failed",
|
||||
"translation": "Failed to delete Elasticsearch index"
|
||||
@@ -7658,66 +7706,6 @@
|
||||
"id": "store.sql_group.uniqueness_error",
|
||||
"translation": "group member already exists"
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.analytics_posts_count.app_error",
|
||||
"translation": "Unable to get post counts."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.analytics_posts_count_by_day.app_error",
|
||||
"translation": "Unable to get post counts by day."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.analytics_user_counts_posts_by_day.app_error",
|
||||
"translation": "Unable to get user counts with posts."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.get_direct_posts.app_error",
|
||||
"translation": "Unable to get direct posts."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.get_oldest_entity_creation_time.app_error",
|
||||
"translation": "Unable to get the oldest entitiy creation time."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.get_parents_posts.app_error",
|
||||
"translation": "Unable to get the parent post for the channel."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.get_posts.app_error",
|
||||
"translation": "Limit exceeded for paging."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.get_posts_batch_for_indexing.get.app_error",
|
||||
"translation": "Unable to get the posts batch for indexing."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.get_posts_by_ids.app_error",
|
||||
"translation": "Unable to get the posts."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.get_posts_created_att.app_error",
|
||||
"translation": "Unable to get the posts for the channel."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.get_root_posts.app_error",
|
||||
"translation": "Unable to get the posts for the channel."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.overwrite.app_error",
|
||||
"translation": "Unable to overwrite the Post."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.permanent_delete_batch.app_error",
|
||||
"translation": "We encountered an error permanently deleting the batch of posts."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.populate_reply_count.app_error",
|
||||
"translation": "Unable to get the post replies count"
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.search.app_error",
|
||||
"translation": "Error searching posts"
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.search.disabled",
|
||||
"translation": "Searching has been disabled on this server. Please contact your System Administrator."
|
||||
|
||||
@@ -283,11 +283,11 @@ func (worker *BleveIndexerWorker) IndexPostsBatch(progress IndexingProgress) (In
|
||||
|
||||
tries := 0
|
||||
for posts == nil {
|
||||
var err *model.AppError
|
||||
var err error
|
||||
posts, err = worker.jobServer.Store.Post().GetPostsBatchForIndexing(progress.LastEntityTime, endTime, BATCH_SIZE)
|
||||
if err != nil {
|
||||
if tries >= 10 {
|
||||
return progress, err
|
||||
return progress, model.NewAppError("IndexPostsBatch", "app.post.get_posts_batch_for_indexing.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
} else {
|
||||
mlog.Warn("Failed to get posts batch for indexing. Retrying.", mlog.Err(err))
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ func (s LocalCachePostStore) GetPostsSince(options model.GetPostsSinceOptions, a
|
||||
return list, err
|
||||
}
|
||||
|
||||
func (s LocalCachePostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool) (*model.PostList, *model.AppError) {
|
||||
func (s LocalCachePostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool) (*model.PostList, error) {
|
||||
if !allowFromCache {
|
||||
return s.PostStore.GetPosts(options, allowFromCache)
|
||||
}
|
||||
|
||||
@@ -4713,7 +4713,7 @@ func (s *OpenTracingLayerPluginStore) SetWithOptions(pluginId string, key string
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) AnalyticsPostCount(teamId string, mustHaveFile bool, mustHaveHashtag bool) (int64, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) AnalyticsPostCount(teamId string, mustHaveFile bool, mustHaveHashtag bool) (int64, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.AnalyticsPostCount")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -4731,7 +4731,7 @@ func (s *OpenTracingLayerPostStore) AnalyticsPostCount(teamId string, mustHaveFi
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) AnalyticsPostCountsByDay(options *model.AnalyticsPostCountsOptions) (model.AnalyticsRows, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) AnalyticsPostCountsByDay(options *model.AnalyticsPostCountsOptions) (model.AnalyticsRows, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.AnalyticsPostCountsByDay")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -4749,7 +4749,7 @@ func (s *OpenTracingLayerPostStore) AnalyticsPostCountsByDay(options *model.Anal
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) (model.AnalyticsRows, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) (model.AnalyticsRows, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.AnalyticsUserCountsWithPostsByDay")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -4816,7 +4816,7 @@ func (s *OpenTracingLayerPostStore) Get(id string, skipFetchThreads bool) (*mode
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) GetDirectPostParentsForExportAfter(limit int, afterId string) ([]*model.DirectPostForExport, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) GetDirectPostParentsForExportAfter(limit int, afterId string) ([]*model.DirectPostForExport, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.GetDirectPostParentsForExportAfter")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -4922,7 +4922,7 @@ func (s *OpenTracingLayerPostStore) GetMaxPostSize() int {
|
||||
return result
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) GetOldest() (*model.Post, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) GetOldest() (*model.Post, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.GetOldest")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -4940,7 +4940,7 @@ func (s *OpenTracingLayerPostStore) GetOldest() (*model.Post, *model.AppError) {
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) GetOldestEntityCreationTime() (int64, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) GetOldestEntityCreationTime() (int64, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.GetOldestEntityCreationTime")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -4958,7 +4958,7 @@ func (s *OpenTracingLayerPostStore) GetOldestEntityCreationTime() (int64, *model
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) GetParentsForExportAfter(limit int, afterId string) ([]*model.PostForExport, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) GetParentsForExportAfter(limit int, afterId string) ([]*model.PostForExport, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.GetParentsForExportAfter")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -5030,7 +5030,7 @@ func (s *OpenTracingLayerPostStore) GetPostIdBeforeTime(channelId string, time i
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool) (*model.PostList, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool) (*model.PostList, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.GetPosts")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -5066,7 +5066,7 @@ func (s *OpenTracingLayerPostStore) GetPostsAfter(options model.GetPostsOptions)
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.PostForIndexing, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.PostForIndexing, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.GetPostsBatchForIndexing")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -5102,7 +5102,7 @@ func (s *OpenTracingLayerPostStore) GetPostsBefore(options model.GetPostsOptions
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) GetPostsByIds(postIds []string) ([]*model.Post, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) GetPostsByIds(postIds []string) ([]*model.Post, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.GetPostsByIds")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -5120,7 +5120,7 @@ func (s *OpenTracingLayerPostStore) GetPostsByIds(postIds []string) ([]*model.Po
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) GetPostsCreatedAt(channelId string, time int64) ([]*model.Post, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) GetPostsCreatedAt(channelId string, time int64) ([]*model.Post, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.GetPostsCreatedAt")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -5156,7 +5156,7 @@ func (s *OpenTracingLayerPostStore) GetPostsSince(options model.GetPostsSinceOpt
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) GetRepliesForExport(parentId string) ([]*model.ReplyForExport, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) GetRepliesForExport(parentId string) ([]*model.ReplyForExport, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.GetRepliesForExport")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -5205,7 +5205,7 @@ func (s *OpenTracingLayerPostStore) InvalidateLastPostTimeCache(channelId string
|
||||
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) Overwrite(post *model.Post) (*model.Post, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) Overwrite(post *model.Post) (*model.Post, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.Overwrite")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -5223,7 +5223,7 @@ func (s *OpenTracingLayerPostStore) Overwrite(post *model.Post) (*model.Post, *m
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) OverwriteMultiple(posts []*model.Post) ([]*model.Post, int, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) OverwriteMultiple(posts []*model.Post) ([]*model.Post, int, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.OverwriteMultiple")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -5241,7 +5241,7 @@ func (s *OpenTracingLayerPostStore) OverwriteMultiple(posts []*model.Post) ([]*m
|
||||
return result, resultVar1, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.PermanentDeleteBatch")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -5331,7 +5331,7 @@ func (s *OpenTracingLayerPostStore) SaveMultiple(posts []*model.Post) ([]*model.
|
||||
return result, resultVar1, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) Search(teamId string, userId string, params *model.SearchParams) (*model.PostList, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) Search(teamId string, userId string, params *model.SearchParams) (*model.PostList, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.Search")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -5349,7 +5349,7 @@ func (s *OpenTracingLayerPostStore) Search(teamId string, userId string, params
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId string, teamId string, page int, perPage int) (*model.PostSearchResults, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId string, teamId string, page int, perPage int) (*model.PostSearchResults, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.SearchPostsInTeamForUser")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
|
||||
@@ -4070,21 +4070,63 @@ func (s *RetryLayerPluginStore) SetWithOptions(pluginId string, key string, valu
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) AnalyticsPostCount(teamId string, mustHaveFile bool, mustHaveHashtag bool) (int64, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) AnalyticsPostCount(teamId string, mustHaveFile bool, mustHaveHashtag bool) (int64, error) {
|
||||
|
||||
return s.PostStore.AnalyticsPostCount(teamId, mustHaveFile, mustHaveHashtag)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.AnalyticsPostCount(teamId, mustHaveFile, mustHaveHashtag)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) AnalyticsPostCountsByDay(options *model.AnalyticsPostCountsOptions) (model.AnalyticsRows, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) AnalyticsPostCountsByDay(options *model.AnalyticsPostCountsOptions) (model.AnalyticsRows, error) {
|
||||
|
||||
return s.PostStore.AnalyticsPostCountsByDay(options)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.AnalyticsPostCountsByDay(options)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) (model.AnalyticsRows, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) (model.AnalyticsRows, error) {
|
||||
|
||||
return s.PostStore.AnalyticsUserCountsWithPostsByDay(teamId)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.AnalyticsUserCountsWithPostsByDay(teamId)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4134,9 +4176,23 @@ func (s *RetryLayerPostStore) Get(id string, skipFetchThreads bool) (*model.Post
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) GetDirectPostParentsForExportAfter(limit int, afterId string) ([]*model.DirectPostForExport, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) GetDirectPostParentsForExportAfter(limit int, afterId string) ([]*model.DirectPostForExport, error) {
|
||||
|
||||
return s.PostStore.GetDirectPostParentsForExportAfter(limit, afterId)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.GetDirectPostParentsForExportAfter(limit, afterId)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4212,21 +4268,63 @@ func (s *RetryLayerPostStore) GetMaxPostSize() int {
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) GetOldest() (*model.Post, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) GetOldest() (*model.Post, error) {
|
||||
|
||||
return s.PostStore.GetOldest()
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.GetOldest()
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) GetOldestEntityCreationTime() (int64, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) GetOldestEntityCreationTime() (int64, error) {
|
||||
|
||||
return s.PostStore.GetOldestEntityCreationTime()
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.GetOldestEntityCreationTime()
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) GetParentsForExportAfter(limit int, afterId string) ([]*model.PostForExport, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) GetParentsForExportAfter(limit int, afterId string) ([]*model.PostForExport, error) {
|
||||
|
||||
return s.PostStore.GetParentsForExportAfter(limit, afterId)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.GetParentsForExportAfter(limit, afterId)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4290,9 +4388,23 @@ func (s *RetryLayerPostStore) GetPostIdBeforeTime(channelId string, time int64)
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool) (*model.PostList, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool) (*model.PostList, error) {
|
||||
|
||||
return s.PostStore.GetPosts(options, allowFromCache)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.GetPosts(options, allowFromCache)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4316,9 +4428,23 @@ func (s *RetryLayerPostStore) GetPostsAfter(options model.GetPostsOptions) (*mod
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.PostForIndexing, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.PostForIndexing, error) {
|
||||
|
||||
return s.PostStore.GetPostsBatchForIndexing(startTime, endTime, limit)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.GetPostsBatchForIndexing(startTime, endTime, limit)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4342,15 +4468,43 @@ func (s *RetryLayerPostStore) GetPostsBefore(options model.GetPostsOptions) (*mo
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) GetPostsByIds(postIds []string) ([]*model.Post, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) GetPostsByIds(postIds []string) ([]*model.Post, error) {
|
||||
|
||||
return s.PostStore.GetPostsByIds(postIds)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.GetPostsByIds(postIds)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) GetPostsCreatedAt(channelId string, time int64) ([]*model.Post, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) GetPostsCreatedAt(channelId string, time int64) ([]*model.Post, error) {
|
||||
|
||||
return s.PostStore.GetPostsCreatedAt(channelId, time)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.GetPostsCreatedAt(channelId, time)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4374,9 +4528,23 @@ func (s *RetryLayerPostStore) GetPostsSince(options model.GetPostsSinceOptions,
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) GetRepliesForExport(parentId string) ([]*model.ReplyForExport, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) GetRepliesForExport(parentId string) ([]*model.ReplyForExport, error) {
|
||||
|
||||
return s.PostStore.GetRepliesForExport(parentId)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.GetRepliesForExport(parentId)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4406,21 +4574,63 @@ func (s *RetryLayerPostStore) InvalidateLastPostTimeCache(channelId string) {
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) Overwrite(post *model.Post) (*model.Post, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) Overwrite(post *model.Post) (*model.Post, error) {
|
||||
|
||||
return s.PostStore.Overwrite(post)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.Overwrite(post)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) OverwriteMultiple(posts []*model.Post) ([]*model.Post, int, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) OverwriteMultiple(posts []*model.Post) ([]*model.Post, int, error) {
|
||||
|
||||
return s.PostStore.OverwriteMultiple(posts)
|
||||
tries := 0
|
||||
for {
|
||||
result, resultVar1, err := s.PostStore.OverwriteMultiple(posts)
|
||||
if err == nil {
|
||||
return result, resultVar1, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, resultVar1, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, resultVar1, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, error) {
|
||||
|
||||
return s.PostStore.PermanentDeleteBatch(endTime, limit)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.PermanentDeleteBatch(endTime, limit)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4504,15 +4714,43 @@ func (s *RetryLayerPostStore) SaveMultiple(posts []*model.Post) ([]*model.Post,
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) Search(teamId string, userId string, params *model.SearchParams) (*model.PostList, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) Search(teamId string, userId string, params *model.SearchParams) (*model.PostList, error) {
|
||||
|
||||
return s.PostStore.Search(teamId, userId, params)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.Search(teamId, userId, params)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId string, teamId string, page int, perPage int) (*model.PostSearchResults, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId string, teamId string, page int, perPage int) (*model.PostSearchResults, error) {
|
||||
|
||||
return s.PostStore.SearchPostsInTeamForUser(paramsList, userId, teamId, page, perPage)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.SearchPostsInTeamForUser(paramsList, userId, teamId, page, perPage)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ func (s SearchPostStore) Update(newPost, oldPost *model.Post) (*model.Post, erro
|
||||
return post, err
|
||||
}
|
||||
|
||||
func (s *SearchPostStore) Overwrite(post *model.Post) (*model.Post, *model.AppError) {
|
||||
func (s *SearchPostStore) Overwrite(post *model.Post) (*model.Post, error) {
|
||||
post, err := s.PostStore.Overwrite(post)
|
||||
if err == nil {
|
||||
s.indexPost(post)
|
||||
@@ -131,7 +131,7 @@ func (s SearchPostStore) PermanentDeleteByChannel(channelID string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (s SearchPostStore) searchPostsInTeamForUserByEngine(engine searchengine.SearchEngineInterface, paramsList []*model.SearchParams, userId, teamId string, page, perPage int) (*model.PostSearchResults, *model.AppError) {
|
||||
func (s SearchPostStore) searchPostsInTeamForUserByEngine(engine searchengine.SearchEngineInterface, paramsList []*model.SearchParams, userId, teamId string, page, perPage int) (*model.PostSearchResults, error) {
|
||||
if err := model.IsSearchParamsListValid(paramsList); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -173,7 +173,7 @@ func (s SearchPostStore) searchPostsInTeamForUserByEngine(engine searchengine.Se
|
||||
return model.MakePostSearchResults(postList, matches), nil
|
||||
}
|
||||
|
||||
func (s SearchPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId, teamId string, page, perPage int) (*model.PostSearchResults, *model.AppError) {
|
||||
func (s SearchPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId, teamId string, page, perPage int) (*model.PostSearchResults, error) {
|
||||
for _, engine := range s.rootStore.searchEngine.GetActiveEngines() {
|
||||
if engine.IsSearchEnabled() {
|
||||
results, err := s.searchPostsInTeamForUserByEngine(engine, paramsList, userId, teamId, page, perPage)
|
||||
|
||||
@@ -6,7 +6,6 @@ package sqlstore
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -14,9 +13,9 @@ import (
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/store/searchlayer"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/mattermost/mattermost-server/v5/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v5/mlog"
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
@@ -205,7 +204,7 @@ func (s *SqlPostStore) Save(post *model.Post) (*model.Post, error) {
|
||||
return posts[0], nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) populateReplyCount(posts []*model.Post) *model.AppError {
|
||||
func (s *SqlPostStore) populateReplyCount(posts []*model.Post) error {
|
||||
rootIds := []string{}
|
||||
for _, post := range posts {
|
||||
rootIds = append(rootIds, post.RootId)
|
||||
@@ -218,11 +217,11 @@ func (s *SqlPostStore) populateReplyCount(posts []*model.Post) *model.AppError {
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return model.NewAppError("SqlPostStore.populateReplyCount", "store.sql_post.populate_reply_count.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return errors.Wrap(err, "post_tosql")
|
||||
}
|
||||
_, err = s.GetMaster().Select(&countList, queryString, args...)
|
||||
if err != nil {
|
||||
return model.NewAppError("SqlPostStore.populateReplyCount", "store.sql_post.populate_reply_count.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return errors.Wrap(err, "failed to count Posts")
|
||||
}
|
||||
|
||||
counts := map[string]int64{}
|
||||
@@ -274,7 +273,7 @@ func (s *SqlPostStore) Update(newPost *model.Post, oldPost *model.Post) (*model.
|
||||
return newPost, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) OverwriteMultiple(posts []*model.Post) ([]*model.Post, int, *model.AppError) {
|
||||
func (s *SqlPostStore) OverwriteMultiple(posts []*model.Post) ([]*model.Post, int, error) {
|
||||
updateAt := model.GetMillis()
|
||||
maxPostSize := s.GetMaxPostSize()
|
||||
for idx, post := range posts {
|
||||
@@ -286,27 +285,27 @@ func (s *SqlPostStore) OverwriteMultiple(posts []*model.Post) ([]*model.Post, in
|
||||
|
||||
tx, err := s.GetMaster().Begin()
|
||||
if err != nil {
|
||||
return nil, -1, model.NewAppError("SqlPostStore.Overwrite", "store.sql_post.overwrite.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, -1, errors.Wrap(err, "begin_transaction")
|
||||
}
|
||||
for idx, post := range posts {
|
||||
if _, err = tx.Update(post); err != nil {
|
||||
txErr := tx.Rollback()
|
||||
if txErr != nil {
|
||||
return nil, idx, model.NewAppError("SqlPostStore.Overwrite", "store.sql_post.overwrite.app_error", nil, txErr.Error(), http.StatusInternalServerError)
|
||||
return nil, idx, errors.Wrap(txErr, "rollback_transaction")
|
||||
}
|
||||
|
||||
return nil, idx, model.NewAppError("SqlPostStore.Overwrite", "store.sql_post.overwrite.app_error", nil, "id="+post.Id+", "+err.Error(), http.StatusInternalServerError)
|
||||
return nil, idx, errors.Wrap(err, "failed to update Post")
|
||||
}
|
||||
}
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
return nil, -1, model.NewAppError("SqlPostStore.Overwrite", "store.sql_post.overwrite.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, -1, errors.Wrap(err, "commit_transaction")
|
||||
}
|
||||
|
||||
return posts, -1, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) Overwrite(post *model.Post) (*model.Post, *model.AppError) {
|
||||
func (s *SqlPostStore) Overwrite(post *model.Post) (*model.Post, error) {
|
||||
posts, _, err := s.OverwriteMultiple([]*model.Post{post})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -558,36 +557,35 @@ func (s *SqlPostStore) PermanentDeleteByChannel(channelId string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetPosts(options model.GetPostsOptions, _ bool) (*model.PostList, *model.AppError) {
|
||||
func (s *SqlPostStore) GetPosts(options model.GetPostsOptions, _ bool) (*model.PostList, error) {
|
||||
if options.PerPage > 1000 {
|
||||
return nil, model.NewAppError("SqlPostStore.GetLinearPosts", "store.sql_post.get_posts.app_error", nil, "channelId="+options.ChannelId, http.StatusBadRequest)
|
||||
return nil, store.NewErrInvalidInput("Post", "<options.PerPage>", options.PerPage)
|
||||
}
|
||||
offset := options.PerPage * options.Page
|
||||
|
||||
rpc := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
posts, err := s.getRootPosts(options.ChannelId, offset, options.PerPage, options.SkipFetchThreads)
|
||||
rpc <- store.StoreResult{Data: posts, Err: err}
|
||||
rpc <- store.StoreResult{Data: posts, NErr: err}
|
||||
close(rpc)
|
||||
}()
|
||||
cpc := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
posts, err := s.getParentsPosts(options.ChannelId, offset, options.PerPage, options.SkipFetchThreads)
|
||||
cpc <- store.StoreResult{Data: posts, Err: err}
|
||||
cpc <- store.StoreResult{Data: posts, NErr: err}
|
||||
close(cpc)
|
||||
}()
|
||||
|
||||
var err *model.AppError
|
||||
list := model.NewPostList()
|
||||
|
||||
rpr := <-rpc
|
||||
if rpr.Err != nil {
|
||||
return nil, rpr.Err
|
||||
if rpr.NErr != nil {
|
||||
return nil, rpr.NErr
|
||||
}
|
||||
|
||||
cpr := <-cpc
|
||||
if cpr.Err != nil {
|
||||
return nil, cpr.Err
|
||||
if cpr.NErr != nil {
|
||||
return nil, cpr.NErr
|
||||
}
|
||||
|
||||
posts := rpr.Data.([]*model.Post)
|
||||
@@ -604,7 +602,7 @@ func (s *SqlPostStore) GetPosts(options model.GetPostsOptions, _ bool) (*model.P
|
||||
|
||||
list.MakeNonNil()
|
||||
|
||||
return list, err
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, error) {
|
||||
@@ -661,6 +659,7 @@ func (s *SqlPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFr
|
||||
ORDER BY CreateAt DESC`
|
||||
}
|
||||
_, err := s.GetReplica().Select(&posts, query, map[string]interface{}{"ChannelId": options.ChannelId, "Time": options.Time})
|
||||
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to find Posts with channelId=%s", options.ChannelId)
|
||||
}
|
||||
@@ -892,7 +891,7 @@ func (s *SqlPostStore) GetPostAfterTime(channelId string, time int64) (*model.Po
|
||||
return post, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) getRootPosts(channelId string, offset int, limit int, skipFetchThreads bool) ([]*model.Post, *model.AppError) {
|
||||
func (s *SqlPostStore) getRootPosts(channelId string, offset int, limit int, skipFetchThreads bool) ([]*model.Post, error) {
|
||||
var posts []*model.Post
|
||||
var fetchQuery string
|
||||
if skipFetchThreads {
|
||||
@@ -902,12 +901,12 @@ func (s *SqlPostStore) getRootPosts(channelId string, offset int, limit int, ski
|
||||
}
|
||||
_, err := s.GetReplica().Select(&posts, fetchQuery, map[string]interface{}{"ChannelId": channelId, "Offset": offset, "Limit": limit})
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetLinearPosts", "store.sql_post.get_root_posts.app_error", nil, "channelId="+channelId+err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "failed to find Posts")
|
||||
}
|
||||
return posts, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) getParentsPosts(channelId string, offset int, limit int, skipFetchThreads bool) ([]*model.Post, *model.AppError) {
|
||||
func (s *SqlPostStore) getParentsPosts(channelId string, offset int, limit int, skipFetchThreads bool) ([]*model.Post, error) {
|
||||
if s.DriverName() == model.DATABASE_DRIVER_POSTGRES {
|
||||
return s.getParentsPostsPostgreSQL(channelId, offset, limit, skipFetchThreads)
|
||||
}
|
||||
@@ -933,7 +932,7 @@ func (s *SqlPostStore) getParentsPosts(channelId string, offset int, limit int,
|
||||
|
||||
_, err := s.GetReplica().Select(&roots, rootQuery, map[string]interface{}{"ChannelId": channelId, "Offset": offset, "Limit": limit})
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetLinearPosts", "store.sql_post.get_parents_posts.app_error", nil, "channelId="+channelId+" err="+err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "failed to find Posts")
|
||||
}
|
||||
if len(roots) == 0 {
|
||||
return nil, nil
|
||||
@@ -966,12 +965,12 @@ func (s *SqlPostStore) getParentsPosts(channelId string, offset int, limit int,
|
||||
ORDER BY CreateAt`,
|
||||
params)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetLinearPosts", "store.sql_post.get_parents_posts.app_error", nil, "channelId="+channelId+" err="+err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "failed to find Posts")
|
||||
}
|
||||
return posts, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) getParentsPostsPostgreSQL(channelId string, offset int, limit int, skipFetchThreads bool) ([]*model.Post, *model.AppError) {
|
||||
func (s *SqlPostStore) getParentsPostsPostgreSQL(channelId string, offset int, limit int, skipFetchThreads bool) ([]*model.Post, error) {
|
||||
var posts []*model.Post
|
||||
replyCountQuery := ""
|
||||
onStatement := "q1.RootId = q2.Id"
|
||||
@@ -1005,7 +1004,7 @@ func (s *SqlPostStore) getParentsPostsPostgreSQL(channelId string, offset int, l
|
||||
ORDER BY CreateAt`,
|
||||
map[string]interface{}{"ChannelId1": channelId, "Offset": offset, "Limit": limit, "ChannelId2": channelId})
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetLinearPosts", "store.sql_post.get_parents_posts.app_error", nil, "channelId="+channelId+" err="+err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrapf(err, "failed to find Posts with channelId=%s", channelId)
|
||||
}
|
||||
return posts, nil
|
||||
}
|
||||
@@ -1151,11 +1150,11 @@ func (s *SqlPostStore) buildSearchPostFilterClause(fromUsers []string, excludedU
|
||||
return filterQuery, queryParams
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) Search(teamId string, userId string, params *model.SearchParams) (*model.PostList, *model.AppError) {
|
||||
func (s *SqlPostStore) Search(teamId string, userId string, params *model.SearchParams) (*model.PostList, error) {
|
||||
return s.search(teamId, userId, params, true, true)
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) search(teamId string, userId string, params *model.SearchParams, channelsByName bool, userByUsername bool) (*model.PostList, *model.AppError) {
|
||||
func (s *SqlPostStore) search(teamId string, userId string, params *model.SearchParams, channelsByName bool, userByUsername bool) (*model.PostList, error) {
|
||||
queryParams := map[string]interface{}{
|
||||
"TeamId": teamId,
|
||||
"UserId": userId,
|
||||
@@ -1266,7 +1265,7 @@ func (s *SqlPostStore) search(teamId string, userId string, params *model.Search
|
||||
var err error
|
||||
terms, err = removeMysqlStopWordsFromTerms(terms)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.search", "store.sql_post.search.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "failed to remove Mysql stop-words from terms")
|
||||
}
|
||||
|
||||
if terms == "" {
|
||||
@@ -1338,7 +1337,7 @@ func removeMysqlStopWordsFromTerms(terms string) (string, error) {
|
||||
return strings.Join(newTerms, " "), nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) (model.AnalyticsRows, *model.AppError) {
|
||||
func (s *SqlPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) (model.AnalyticsRows, error) {
|
||||
query :=
|
||||
`SELECT DISTINCT
|
||||
DATE(FROM_UNIXTIME(Posts.CreateAt / 1000)) AS Name,
|
||||
@@ -1383,12 +1382,12 @@ func (s *SqlPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) (model.A
|
||||
query,
|
||||
map[string]interface{}{"TeamId": teamId, "StartTime": start, "EndTime": end})
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.AnalyticsUserCountsWithPostsByDay", "store.sql_post.analytics_user_counts_posts_by_day.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrapf(err, "failed to find Posts with teamId=%s", teamId)
|
||||
}
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) AnalyticsPostCountsByDay(options *model.AnalyticsPostCountsOptions) (model.AnalyticsRows, *model.AppError) {
|
||||
func (s *SqlPostStore) AnalyticsPostCountsByDay(options *model.AnalyticsPostCountsOptions) (model.AnalyticsRows, error) {
|
||||
|
||||
query :=
|
||||
`SELECT
|
||||
@@ -1447,12 +1446,12 @@ func (s *SqlPostStore) AnalyticsPostCountsByDay(options *model.AnalyticsPostCoun
|
||||
query,
|
||||
map[string]interface{}{"TeamId": options.TeamId, "StartTime": start, "EndTime": end})
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.AnalyticsPostCountsByDay", "store.sql_post.analytics_posts_count_by_day.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrapf(err, "failed to find Posts with teamId=%s", options.TeamId)
|
||||
}
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) AnalyticsPostCount(teamId string, mustHaveFile bool, mustHaveHashtag bool) (int64, *model.AppError) {
|
||||
func (s *SqlPostStore) AnalyticsPostCount(teamId string, mustHaveFile bool, mustHaveHashtag bool) (int64, error) {
|
||||
query :=
|
||||
`SELECT
|
||||
COUNT(Posts.Id) AS Value
|
||||
@@ -1476,25 +1475,25 @@ func (s *SqlPostStore) AnalyticsPostCount(teamId string, mustHaveFile bool, must
|
||||
|
||||
v, err := s.GetReplica().SelectInt(query, map[string]interface{}{"TeamId": teamId})
|
||||
if err != nil {
|
||||
return 0, model.NewAppError("SqlPostStore.AnalyticsPostCount", "store.sql_post.analytics_posts_count.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return 0, errors.Wrap(err, "failed to count Posts")
|
||||
}
|
||||
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetPostsCreatedAt(channelId string, time int64) ([]*model.Post, *model.AppError) {
|
||||
func (s *SqlPostStore) GetPostsCreatedAt(channelId string, time int64) ([]*model.Post, error) {
|
||||
query := `SELECT * FROM Posts WHERE CreateAt = :CreateAt AND ChannelId = :ChannelId`
|
||||
|
||||
var posts []*model.Post
|
||||
_, err := s.GetReplica().Select(&posts, query, map[string]interface{}{"CreateAt": time, "ChannelId": channelId})
|
||||
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetPostsCreatedAt", "store.sql_post.get_posts_created_att.app_error", nil, "channelId="+channelId+err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrapf(err, "failed to find Posts with channelId=%s", channelId)
|
||||
}
|
||||
return posts, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetPostsByIds(postIds []string) ([]*model.Post, *model.AppError) {
|
||||
func (s *SqlPostStore) GetPostsByIds(postIds []string) ([]*model.Post, error) {
|
||||
keys, params := MapStringsToQueryParams(postIds, "Post")
|
||||
|
||||
query := `SELECT p.*, (SELECT count(Posts.Id) FROM Posts WHERE Posts.RootId = (CASE WHEN p.RootId = '' THEN p.Id ELSE p.RootId END) AND Posts.DeleteAt = 0) as ReplyCount FROM Posts p WHERE p.Id IN ` + keys + ` ORDER BY CreateAt DESC`
|
||||
@@ -1503,13 +1502,12 @@ func (s *SqlPostStore) GetPostsByIds(postIds []string) ([]*model.Post, *model.Ap
|
||||
_, err := s.GetReplica().Select(&posts, query, params)
|
||||
|
||||
if err != nil {
|
||||
mlog.Error("Query error getting posts.", mlog.Err(err))
|
||||
return nil, model.NewAppError("SqlPostStore.GetPostsByIds", "store.sql_post.get_posts_by_ids.app_error", nil, "", http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "failed to find Posts")
|
||||
}
|
||||
return posts, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.PostForIndexing, *model.AppError) {
|
||||
func (s *SqlPostStore) GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.PostForIndexing, error) {
|
||||
var posts []*model.PostForIndexing
|
||||
_, err := s.GetSearchReplica().Select(&posts,
|
||||
`SELECT
|
||||
@@ -1541,12 +1539,12 @@ func (s *SqlPostStore) GetPostsBatchForIndexing(startTime int64, endTime int64,
|
||||
map[string]interface{}{"StartTime": startTime, "EndTime": endTime, "NumPosts": limit})
|
||||
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetPostContext", "store.sql_post.get_posts_batch_for_indexing.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "failed to find Posts")
|
||||
}
|
||||
return posts, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, *model.AppError) {
|
||||
func (s *SqlPostStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, error) {
|
||||
var query string
|
||||
if s.DriverName() == "postgres" {
|
||||
query = "DELETE from Posts WHERE Id = any (array (SELECT Id FROM Posts WHERE CreateAt < :EndTime LIMIT :Limit))"
|
||||
@@ -1556,21 +1554,25 @@ func (s *SqlPostStore) PermanentDeleteBatch(endTime int64, limit int64) (int64,
|
||||
|
||||
sqlResult, err := s.GetMaster().Exec(query, map[string]interface{}{"EndTime": endTime, "Limit": limit})
|
||||
if err != nil {
|
||||
return 0, model.NewAppError("SqlPostStore.PermanentDeleteBatch", "store.sql_post.permanent_delete_batch.app_error", nil, ""+err.Error(), http.StatusInternalServerError)
|
||||
return 0, errors.Wrap(err, "failed to delete Posts")
|
||||
}
|
||||
|
||||
rowsAffected, err := sqlResult.RowsAffected()
|
||||
if err != nil {
|
||||
return 0, model.NewAppError("SqlPostStore.PermanentDeleteBatch", "store.sql_post.permanent_delete_batch.app_error", nil, ""+err.Error(), http.StatusInternalServerError)
|
||||
return 0, errors.Wrap(err, "failed to delete Posts")
|
||||
}
|
||||
return rowsAffected, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetOldest() (*model.Post, *model.AppError) {
|
||||
func (s *SqlPostStore) GetOldest() (*model.Post, error) {
|
||||
var post model.Post
|
||||
err := s.GetReplica().SelectOne(&post, "SELECT * FROM Posts ORDER BY CreateAt LIMIT 1")
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetOldest", "app.post.get.app_error", nil, err.Error(), http.StatusNotFound)
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, store.NewErrNotFound("Post", "none")
|
||||
}
|
||||
|
||||
return nil, errors.Wrap(err, "failed to get oldest Post")
|
||||
}
|
||||
|
||||
return &post, nil
|
||||
@@ -1591,7 +1593,7 @@ func (s *SqlPostStore) determineMaxPostSize() int {
|
||||
table_name = 'posts'
|
||||
AND column_name = 'message'
|
||||
`); err != nil {
|
||||
mlog.Error("Unable to determine the maximum supported post size", mlog.Err(err))
|
||||
mlog.Warn("Unable to determine the maximum supported post size", mlog.Err(err))
|
||||
}
|
||||
} else if s.DriverName() == model.DATABASE_DRIVER_MYSQL {
|
||||
// The Post.Message column in MySQL has historically been TEXT, with a maximum
|
||||
@@ -1636,7 +1638,7 @@ func (s *SqlPostStore) GetMaxPostSize() int {
|
||||
return s.maxPostSizeCached
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetParentsForExportAfter(limit int, afterId string) ([]*model.PostForExport, *model.AppError) {
|
||||
func (s *SqlPostStore) GetParentsForExportAfter(limit int, afterId string) ([]*model.PostForExport, error) {
|
||||
for {
|
||||
var rootIds []string
|
||||
_, err := s.GetReplica().Select(&rootIds,
|
||||
@@ -1652,8 +1654,7 @@ func (s *SqlPostStore) GetParentsForExportAfter(limit int, afterId string) ([]*m
|
||||
LIMIT :Limit`,
|
||||
map[string]interface{}{"Limit": limit, "AfterId": afterId})
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetAllAfterForExport", "store.sql_post.get_posts.app_error",
|
||||
nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "failed to find Posts")
|
||||
}
|
||||
|
||||
var postsForExport []*model.PostForExport
|
||||
@@ -1683,8 +1684,7 @@ func (s *SqlPostStore) GetParentsForExportAfter(limit int, afterId string) ([]*m
|
||||
p1.Id`,
|
||||
params)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetAllAfterForExport", "store.sql_post.get_posts.app_error",
|
||||
nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "failed to find Posts")
|
||||
}
|
||||
|
||||
if len(postsForExport) == 0 {
|
||||
@@ -1698,7 +1698,7 @@ func (s *SqlPostStore) GetParentsForExportAfter(limit int, afterId string) ([]*m
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetRepliesForExport(rootId string) ([]*model.ReplyForExport, *model.AppError) {
|
||||
func (s *SqlPostStore) GetRepliesForExport(rootId string) ([]*model.ReplyForExport, error) {
|
||||
var posts []*model.ReplyForExport
|
||||
_, err := s.GetSearchReplica().Select(&posts, `
|
||||
SELECT
|
||||
@@ -1716,13 +1716,13 @@ func (s *SqlPostStore) GetRepliesForExport(rootId string) ([]*model.ReplyForExpo
|
||||
map[string]interface{}{"RootId": rootId})
|
||||
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetAllAfterForExport", "store.sql_post.get_posts.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "failed to find Posts")
|
||||
}
|
||||
|
||||
return posts, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetDirectPostParentsForExportAfter(limit int, afterId string) ([]*model.DirectPostForExport, *model.AppError) {
|
||||
func (s *SqlPostStore) GetDirectPostParentsForExportAfter(limit int, afterId string) ([]*model.DirectPostForExport, error) {
|
||||
query := s.getQueryBuilder().
|
||||
Select("p.*", "Users.Username as User").
|
||||
From("Posts p").
|
||||
@@ -1741,12 +1741,12 @@ func (s *SqlPostStore) GetDirectPostParentsForExportAfter(limit int, afterId str
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetDirectPostParentsForExportAfter", "store.sql_post.get_direct_posts.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "post_tosql")
|
||||
}
|
||||
|
||||
var posts []*model.DirectPostForExport
|
||||
if _, err = s.GetReplica().Select(&posts, queryString, args...); err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetDirectPostParentsForExportAfter", "store.sql_post.get_direct_posts.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "failed to find Posts")
|
||||
}
|
||||
var channelIds []string
|
||||
for _, post := range posts {
|
||||
@@ -1762,12 +1762,12 @@ func (s *SqlPostStore) GetDirectPostParentsForExportAfter(limit int, afterId str
|
||||
|
||||
queryString, args, err = query.ToSql()
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetDirectPostParentsForExportAfter", "store.sql_post.get_direct_posts.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "post_tosql")
|
||||
}
|
||||
|
||||
var channelMembers []*model.ChannelMemberForExport
|
||||
if _, err := s.GetReplica().Select(&channelMembers, queryString, args...); err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetDirectPostParentsForExportAfter", "store.sql_post.get_direct_posts.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "failed to find ChannelMembers")
|
||||
}
|
||||
|
||||
// Build a map of channels and their posts
|
||||
@@ -1792,7 +1792,7 @@ func (s *SqlPostStore) GetDirectPostParentsForExportAfter(limit int, afterId str
|
||||
return posts, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId, teamId string, page, perPage int) (*model.PostSearchResults, *model.AppError) {
|
||||
func (s *SqlPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId, teamId string, page, perPage int) (*model.PostSearchResults, error) {
|
||||
// Since we don't support paging for DB search, we just return nothing for later pages
|
||||
if page > 0 {
|
||||
return model.MakePostSearchResults(model.NewPostList(), nil), nil
|
||||
@@ -1816,7 +1816,7 @@ func (s *SqlPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams
|
||||
go func(params *model.SearchParams) {
|
||||
defer wg.Done()
|
||||
postList, err := s.search(teamId, userId, params, false, false)
|
||||
pchan <- store.StoreResult{Data: postList, Err: err}
|
||||
pchan <- store.StoreResult{Data: postList, NErr: err}
|
||||
}(params)
|
||||
}
|
||||
|
||||
@@ -1826,8 +1826,8 @@ func (s *SqlPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams
|
||||
posts := model.NewPostList()
|
||||
|
||||
for result := range pchan {
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
if result.NErr != nil {
|
||||
return nil, result.NErr
|
||||
}
|
||||
data := result.Data.(*model.PostList)
|
||||
posts.Extend(data)
|
||||
@@ -1838,7 +1838,7 @@ func (s *SqlPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams
|
||||
return model.MakePostSearchResults(posts, nil), nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetOldestEntityCreationTime() (int64, *model.AppError) {
|
||||
func (s *SqlPostStore) GetOldestEntityCreationTime() (int64, error) {
|
||||
query := s.getQueryBuilder().Select("MIN(min_createat) min_createat").
|
||||
Suffix(`FROM (
|
||||
(SELECT MIN(createat) min_createat FROM Posts)
|
||||
@@ -1849,14 +1849,12 @@ func (s *SqlPostStore) GetOldestEntityCreationTime() (int64, *model.AppError) {
|
||||
) entities`)
|
||||
queryString, _, err := query.ToSql()
|
||||
if err != nil {
|
||||
return -1, model.NewAppError("SqlPostStore.GetOldestEntityCreationTime",
|
||||
"store.sql_post.get_oldest_entity_creation_time.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return -1, errors.Wrap(err, "post_tosql")
|
||||
}
|
||||
row := s.GetReplica().Db.QueryRow(queryString)
|
||||
var oldest int64
|
||||
if err := row.Scan(&oldest); err != nil {
|
||||
return -1, model.NewAppError("SqlPostStore.GetOldestEntityCreationTime",
|
||||
"store.sql_post.get_oldest_entity_creation_time.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return -1, errors.Wrap(err, "unable to scan oldest entity creation time")
|
||||
}
|
||||
return oldest, nil
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ type PostStore interface {
|
||||
Delete(postId string, time int64, deleteByID string) error
|
||||
PermanentDeleteByUser(userId string) error
|
||||
PermanentDeleteByChannel(channelId string) error
|
||||
GetPosts(options model.GetPostsOptions, allowFromCache bool) (*model.PostList, *model.AppError)
|
||||
GetPosts(options model.GetPostsOptions, allowFromCache bool) (*model.PostList, error)
|
||||
GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, error)
|
||||
// @openTracingParams userId, teamId, offset, limit
|
||||
GetFlaggedPostsForTeam(userId, teamId string, offset int, limit int) (*model.PostList, error)
|
||||
@@ -267,25 +267,25 @@ type PostStore interface {
|
||||
GetPostIdAfterTime(channelId string, time int64) (string, error)
|
||||
GetPostIdBeforeTime(channelId string, time int64) (string, error)
|
||||
GetEtag(channelId string, allowFromCache bool) string
|
||||
Search(teamId string, userId string, params *model.SearchParams) (*model.PostList, *model.AppError)
|
||||
AnalyticsUserCountsWithPostsByDay(teamId string) (model.AnalyticsRows, *model.AppError)
|
||||
AnalyticsPostCountsByDay(options *model.AnalyticsPostCountsOptions) (model.AnalyticsRows, *model.AppError)
|
||||
AnalyticsPostCount(teamId string, mustHaveFile bool, mustHaveHashtag bool) (int64, *model.AppError)
|
||||
Search(teamId string, userId string, params *model.SearchParams) (*model.PostList, error)
|
||||
AnalyticsUserCountsWithPostsByDay(teamId string) (model.AnalyticsRows, error)
|
||||
AnalyticsPostCountsByDay(options *model.AnalyticsPostCountsOptions) (model.AnalyticsRows, error)
|
||||
AnalyticsPostCount(teamId string, mustHaveFile bool, mustHaveHashtag bool) (int64, error)
|
||||
ClearCaches()
|
||||
InvalidateLastPostTimeCache(channelId string)
|
||||
GetPostsCreatedAt(channelId string, time int64) ([]*model.Post, *model.AppError)
|
||||
Overwrite(post *model.Post) (*model.Post, *model.AppError)
|
||||
OverwriteMultiple(posts []*model.Post) ([]*model.Post, int, *model.AppError)
|
||||
GetPostsByIds(postIds []string) ([]*model.Post, *model.AppError)
|
||||
GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.PostForIndexing, *model.AppError)
|
||||
PermanentDeleteBatch(endTime int64, limit int64) (int64, *model.AppError)
|
||||
GetOldest() (*model.Post, *model.AppError)
|
||||
GetPostsCreatedAt(channelId string, time int64) ([]*model.Post, error)
|
||||
Overwrite(post *model.Post) (*model.Post, error)
|
||||
OverwriteMultiple(posts []*model.Post) ([]*model.Post, int, error)
|
||||
GetPostsByIds(postIds []string) ([]*model.Post, error)
|
||||
GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.PostForIndexing, error)
|
||||
PermanentDeleteBatch(endTime int64, limit int64) (int64, error)
|
||||
GetOldest() (*model.Post, error)
|
||||
GetMaxPostSize() int
|
||||
GetParentsForExportAfter(limit int, afterId string) ([]*model.PostForExport, *model.AppError)
|
||||
GetRepliesForExport(parentId string) ([]*model.ReplyForExport, *model.AppError)
|
||||
GetDirectPostParentsForExportAfter(limit int, afterId string) ([]*model.DirectPostForExport, *model.AppError)
|
||||
SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId, teamId string, page, perPage int) (*model.PostSearchResults, *model.AppError)
|
||||
GetOldestEntityCreationTime() (int64, *model.AppError)
|
||||
GetParentsForExportAfter(limit int, afterId string) ([]*model.PostForExport, error)
|
||||
GetRepliesForExport(parentId string) ([]*model.ReplyForExport, error)
|
||||
GetDirectPostParentsForExportAfter(limit int, afterId string) ([]*model.DirectPostForExport, error)
|
||||
SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId, teamId string, page, perPage int) (*model.PostSearchResults, error)
|
||||
GetOldestEntityCreationTime() (int64, error)
|
||||
}
|
||||
|
||||
type UserStore interface {
|
||||
|
||||
@@ -15,7 +15,7 @@ type PostStore struct {
|
||||
}
|
||||
|
||||
// AnalyticsPostCount provides a mock function with given fields: teamId, mustHaveFile, mustHaveHashtag
|
||||
func (_m *PostStore) AnalyticsPostCount(teamId string, mustHaveFile bool, mustHaveHashtag bool) (int64, *model.AppError) {
|
||||
func (_m *PostStore) AnalyticsPostCount(teamId string, mustHaveFile bool, mustHaveHashtag bool) (int64, error) {
|
||||
ret := _m.Called(teamId, mustHaveFile, mustHaveHashtag)
|
||||
|
||||
var r0 int64
|
||||
@@ -25,20 +25,18 @@ func (_m *PostStore) AnalyticsPostCount(teamId string, mustHaveFile bool, mustHa
|
||||
r0 = ret.Get(0).(int64)
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, bool, bool) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, bool, bool) error); ok {
|
||||
r1 = rf(teamId, mustHaveFile, mustHaveHashtag)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// AnalyticsPostCountsByDay provides a mock function with given fields: options
|
||||
func (_m *PostStore) AnalyticsPostCountsByDay(options *model.AnalyticsPostCountsOptions) (model.AnalyticsRows, *model.AppError) {
|
||||
func (_m *PostStore) AnalyticsPostCountsByDay(options *model.AnalyticsPostCountsOptions) (model.AnalyticsRows, error) {
|
||||
ret := _m.Called(options)
|
||||
|
||||
var r0 model.AnalyticsRows
|
||||
@@ -50,20 +48,18 @@ func (_m *PostStore) AnalyticsPostCountsByDay(options *model.AnalyticsPostCounts
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(*model.AnalyticsPostCountsOptions) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(*model.AnalyticsPostCountsOptions) error); ok {
|
||||
r1 = rf(options)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// AnalyticsUserCountsWithPostsByDay provides a mock function with given fields: teamId
|
||||
func (_m *PostStore) AnalyticsUserCountsWithPostsByDay(teamId string) (model.AnalyticsRows, *model.AppError) {
|
||||
func (_m *PostStore) AnalyticsUserCountsWithPostsByDay(teamId string) (model.AnalyticsRows, error) {
|
||||
ret := _m.Called(teamId)
|
||||
|
||||
var r0 model.AnalyticsRows
|
||||
@@ -75,13 +71,11 @@ func (_m *PostStore) AnalyticsUserCountsWithPostsByDay(teamId string) (model.Ana
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(teamId)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
@@ -130,7 +124,7 @@ func (_m *PostStore) Get(id string, skipFetchThreads bool) (*model.PostList, err
|
||||
}
|
||||
|
||||
// GetDirectPostParentsForExportAfter provides a mock function with given fields: limit, afterId
|
||||
func (_m *PostStore) GetDirectPostParentsForExportAfter(limit int, afterId string) ([]*model.DirectPostForExport, *model.AppError) {
|
||||
func (_m *PostStore) GetDirectPostParentsForExportAfter(limit int, afterId string) ([]*model.DirectPostForExport, error) {
|
||||
ret := _m.Called(limit, afterId)
|
||||
|
||||
var r0 []*model.DirectPostForExport
|
||||
@@ -142,13 +136,11 @@ func (_m *PostStore) GetDirectPostParentsForExportAfter(limit int, afterId strin
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(int, string) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(int, string) error); ok {
|
||||
r1 = rf(limit, afterId)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
@@ -252,7 +244,7 @@ func (_m *PostStore) GetMaxPostSize() int {
|
||||
}
|
||||
|
||||
// GetOldest provides a mock function with given fields:
|
||||
func (_m *PostStore) GetOldest() (*model.Post, *model.AppError) {
|
||||
func (_m *PostStore) GetOldest() (*model.Post, error) {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 *model.Post
|
||||
@@ -264,20 +256,18 @@ func (_m *PostStore) GetOldest() (*model.Post, *model.AppError) {
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func() *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func() error); ok {
|
||||
r1 = rf()
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetOldestEntityCreationTime provides a mock function with given fields:
|
||||
func (_m *PostStore) GetOldestEntityCreationTime() (int64, *model.AppError) {
|
||||
func (_m *PostStore) GetOldestEntityCreationTime() (int64, error) {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 int64
|
||||
@@ -287,20 +277,18 @@ func (_m *PostStore) GetOldestEntityCreationTime() (int64, *model.AppError) {
|
||||
r0 = ret.Get(0).(int64)
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func() *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func() error); ok {
|
||||
r1 = rf()
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetParentsForExportAfter provides a mock function with given fields: limit, afterId
|
||||
func (_m *PostStore) GetParentsForExportAfter(limit int, afterId string) ([]*model.PostForExport, *model.AppError) {
|
||||
func (_m *PostStore) GetParentsForExportAfter(limit int, afterId string) ([]*model.PostForExport, error) {
|
||||
ret := _m.Called(limit, afterId)
|
||||
|
||||
var r0 []*model.PostForExport
|
||||
@@ -312,13 +300,11 @@ func (_m *PostStore) GetParentsForExportAfter(limit int, afterId string) ([]*mod
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(int, string) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(int, string) error); ok {
|
||||
r1 = rf(limit, afterId)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
@@ -390,7 +376,7 @@ func (_m *PostStore) GetPostIdBeforeTime(channelId string, time int64) (string,
|
||||
}
|
||||
|
||||
// GetPosts provides a mock function with given fields: options, allowFromCache
|
||||
func (_m *PostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool) (*model.PostList, *model.AppError) {
|
||||
func (_m *PostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool) (*model.PostList, error) {
|
||||
ret := _m.Called(options, allowFromCache)
|
||||
|
||||
var r0 *model.PostList
|
||||
@@ -402,13 +388,11 @@ func (_m *PostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsOptions, bool) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsOptions, bool) error); ok {
|
||||
r1 = rf(options, allowFromCache)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
@@ -438,7 +422,7 @@ func (_m *PostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostLi
|
||||
}
|
||||
|
||||
// GetPostsBatchForIndexing provides a mock function with given fields: startTime, endTime, limit
|
||||
func (_m *PostStore) GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.PostForIndexing, *model.AppError) {
|
||||
func (_m *PostStore) GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.PostForIndexing, error) {
|
||||
ret := _m.Called(startTime, endTime, limit)
|
||||
|
||||
var r0 []*model.PostForIndexing
|
||||
@@ -450,13 +434,11 @@ func (_m *PostStore) GetPostsBatchForIndexing(startTime int64, endTime int64, li
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(int64, int64, int) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(int64, int64, int) error); ok {
|
||||
r1 = rf(startTime, endTime, limit)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
@@ -486,7 +468,7 @@ func (_m *PostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostL
|
||||
}
|
||||
|
||||
// GetPostsByIds provides a mock function with given fields: postIds
|
||||
func (_m *PostStore) GetPostsByIds(postIds []string) ([]*model.Post, *model.AppError) {
|
||||
func (_m *PostStore) GetPostsByIds(postIds []string) ([]*model.Post, error) {
|
||||
ret := _m.Called(postIds)
|
||||
|
||||
var r0 []*model.Post
|
||||
@@ -498,20 +480,18 @@ func (_m *PostStore) GetPostsByIds(postIds []string) ([]*model.Post, *model.AppE
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func([]string) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func([]string) error); ok {
|
||||
r1 = rf(postIds)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetPostsCreatedAt provides a mock function with given fields: channelId, time
|
||||
func (_m *PostStore) GetPostsCreatedAt(channelId string, time int64) ([]*model.Post, *model.AppError) {
|
||||
func (_m *PostStore) GetPostsCreatedAt(channelId string, time int64) ([]*model.Post, error) {
|
||||
ret := _m.Called(channelId, time)
|
||||
|
||||
var r0 []*model.Post
|
||||
@@ -523,13 +503,11 @@ func (_m *PostStore) GetPostsCreatedAt(channelId string, time int64) ([]*model.P
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, int64) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, int64) error); ok {
|
||||
r1 = rf(channelId, time)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
@@ -559,7 +537,7 @@ func (_m *PostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFrom
|
||||
}
|
||||
|
||||
// GetRepliesForExport provides a mock function with given fields: parentId
|
||||
func (_m *PostStore) GetRepliesForExport(parentId string) ([]*model.ReplyForExport, *model.AppError) {
|
||||
func (_m *PostStore) GetRepliesForExport(parentId string) ([]*model.ReplyForExport, error) {
|
||||
ret := _m.Called(parentId)
|
||||
|
||||
var r0 []*model.ReplyForExport
|
||||
@@ -571,13 +549,11 @@ func (_m *PostStore) GetRepliesForExport(parentId string) ([]*model.ReplyForExpo
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(parentId)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
@@ -612,7 +588,7 @@ func (_m *PostStore) InvalidateLastPostTimeCache(channelId string) {
|
||||
}
|
||||
|
||||
// Overwrite provides a mock function with given fields: post
|
||||
func (_m *PostStore) Overwrite(post *model.Post) (*model.Post, *model.AppError) {
|
||||
func (_m *PostStore) Overwrite(post *model.Post) (*model.Post, error) {
|
||||
ret := _m.Called(post)
|
||||
|
||||
var r0 *model.Post
|
||||
@@ -624,20 +600,18 @@ func (_m *PostStore) Overwrite(post *model.Post) (*model.Post, *model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(*model.Post) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(*model.Post) error); ok {
|
||||
r1 = rf(post)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// OverwriteMultiple provides a mock function with given fields: posts
|
||||
func (_m *PostStore) OverwriteMultiple(posts []*model.Post) ([]*model.Post, int, *model.AppError) {
|
||||
func (_m *PostStore) OverwriteMultiple(posts []*model.Post) ([]*model.Post, int, error) {
|
||||
ret := _m.Called(posts)
|
||||
|
||||
var r0 []*model.Post
|
||||
@@ -656,20 +630,18 @@ func (_m *PostStore) OverwriteMultiple(posts []*model.Post) ([]*model.Post, int,
|
||||
r1 = ret.Get(1).(int)
|
||||
}
|
||||
|
||||
var r2 *model.AppError
|
||||
if rf, ok := ret.Get(2).(func([]*model.Post) *model.AppError); ok {
|
||||
var r2 error
|
||||
if rf, ok := ret.Get(2).(func([]*model.Post) error); ok {
|
||||
r2 = rf(posts)
|
||||
} else {
|
||||
if ret.Get(2) != nil {
|
||||
r2 = ret.Get(2).(*model.AppError)
|
||||
}
|
||||
r2 = ret.Error(2)
|
||||
}
|
||||
|
||||
return r0, r1, r2
|
||||
}
|
||||
|
||||
// PermanentDeleteBatch provides a mock function with given fields: endTime, limit
|
||||
func (_m *PostStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, *model.AppError) {
|
||||
func (_m *PostStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, error) {
|
||||
ret := _m.Called(endTime, limit)
|
||||
|
||||
var r0 int64
|
||||
@@ -679,13 +651,11 @@ func (_m *PostStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, *m
|
||||
r0 = ret.Get(0).(int64)
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(int64, int64) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(int64, int64) error); ok {
|
||||
r1 = rf(endTime, limit)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
@@ -773,7 +743,7 @@ func (_m *PostStore) SaveMultiple(posts []*model.Post) ([]*model.Post, int, erro
|
||||
}
|
||||
|
||||
// Search provides a mock function with given fields: teamId, userId, params
|
||||
func (_m *PostStore) Search(teamId string, userId string, params *model.SearchParams) (*model.PostList, *model.AppError) {
|
||||
func (_m *PostStore) Search(teamId string, userId string, params *model.SearchParams) (*model.PostList, error) {
|
||||
ret := _m.Called(teamId, userId, params)
|
||||
|
||||
var r0 *model.PostList
|
||||
@@ -785,20 +755,18 @@ func (_m *PostStore) Search(teamId string, userId string, params *model.SearchPa
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, string, *model.SearchParams) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, string, *model.SearchParams) error); ok {
|
||||
r1 = rf(teamId, userId, params)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// SearchPostsInTeamForUser provides a mock function with given fields: paramsList, userId, teamId, page, perPage
|
||||
func (_m *PostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId string, teamId string, page int, perPage int) (*model.PostSearchResults, *model.AppError) {
|
||||
func (_m *PostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId string, teamId string, page int, perPage int) (*model.PostSearchResults, error) {
|
||||
ret := _m.Called(paramsList, userId, teamId, page, perPage)
|
||||
|
||||
var r0 *model.PostSearchResults
|
||||
@@ -810,13 +778,11 @@ func (_m *PostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams,
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func([]*model.SearchParams, string, string, int, int) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func([]*model.SearchParams, string, string, int, int) error); ok {
|
||||
r1 = rf(paramsList, userId, teamId, page, perPage)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
|
||||
@@ -2654,8 +2654,8 @@ func testPostStoreGetDirectPostParentsForExportAfter(t *testing.T, ss store.Stor
|
||||
p1, nErr = ss.Post().Save(p1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
r1, err := ss.Post().GetDirectPostParentsForExportAfter(10000, strings.Repeat("0", 26))
|
||||
assert.Nil(t, err)
|
||||
r1, nErr := ss.Post().GetDirectPostParentsForExportAfter(10000, strings.Repeat("0", 26))
|
||||
assert.Nil(t, nErr)
|
||||
|
||||
assert.Equal(t, p1.Message, r1[0].Message)
|
||||
|
||||
@@ -2720,8 +2720,8 @@ func testPostStoreGetDirectPostParentsForExportAfterDeleted(t *testing.T, ss sto
|
||||
_, nErr = ss.Post().Update(o1a, p1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
r1, err := ss.Post().GetDirectPostParentsForExportAfter(10000, strings.Repeat("0", 26))
|
||||
assert.Nil(t, err)
|
||||
r1, nErr := ss.Post().GetDirectPostParentsForExportAfter(10000, strings.Repeat("0", 26))
|
||||
assert.Nil(t, nErr)
|
||||
|
||||
assert.Equal(t, 0, len(r1))
|
||||
|
||||
|
||||
@@ -4275,7 +4275,7 @@ func (s *TimerLayerPluginStore) SetWithOptions(pluginId string, key string, valu
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) AnalyticsPostCount(teamId string, mustHaveFile bool, mustHaveHashtag bool) (int64, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) AnalyticsPostCount(teamId string, mustHaveFile bool, mustHaveHashtag bool) (int64, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.AnalyticsPostCount(teamId, mustHaveFile, mustHaveHashtag)
|
||||
@@ -4291,7 +4291,7 @@ func (s *TimerLayerPostStore) AnalyticsPostCount(teamId string, mustHaveFile boo
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) AnalyticsPostCountsByDay(options *model.AnalyticsPostCountsOptions) (model.AnalyticsRows, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) AnalyticsPostCountsByDay(options *model.AnalyticsPostCountsOptions) (model.AnalyticsRows, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.AnalyticsPostCountsByDay(options)
|
||||
@@ -4307,7 +4307,7 @@ func (s *TimerLayerPostStore) AnalyticsPostCountsByDay(options *model.AnalyticsP
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) (model.AnalyticsRows, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) (model.AnalyticsRows, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.AnalyticsUserCountsWithPostsByDay(teamId)
|
||||
@@ -4370,7 +4370,7 @@ func (s *TimerLayerPostStore) Get(id string, skipFetchThreads bool) (*model.Post
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) GetDirectPostParentsForExportAfter(limit int, afterId string) ([]*model.DirectPostForExport, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) GetDirectPostParentsForExportAfter(limit int, afterId string) ([]*model.DirectPostForExport, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.GetDirectPostParentsForExportAfter(limit, afterId)
|
||||
@@ -4466,7 +4466,7 @@ func (s *TimerLayerPostStore) GetMaxPostSize() int {
|
||||
return result
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) GetOldest() (*model.Post, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) GetOldest() (*model.Post, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.GetOldest()
|
||||
@@ -4482,7 +4482,7 @@ func (s *TimerLayerPostStore) GetOldest() (*model.Post, *model.AppError) {
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) GetOldestEntityCreationTime() (int64, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) GetOldestEntityCreationTime() (int64, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.GetOldestEntityCreationTime()
|
||||
@@ -4498,7 +4498,7 @@ func (s *TimerLayerPostStore) GetOldestEntityCreationTime() (int64, *model.AppEr
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) GetParentsForExportAfter(limit int, afterId string) ([]*model.PostForExport, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) GetParentsForExportAfter(limit int, afterId string) ([]*model.PostForExport, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.GetParentsForExportAfter(limit, afterId)
|
||||
@@ -4562,7 +4562,7 @@ func (s *TimerLayerPostStore) GetPostIdBeforeTime(channelId string, time int64)
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool) (*model.PostList, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool) (*model.PostList, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.GetPosts(options, allowFromCache)
|
||||
@@ -4594,7 +4594,7 @@ func (s *TimerLayerPostStore) GetPostsAfter(options model.GetPostsOptions) (*mod
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.PostForIndexing, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.PostForIndexing, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.GetPostsBatchForIndexing(startTime, endTime, limit)
|
||||
@@ -4626,7 +4626,7 @@ func (s *TimerLayerPostStore) GetPostsBefore(options model.GetPostsOptions) (*mo
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) GetPostsByIds(postIds []string) ([]*model.Post, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) GetPostsByIds(postIds []string) ([]*model.Post, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.GetPostsByIds(postIds)
|
||||
@@ -4642,7 +4642,7 @@ func (s *TimerLayerPostStore) GetPostsByIds(postIds []string) ([]*model.Post, *m
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) GetPostsCreatedAt(channelId string, time int64) ([]*model.Post, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) GetPostsCreatedAt(channelId string, time int64) ([]*model.Post, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.GetPostsCreatedAt(channelId, time)
|
||||
@@ -4674,7 +4674,7 @@ func (s *TimerLayerPostStore) GetPostsSince(options model.GetPostsSinceOptions,
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) GetRepliesForExport(parentId string) ([]*model.ReplyForExport, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) GetRepliesForExport(parentId string) ([]*model.ReplyForExport, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.GetRepliesForExport(parentId)
|
||||
@@ -4721,7 +4721,7 @@ func (s *TimerLayerPostStore) InvalidateLastPostTimeCache(channelId string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) Overwrite(post *model.Post) (*model.Post, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) Overwrite(post *model.Post) (*model.Post, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.Overwrite(post)
|
||||
@@ -4737,7 +4737,7 @@ func (s *TimerLayerPostStore) Overwrite(post *model.Post) (*model.Post, *model.A
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) OverwriteMultiple(posts []*model.Post) ([]*model.Post, int, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) OverwriteMultiple(posts []*model.Post) ([]*model.Post, int, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, resultVar1, err := s.PostStore.OverwriteMultiple(posts)
|
||||
@@ -4753,7 +4753,7 @@ func (s *TimerLayerPostStore) OverwriteMultiple(posts []*model.Post) ([]*model.P
|
||||
return result, resultVar1, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.PermanentDeleteBatch(endTime, limit)
|
||||
@@ -4833,7 +4833,7 @@ func (s *TimerLayerPostStore) SaveMultiple(posts []*model.Post) ([]*model.Post,
|
||||
return result, resultVar1, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) Search(teamId string, userId string, params *model.SearchParams) (*model.PostList, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) Search(teamId string, userId string, params *model.SearchParams) (*model.PostList, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.Search(teamId, userId, params)
|
||||
@@ -4849,7 +4849,7 @@ func (s *TimerLayerPostStore) Search(teamId string, userId string, params *model
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId string, teamId string, page int, perPage int) (*model.PostSearchResults, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId string, teamId string, page int, perPage int) (*model.PostSearchResults, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.SearchPostsInTeamForUser(paramsList, userId, teamId, page, perPage)
|
||||
|
||||
Ссылка в новой задаче
Block a user