PLT-4938 Add app package and move logic over from api package (#4931)
* 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
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
07bad4d6d5
Коммит
97558f6a6e
31
app/command.go
Обычный файл
31
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
|
||||
}
|
||||
Ссылка в новой задаче
Block a user