|
10 | 10 | from dispatch import config
|
11 | 11 | from dispatch.enums import DispatchEnum, DocumentResourceTypes, DocumentResourceReferenceTypes
|
12 | 12 |
|
| 13 | +"""Dict for reminder strings and values. Note values are in hours""" |
| 14 | +reminder_select_values = { |
| 15 | + "thirty": {"message": "30 minutes", "value": 0.5}, |
| 16 | + "one_hour": {"message": "1 hour", "value": 1}, |
| 17 | + "two_hours": {"message": "2 hours", "value": 2}, |
| 18 | +} |
| 19 | + |
13 | 20 |
|
14 | 21 | class MessageType(DispatchEnum):
|
15 | 22 | evergreen_reminder = "evergreen-reminder"
|
@@ -218,6 +225,11 @@ class MessageType(DispatchEnum):
|
218 | 225 | "\n", " "
|
219 | 226 | ).strip()
|
220 | 227 |
|
| 228 | +INCIDENT_REPORT_REMINDER_DELAYED_DESCRIPTION = """You asked me to send you this reminder to write a {{report_type}} for this incident. |
| 229 | +You can use `{{command}}` in the conversation to assist you in writing one.""".replace( |
| 230 | + "\n", " " |
| 231 | +).strip() |
| 232 | + |
221 | 233 | INCIDENT_CLOSE_REMINDER_DESCRIPTION = """The status of this incident hasn't been updated recently.
|
222 | 234 | You can use `{{command}}` in the conversation to close the incident if it has been resolved and can be closed.""".replace(
|
223 | 235 | "\n", " "
|
@@ -531,13 +543,39 @@ class MessageType(DispatchEnum):
|
531 | 543 | {"title": "Next Steps", "text": "{{next_steps}}"},
|
532 | 544 | ]
|
533 | 545 |
|
| 546 | +REMIND_AGAIN_OPTIONS = { |
| 547 | + "text": "[Optional] Remind me again in:", |
| 548 | + "select": { |
| 549 | + "placeholder": "Choose a time value", |
| 550 | + "select_action": ConversationButtonActions.remind_again, |
| 551 | + "options": [ |
| 552 | + { |
| 553 | + "option_text": value["message"], |
| 554 | + "option_value": "{{organization_slug}}-{{incident_id}}-{{report_type}}-" + key, |
| 555 | + } |
| 556 | + for key, value in reminder_select_values.items() |
| 557 | + ], |
| 558 | + }, |
| 559 | +} |
| 560 | + |
534 | 561 | INCIDENT_REPORT_REMINDER = [
|
535 | 562 | {
|
536 | 563 | "title": "{{name}} Incident - {{report_type}} Reminder",
|
537 | 564 | "title_link": "{{ticket_weblink}}",
|
538 | 565 | "text": INCIDENT_REPORT_REMINDER_DESCRIPTION,
|
539 | 566 | },
|
540 | 567 | INCIDENT_TITLE,
|
| 568 | + REMIND_AGAIN_OPTIONS, |
| 569 | +] |
| 570 | + |
| 571 | +INCIDENT_REPORT_REMINDER_DELAYED = [ |
| 572 | + { |
| 573 | + "title": "{{name}} Incident - {{report_type}} Reminder", |
| 574 | + "title_link": "{{ticket_weblink}}", |
| 575 | + "text": INCIDENT_REPORT_REMINDER_DELAYED_DESCRIPTION, |
| 576 | + }, |
| 577 | + INCIDENT_TITLE, |
| 578 | + REMIND_AGAIN_OPTIONS, |
541 | 579 | ]
|
542 | 580 |
|
543 | 581 |
|
@@ -764,6 +802,17 @@ def render_message_template(message_template: List[dict], **kwargs):
|
764 | 802 | if button.get("button_url"):
|
765 | 803 | button["button_url"] = env.from_string(button["button_url"]).render(**kwargs)
|
766 | 804 |
|
| 805 | + # render drop-down list |
| 806 | + if select := d.get("select"): |
| 807 | + if placeholder := select.get("placeholder"): |
| 808 | + select["placeholder"] = env.from_string(placeholder).render(**kwargs) |
| 809 | + |
| 810 | + select["select_action"] = env.from_string(select["select_action"]).render(**kwargs) |
| 811 | + |
| 812 | + for option in select["options"]: |
| 813 | + option["option_text"] = env.from_string(option["option_text"]).render(**kwargs) |
| 814 | + option["option_value"] = env.from_string(option["option_value"]).render(**kwargs) |
| 815 | + |
767 | 816 | if d.get("visibility_mapping"):
|
768 | 817 | d["text"] = d["visibility_mapping"][kwargs["visibility"]]
|
769 | 818 |
|
|
0 commit comments