mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* Add app package and move logic over from api package * Change app package functions to return errors * Move non-api tests into app package * Fix merge
32 lines
781 B
Go
32 lines
781 B
Go
// 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
|
|
}
|