Skip to content
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

add support ChatWork Alert Destination. #2482

Merged
merged 2 commits into from
Jul 31, 2018

Conversation

matsumo
Copy link
Contributor

@matsumo matsumo commented Apr 23, 2018

Copy link
Member

@arikfr arikfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Please see comments.



class ChatWork(BaseDestination):
ALERTS_DEFAULT_MESSAGE_TEMPLATE = '{alert_name} changed state to {new_state}.\\n{alert_url}\\n{query_url}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alert names might include unicode so it's better to use a unicode string (i.e. prefix this with u -> u'{alert_name} changed...').

alert_url = '{host}/alerts/{alert_id}'.format(host=host, alert_id=alert.id)
query_url = '{host}/queries/{query_id}'.format(host=host, query_id=query.id)

message_template = options.get('message_template', ChatWork.ALERTS_DEFAULT_MESSAGE_TEMPLATE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better that we use some proper templating engine here to avoid possible security risk that can be introduced by using a user input with String#format.

We already use pystache, so you can easily use it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've realized that we do the same thing in email destination... so will address both together.

@arikfr arikfr merged commit 44014d7 into getredash:master Jul 31, 2018
@arikfr
Copy link
Member

arikfr commented Jul 31, 2018

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants