···
125
125
title_url: `${process.env.API_URL}/api/video/${take.id}`,
126
126
title: {
127
127
type: "plain_text",
128
128
-
text: `take from ${generateSlackDate(takeUploadedAt)}`,
128
128
+
text: `${take.description} by <@${user}> uploaded at ${generateSlackDate(takeUploadedAt)}`,
129
129
},
130
130
thumbnail_url: `https://cachet.dunkirk.sh/users/${payload.user}/r`,
131
131
alt_text: `takes from ${takeUploadedAt?.toLocaleString("en-CA", { year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", hour12: false })} uploaded with the description: *${take.description}*`,
···
210
210
},
211
211
],
212
212
},
213
213
-
{
214
214
-
type: "divider",
215
215
-
},
216
216
-
{
217
217
-
type: "context",
218
218
-
elements: [
219
219
-
{
220
220
-
type: "mrkdwn",
221
221
-
text: `take by <@${user}> for \`${prettyPrintTime(take.elapsedTimeMs)}\` working on: *${take.description}*`,
222
222
-
},
223
223
-
],
224
224
-
},
225
213
],
226
214
});
227
215
} catch (error) {
···
246
234
});
247
235
248
236
slackApp.action("select_multiplier", async () => {});
237
237
+
slackApp.action("dismiss_message", async ({ payload, context }) => {
238
238
+
try {
239
239
+
if (context.respond)
240
240
+
await context.respond({
241
241
+
delete_original: true,
242
242
+
});
243
243
+
} catch (error) {
244
244
+
console.error("Error dismissing message:", error);
245
245
+
Sentry.captureException(error, {
246
246
+
extra: {
247
247
+
payload,
248
248
+
context,
249
249
+
},
250
250
+
tags: {
251
251
+
type: "dismiss_message_error",
252
252
+
},
253
253
+
});
254
254
+
}
255
255
+
});
249
256
250
257
slackApp.action("approve", async ({ payload, context }) => {
251
258
try {
252
259
const multiplier = Object.values(payload.state.values)[0]
253
260
?.select_multiplier?.selected_option?.value;
261
261
+
254
262
// @ts-expect-error
255
263
const takeId = payload.actions[0]?.value;
256
264
···
261
269
if (take.length === 0) {
262
270
return;
263
271
}
272
272
+
264
273
const takeToApprove = take[0];
265
274
if (!takeToApprove) return;
266
275
276
276
+
if (!multiplier || Number.isNaN(Number(multiplier))) {
277
277
+
await slackClient.chat.postEphemeral({
278
278
+
channel: process.env.SLACK_REVIEW_CHANNEL || "",
279
279
+
user: payload.user.id,
280
280
+
text: ":warning: please select a multiplier",
281
281
+
blocks: [
282
282
+
{
283
283
+
type: "actions",
284
284
+
elements: [
285
285
+
{
286
286
+
type: "button",
287
287
+
text: {
288
288
+
type: "plain_text",
289
289
+
text: "⚠️ I'll select a multiplier",
290
290
+
},
291
291
+
action_id: "dismiss_message",
292
292
+
},
293
293
+
],
294
294
+
},
295
295
+
],
296
296
+
});
297
297
+
return;
298
298
+
}
299
299
+
267
300
await db
268
301
.update(takesTable)
269
302
.set({
···
275
308
await slackClient.chat.postMessage({
276
309
channel: payload.user.id,
277
310
thread_ts: take[0]?.ts as string,
278
278
-
text: `take approved with multiplier \`${multiplier}\` so you have earned *${Number((takeToApprove.elapsedTimeMs * Number(multiplier)) / 1000 / 60).toFixed(1)} takes*!`,
311
311
+
text: `take approved with multiplier \`${multiplier}\` so you have earned *${Number((takeToApprove.elapsedTimeMs * Number(multiplier)) / 1000 / 360).toFixed(1)} takes*!`,
279
312
});
280
313
281
314
// delete the message from the review channel