коммит произвёл
Harrison Healey
родитель
6d2882f6e7
Коммит
a25afb1134
@@ -132,7 +132,9 @@ func CreatePost(c *Context, post *model.Post, triggerWebhooks bool) (*model.Post
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if post.CreateAt != 0 && !HasPermissionToContext(c, model.PERMISSION_MANAGE_SYSTEM) {
|
||||||
post.CreateAt = 0
|
post.CreateAt = 0
|
||||||
|
}
|
||||||
|
|
||||||
post.Hashtags, _ = model.ParseHashtags(post.Message)
|
post.Hashtags, _ = model.ParseHashtags(post.Message)
|
||||||
|
|
||||||
|
|||||||
@@ -138,6 +138,37 @@ func TestCreatePost(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCreatePostWithCreateAt(t *testing.T) {
|
||||||
|
|
||||||
|
// An ordinary user cannot use CreateAt
|
||||||
|
|
||||||
|
th := Setup().InitBasic()
|
||||||
|
Client := th.BasicClient
|
||||||
|
channel1 := th.BasicChannel
|
||||||
|
|
||||||
|
post := &model.Post{
|
||||||
|
ChannelId: channel1.Id,
|
||||||
|
Message: "PLT-4349",
|
||||||
|
CreateAt: 1234,
|
||||||
|
}
|
||||||
|
if resp, err := Client.CreatePost(post); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
} else if rpost := resp.Data.(*model.Post); rpost.CreateAt == post.CreateAt {
|
||||||
|
t.Fatal("post should be created with default CreateAt timestamp for ordinary user")
|
||||||
|
}
|
||||||
|
|
||||||
|
// But a System Admin user can
|
||||||
|
|
||||||
|
th2 := Setup().InitSystemAdmin()
|
||||||
|
SysClient := th2.SystemAdminClient
|
||||||
|
|
||||||
|
if resp, err := SysClient.CreatePost(post); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
} else if rpost := resp.Data.(*model.Post); rpost.CreateAt != post.CreateAt {
|
||||||
|
t.Fatal("post should be created with provided CreateAt timestamp for System Admin user")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func testCreatePostWithOutgoingHook(
|
func testCreatePostWithOutgoingHook(
|
||||||
t *testing.T,
|
t *testing.T,
|
||||||
hookContentType string,
|
hookContentType string,
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user