This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

feat: prevent nan takes

+47 -14
+47 -14
src/features/takes/services/upload.ts
··· 125 125 title_url: `${process.env.API_URL}/api/video/${take.id}`, 126 126 title: { 127 127 type: "plain_text", 128 - text: `take from ${generateSlackDate(takeUploadedAt)}`, 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 - { 214 - type: "divider", 215 - }, 216 - { 217 - type: "context", 218 - elements: [ 219 - { 220 - type: "mrkdwn", 221 - text: `take by <@${user}> for \`${prettyPrintTime(take.elapsedTimeMs)}\` working on: *${take.description}*`, 222 - }, 223 - ], 224 - }, 225 213 ], 226 214 }); 227 215 } catch (error) { ··· 246 234 }); 247 235 248 236 slackApp.action("select_multiplier", async () => {}); 237 + slackApp.action("dismiss_message", async ({ payload, context }) => { 238 + try { 239 + if (context.respond) 240 + await context.respond({ 241 + delete_original: true, 242 + }); 243 + } catch (error) { 244 + console.error("Error dismissing message:", error); 245 + Sentry.captureException(error, { 246 + extra: { 247 + payload, 248 + context, 249 + }, 250 + tags: { 251 + type: "dismiss_message_error", 252 + }, 253 + }); 254 + } 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 + 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 + 264 273 const takeToApprove = take[0]; 265 274 if (!takeToApprove) return; 266 275 276 + if (!multiplier || Number.isNaN(Number(multiplier))) { 277 + await slackClient.chat.postEphemeral({ 278 + channel: process.env.SLACK_REVIEW_CHANNEL || "", 279 + user: payload.user.id, 280 + text: ":warning: please select a multiplier", 281 + blocks: [ 282 + { 283 + type: "actions", 284 + elements: [ 285 + { 286 + type: "button", 287 + text: { 288 + type: "plain_text", 289 + text: "⚠️ I'll select a multiplier", 290 + }, 291 + action_id: "dismiss_message", 292 + }, 293 + ], 294 + }, 295 + ], 296 + }); 297 + return; 298 + } 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 - text: `take approved with multiplier \`${multiplier}\` so you have earned *${Number((takeToApprove.elapsedTimeMs * Number(multiplier)) / 1000 / 60).toFixed(1)} takes*!`, 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