Initial Commit of Ephemeral Message Support for System Admins (#8611)
Fixed Permission Test Fixed and extended ephemeral message tests; Removed Online/Activity Updates Set Create Time to current time gofmt
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
3a4c7603b3
Коммит
997df03ac1
@@ -162,6 +162,10 @@ func (c *Client4) GetPostsRoute() string {
|
||||
return fmt.Sprintf("/posts")
|
||||
}
|
||||
|
||||
func (c *Client4) GetPostsEphemeralRoute() string {
|
||||
return fmt.Sprintf("/posts/ephemeral")
|
||||
}
|
||||
|
||||
func (c *Client4) GetConfigRoute() string {
|
||||
return fmt.Sprintf("/config")
|
||||
}
|
||||
@@ -1771,6 +1775,16 @@ func (c *Client4) CreatePost(post *Post) (*Post, *Response) {
|
||||
}
|
||||
}
|
||||
|
||||
// CreatePostEphemeral creates a ephemeral post based on the provided post struct which is send to the given user id
|
||||
func (c *Client4) CreatePostEphemeral(post *PostEphemeral) (*Post, *Response) {
|
||||
if r, err := c.DoApiPost(c.GetPostsEphemeralRoute(), post.ToUnsanitizedJson()); err != nil {
|
||||
return nil, BuildErrorResponse(r, err)
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return PostFromJson(r.Body), BuildResponse(r)
|
||||
}
|
||||
}
|
||||
|
||||
// UpdatePost updates a post based on the provided post struct.
|
||||
func (c *Client4) UpdatePost(postId string, post *Post) (*Post, *Response) {
|
||||
if r, err := c.DoApiPut(c.GetPostRoute(postId), post.ToUnsanitizedJson()); err != nil {
|
||||
|
||||
@@ -52,6 +52,7 @@ var PERMISSION_MANAGE_OAUTH *Permission
|
||||
var PERMISSION_MANAGE_SYSTEM_WIDE_OAUTH *Permission
|
||||
var PERMISSION_CREATE_POST *Permission
|
||||
var PERMISSION_CREATE_POST_PUBLIC *Permission
|
||||
var PERMISSION_CREATE_POST_EPHEMERAL *Permission
|
||||
var PERMISSION_EDIT_POST *Permission
|
||||
var PERMISSION_EDIT_OTHERS_POSTS *Permission
|
||||
var PERMISSION_DELETE_POST *Permission
|
||||
@@ -297,6 +298,12 @@ func initializePermissions() {
|
||||
"authentication.permissions.create_post_public.description",
|
||||
PERMISSION_SCOPE_CHANNEL,
|
||||
}
|
||||
PERMISSION_CREATE_POST_EPHEMERAL = &Permission{
|
||||
"create_post_ephemeral",
|
||||
"authentication.permissions.create_post_ephemeral.name",
|
||||
"authentication.permissions.create_post_ephemeral.description",
|
||||
PERMISSION_SCOPE_CHANNEL,
|
||||
}
|
||||
PERMISSION_EDIT_POST = &Permission{
|
||||
"edit_post",
|
||||
"authentication.permissions.edit_post.name",
|
||||
@@ -419,6 +426,7 @@ func initializePermissions() {
|
||||
PERMISSION_MANAGE_SYSTEM_WIDE_OAUTH,
|
||||
PERMISSION_CREATE_POST,
|
||||
PERMISSION_CREATE_POST_PUBLIC,
|
||||
PERMISSION_CREATE_POST_EPHEMERAL,
|
||||
PERMISSION_EDIT_POST,
|
||||
PERMISSION_EDIT_OTHERS_POSTS,
|
||||
PERMISSION_DELETE_POST,
|
||||
|
||||
@@ -80,6 +80,11 @@ type Post struct {
|
||||
HasReactions bool `json:"has_reactions,omitempty"`
|
||||
}
|
||||
|
||||
type PostEphemeral struct {
|
||||
UserID string `json:"user_id"`
|
||||
Post *Post `json:"post"`
|
||||
}
|
||||
|
||||
type PostPatch struct {
|
||||
IsPinned *bool `json:"is_pinned"`
|
||||
Message *string `json:"message"`
|
||||
@@ -432,6 +437,11 @@ func (o *Post) WithRewrittenImageURLs(f func(string) string) *Post {
|
||||
return ©
|
||||
}
|
||||
|
||||
func (o *PostEphemeral) ToUnsanitizedJson() string {
|
||||
b, _ := json.Marshal(o)
|
||||
return string(b)
|
||||
}
|
||||
|
||||
// RewriteImageURLs takes a message and returns a copy that has all of the image URLs replaced
|
||||
// according to the function f. For each image URL, f will be invoked, and the resulting markdown
|
||||
// will contain the URL returned by that invocation instead.
|
||||
|
||||
@@ -330,6 +330,7 @@ func MakeDefaultRoles() map[string]*Role {
|
||||
PERMISSION_LIST_USERS_WITHOUT_TEAM.Id,
|
||||
PERMISSION_MANAGE_JOBS.Id,
|
||||
PERMISSION_CREATE_POST_PUBLIC.Id,
|
||||
PERMISSION_CREATE_POST_EPHEMERAL.Id,
|
||||
PERMISSION_CREATE_USER_ACCESS_TOKEN.Id,
|
||||
PERMISSION_READ_USER_ACCESS_TOKEN.Id,
|
||||
PERMISSION_REVOKE_USER_ACCESS_TOKEN.Id,
|
||||
|
||||
Ссылка в новой задаче
Block a user