mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-29987 Implement new collapsed threads API (#16091)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user