PLT-5800 Cleaned up duplicated code for adding slack attachments to posts (#5711)
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
06930f378c
Коммит
06a7c3ba8e
@@ -40,17 +40,17 @@ type SlackFile struct {
|
||||
}
|
||||
|
||||
type SlackPost struct {
|
||||
User string `json:"user"`
|
||||
BotId string `json:"bot_id"`
|
||||
BotUsername string `json:"username"`
|
||||
Text string `json:"text"`
|
||||
TimeStamp string `json:"ts"`
|
||||
Type string `json:"type"`
|
||||
SubType string `json:"subtype"`
|
||||
Comment *SlackComment `json:"comment"`
|
||||
Upload bool `json:"upload"`
|
||||
File *SlackFile `json:"file"`
|
||||
Attachments []SlackAttachment `json:"attachments"`
|
||||
User string `json:"user"`
|
||||
BotId string `json:"bot_id"`
|
||||
BotUsername string `json:"username"`
|
||||
Text string `json:"text"`
|
||||
TimeStamp string `json:"ts"`
|
||||
Type string `json:"type"`
|
||||
SubType string `json:"subtype"`
|
||||
Comment *SlackComment `json:"comment"`
|
||||
Upload bool `json:"upload"`
|
||||
File *SlackFile `json:"file"`
|
||||
Attachments []*model.SlackAttachment `json:"attachments"`
|
||||
}
|
||||
|
||||
type SlackComment struct {
|
||||
@@ -58,13 +58,6 @@ type SlackComment struct {
|
||||
Comment string `json:"comment"`
|
||||
}
|
||||
|
||||
type SlackAttachment struct {
|
||||
Id int `json:"id"`
|
||||
Text string `json:"text"`
|
||||
Pretext string `json:"pretext"`
|
||||
Fields []map[string]interface{} `json:"fields"`
|
||||
}
|
||||
|
||||
func truncateRunes(s string, i int) string {
|
||||
runes := []rune(s)
|
||||
if len(runes) > i {
|
||||
@@ -284,15 +277,7 @@ func SlackAddPosts(teamId string, channel *model.Channel, posts []SlackPost, use
|
||||
props := make(model.StringInterface)
|
||||
props["override_username"] = sPost.BotUsername
|
||||
if len(sPost.Attachments) > 0 {
|
||||
var mAttachments []interface{}
|
||||
for _, attachment := range sPost.Attachments {
|
||||
mAttachments = append(mAttachments, map[string]interface{}{
|
||||
"text": attachment.Text,
|
||||
"pretext": attachment.Pretext,
|
||||
"fields": attachment.Fields,
|
||||
})
|
||||
}
|
||||
props["attachments"] = mAttachments
|
||||
props["attachments"] = sPost.Attachments
|
||||
}
|
||||
|
||||
post := &model.Post{
|
||||
|
||||
Ссылка в новой задаче
Block a user