Skip to content

Commit 80cb10f

Browse files
committed
add claim button to /report post
1 parent 4f74990 commit 80cb10f

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

pybot/endpoints/slack/actions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ async def claimed(action: Action, app: SirBot):
159159
attachments = action['original_message']['attachments']
160160

161161
for index, attachment in enumerate(attachments):
162-
if attachment['callback_id'] == 'claimed':
162+
if 'callback_id' in attachment and attachment['callback_id'] == 'claimed':
163163
attachments[index] = claimed_attachment(user_id)
164164
response['attachments'] = attachments
165165

@@ -176,7 +176,7 @@ async def reset_claim(action: Action, app: SirBot):
176176

177177
attachments = action['original_message']['attachments']
178178
for index, attachment in enumerate(attachments):
179-
if attachment['callback_id'] == 'claimed':
179+
if 'callback_id' in attachment and attachment['callback_id'] == 'claimed':
180180
attachments[index] = not_claimed_attachment()
181181

182182
response['attachments'] = attachments

pybot/endpoints/slack/utils/action_messages.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def ticket_attachments(action):
8686
def greeted_attachment(user_id: str) -> List[dict]:
8787
return [{
8888
"text": f":100:<@{user_id}> has greeted the new user!:100:\n"
89-
f"<!date^{now()}^Greeted at {{date_num}} {{time_secs}}|Failed to parse time>",
89+
f"<!date^{now()}^Greeted at {{date_num}} {{time_secs}}|Failed to parse time>",
9090
"fallback": "",
9191
"color": "#3AA3E3",
9292
"callback_id": "greeted",
@@ -139,7 +139,7 @@ def not_claimed_attachment():
139139
def claimed_attachment(user_id):
140140
return {
141141
"text": f"Claimed by <@{user_id}>\n"
142-
f"<!date^{now()}^Claimed at {{date_num}} {{time_secs}}|Failed to parse time>",
142+
f"<!date^{now()}^Claimed at {{date_num}} {{time_secs}}|Failed to parse time>",
143143
"fallback": "",
144144
"color": "#3AA3E3",
145145
"callback_id": "claimed",
@@ -221,7 +221,7 @@ def build_report_message(slack_id, details, message_details):
221221
}
222222

223223
]
224-
}]
224+
}, not_claimed_attachment()]
225225

226226
return {
227227
"text": message,
@@ -233,7 +233,7 @@ def build_report_message(slack_id, details, message_details):
233233
def mentee_claimed_attachment(user_id: str, record: str) -> List[dict]:
234234
return [{
235235
"text": f":100: Request claimed by <@{user_id}>:100:\n"
236-
f"<!date^{now()}^Claimed at {{date_num}} {{time_secs}}|Failed to parse time>",
236+
f"<!date^{now()}^Claimed at {{date_num}} {{time_secs}}|Failed to parse time>",
237237
"fallback": "",
238238
"color": "#3AA3E3",
239239
"callback_id": "claim_mentee",
@@ -251,7 +251,7 @@ def mentee_claimed_attachment(user_id: str, record: str) -> List[dict]:
251251
def mentee_unclaimed_attachment(user_id: str, record: str) -> List[dict]:
252252
return [{
253253
'text': f"Reset by <@{user_id}> at"
254-
f" <!date^{now()}^ {{date_num}} {{time_secs}}|Failed to parse time>",
254+
f" <!date^{now()}^ {{date_num}} {{time_secs}}|Failed to parse time>",
255255
'fallback': '',
256256
'color': '#3AA3E3',
257257
'callback_id': 'claim_mentee',

0 commit comments

Comments
 (0)