diff options
Diffstat (limited to 'app/command.go')
-rw-r--r-- | app/command.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/app/command.go b/app/command.go new file mode 100644 index 000000000..2d5861206 --- /dev/null +++ b/app/command.go @@ -0,0 +1,31 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package app + +import ( + "github.com/mattermost/platform/model" +) + +func CreateCommandPost(post *model.Post, teamId string, response *model.CommandResponse) (*model.Post, *model.AppError) { + post.Message = parseSlackLinksToMarkdown(response.Text) + post.CreateAt = model.GetMillis() + + if response.Attachments != nil { + parseSlackAttachment(post, response.Attachments) + } + + switch response.ResponseType { + case model.COMMAND_RESPONSE_TYPE_IN_CHANNEL: + return CreatePost(post, teamId, true) + case model.COMMAND_RESPONSE_TYPE_EPHEMERAL: + if response.Text == "" { + return post, nil + } + + post.ParentId = "" + SendEphemeralPost(teamId, post.UserId, post) + } + + return post, nil +} |