Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
540dd9ae94
Коммит
1c7f25773a
@@ -113,7 +113,7 @@ func (a *App) TriggerWebhook(payload *model.OutgoingWebhookPayload, hook *model.
|
|||||||
|
|
||||||
webhookResp := model.OutgoingWebhookResponseFromJson(resp.Body)
|
webhookResp := model.OutgoingWebhookResponseFromJson(resp.Body)
|
||||||
|
|
||||||
if webhookResp != nil && webhookResp.Text != nil {
|
if webhookResp != nil && (webhookResp.Text != nil || len(webhookResp.Attachments) > 0) {
|
||||||
postRootId := ""
|
postRootId := ""
|
||||||
if webhookResp.ResponseType == model.OUTGOING_HOOK_RESPONSE_TYPE_COMMENT {
|
if webhookResp.ResponseType == model.OUTGOING_HOOK_RESPONSE_TYPE_COMMENT {
|
||||||
postRootId = post.Id
|
postRootId = post.Id
|
||||||
@@ -122,7 +122,18 @@ func (a *App) TriggerWebhook(payload *model.OutgoingWebhookPayload, hook *model.
|
|||||||
webhookResp.Props = make(model.StringInterface)
|
webhookResp.Props = make(model.StringInterface)
|
||||||
}
|
}
|
||||||
webhookResp.Props["webhook_display_name"] = hook.DisplayName
|
webhookResp.Props["webhook_display_name"] = hook.DisplayName
|
||||||
if _, err := a.CreateWebhookPost(hook.CreatorId, channel, *webhookResp.Text, webhookResp.Username, webhookResp.IconURL, webhookResp.Props, webhookResp.Type, postRootId); err != nil {
|
|
||||||
|
text := ""
|
||||||
|
if webhookResp.Text != nil {
|
||||||
|
text = a.ProcessSlackText(*webhookResp.Text)
|
||||||
|
}
|
||||||
|
webhookResp.Attachments = a.ProcessSlackAttachments(webhookResp.Attachments)
|
||||||
|
// attachments is in here for slack compatibility
|
||||||
|
if len(webhookResp.Attachments) > 0 {
|
||||||
|
webhookResp.Props["attachments"] = webhookResp.Attachments
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := a.CreateWebhookPost(hook.CreatorId, channel, text, webhookResp.Username, webhookResp.IconURL, webhookResp.Props, webhookResp.Type, postRootId); err != nil {
|
||||||
l4g.Error(utils.T("api.post.handle_webhook_events_and_forget.create_post.error"), err)
|
l4g.Error(utils.T("api.post.handle_webhook_events_and_forget.create_post.error"), err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,12 +46,13 @@ type OutgoingWebhookPayload struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type OutgoingWebhookResponse struct {
|
type OutgoingWebhookResponse struct {
|
||||||
Text *string `json:"text"`
|
Text *string `json:"text"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
IconURL string `json:"icon_url"`
|
IconURL string `json:"icon_url"`
|
||||||
Props StringInterface `json:"props"`
|
Props StringInterface `json:"props"`
|
||||||
Type string `json:"type"`
|
Attachments []*SlackAttachment `json:"attachments"`
|
||||||
ResponseType string `json:"response_type"`
|
Type string `json:"type"`
|
||||||
|
ResponseType string `json:"response_type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const OUTGOING_HOOK_RESPONSE_TYPE_COMMENT = "comment"
|
const OUTGOING_HOOK_RESPONSE_TYPE_COMMENT = "comment"
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user