MM-29987 Implement new collapsed threads API (#16091)

This commit is contained in:
Eli Yukelzon
2020-11-08 10:36:46 +02:00
committed by GitHub
parent 483441cea2
commit 45e340b5be
22 changed files with 1155 additions and 49 deletions

View File

@@ -329,6 +329,28 @@ func (c *Context) RequireTokenId() *Context {
return c
}
func (c *Context) RequireThreadId() *Context {
if c.Err != nil {
return c
}
if !model.IsValidId(c.Params.ThreadId) {
c.SetInvalidUrlParam("thread_id")
}
return c
}
func (c *Context) RequireTimestamp() *Context {
if c.Err != nil {
return c
}
if c.Params.Timestamp == 0 {
c.SetInvalidUrlParam("timestamp")
}
return c
}
func (c *Context) RequireChannelId() *Context {
if c.Err != nil {
return c

View File

@@ -27,6 +27,8 @@ type Params struct {
TeamId string
InviteId string
TokenId string
ThreadId string
Timestamp int64
ChannelId string
PostId string
FileId string
@@ -111,6 +113,10 @@ func ParamsFromRequest(r *http.Request) *Params {
params.TokenId = val
}
if val, ok := props["thread_id"]; ok {
params.ThreadId = val
}
if val, ok := props["channel_id"]; ok {
params.ChannelId = val
} else {
@@ -231,6 +237,12 @@ func ParamsFromRequest(r *http.Request) *Params {
params.Page = val
}
if val, err := strconv.ParseInt(props["timestamp"], 10, 64); err != nil || val < 0 {
params.Timestamp = 0
} else {
params.Timestamp = val
}
if val, err := strconv.ParseBool(query.Get("permanent")); err == nil {
params.Permanent = val
}

View File

@@ -73,7 +73,6 @@ func setupTestHelper(t testing.TB, store store.Store, includeCacheLayer bool) *T
*newConfig.AnnouncementSettings.AdminNoticesEnabled = false
*newConfig.AnnouncementSettings.UserNoticesEnabled = false
memoryStore.Set(newConfig)
var options []app.Option
options = append(options, app.ConfigStore(memoryStore))
options = append(options, app.StoreOverride(mainHelper.Store))