Skip to content

Commit 269c5c5

Browse files
committed
thread user and time ticket status changes
1 parent 3ee88f7 commit 269c5c5

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

pybot/endpoints/slack/actions.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ async def ticket_status(action: Action, app: SirBot):
3232
Updates the ticket status dropdown. (I don't know why we need to manually
3333
update the message for this..)
3434
"""
35-
logger.info(action)
36-
response = updated_ticket_status(action)
37-
await app.plugins["slack"].api.query(methods.CHAT_UPDATE, response)
35+
slack = app.plugins["slack"].api
36+
37+
response, selected_option = updated_ticket_status(action)
38+
update_message = update_ticket_message(action, selected_option['text'])
39+
40+
await slack.query(methods.CHAT_UPDATE, response)
41+
await slack.query(methods.CHAT_POST_MESSAGE, update_message)
3842

3943

4044
async def open_ticket(action: Action, app: SirBot):

pybot/endpoints/slack/utils/action_messages.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ def base_response(action):
2929
return response
3030

3131

32+
def update_ticket_message(action, selected_value):
33+
user = action["user"]["id"]
34+
update_message = (f'<@{user}> updated status to {selected_value} at '
35+
f'<!date^{now()}^{{date_num}} {{time_secs}}|Failed to parse time>')
36+
return {
37+
'text': update_message,
38+
'channel': action['channel']['id'],
39+
'thread_ts': action['message_ts']
40+
}
41+
42+
3243
def updated_ticket_status(action):
3344
selected_option = action['actions'][0]['selected_options'][0]
3445
selected_option['text'] = TICKET_OPTIONS[selected_option['value']]
@@ -39,7 +50,7 @@ def updated_ticket_status(action):
3950
**base_response(action),
4051
'attachments': updated_attachments
4152
}
42-
return response
53+
return response, selected_option
4354

4455

4556
def ticket_attachments(action):

0 commit comments

Comments
 (0)