New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PLT-3658 Support for Slack attachments in outgoing webhook response (#7774) #8102
Conversation
app/webhook.go
Outdated
@@ -122,7 +122,15 @@ func (a *App) TriggerWebhook(payload *model.OutgoingWebhookPayload, hook *model. | |||
webhookResp.Props = make(model.StringInterface) | |||
} | |||
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 := a.ProcessSlackText(*webhookResp.Text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that the text in the webhook response isn't being processed as a Slack text, so I added this here. It parses tokens like <!here>, <!all>, <@ userid>. If it is not relevant or needed, I can remove it.
@ccbrown @jwilander Wondering if either of you have suggestion on the best way to test this? @yeoji Huge thanks for this feature! Much needed for fully compatible outgoing webhooks |
|
Spinmint test server created at: http://i-0b670d23f180099b9.spinmint.com Test Account 1: Email: Test Account 2: Email: Instance ID: i-0b670d23f180099b9 |
@jasonblais For manual/spinmint testing, you might be able to just upload a sample response to S3 or somewhere and use that for the hook. (I would go ahead and just do this for you, but I'm off today and away from the computer.) But of course, the best thing would be to get some unit tests for this. :P |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming someone tests this, lgtm. I'm tempted to hit the "request changes" button for a unit test, but I'll let @jwilander be the decider on that.
If it helps, I used Mockbin. The official service isn't working, but there's one hosted on https://requestloggerbin.herokuapp.com/bin/create |
@ccbrown @jwilander Would either of you be able to help with the testing? |
@jasonblais I looked at it @yeoji it looks like if the response only contains an attachment then it doesn't work, otherwise it seems to work well. Would you be able to update it so that if a response has only an attachment, it still works? |
Hi @jwilander, I have updated the PR, it should now work when the response does not contain text |
Spinmint test server destroyed |
@yeoji if you give this a rebase I can merge it in |
@jwilander Done :) |
Thanks @yeoji ! |
Summary
This PR adds support for Slack attachments for outgoing webhook responses.
It also adds support for mentions with <@userid> and announcement tokens (eg. <!here>) in the outgoing webhook responses as implemented in #7615
Ticket Link
The GitHub issue opened for this ticket is #7774