This repository has no description
0

Configure Feed

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

feat: move to cdn

+6 -31
+6 -31
src/features/takes/handlers/upload.ts
··· 8 8 type HackatimeVersion, 9 9 } from "../../../libs/hackatime"; 10 10 import { prettyPrintTime } from "../../../libs/time"; 11 + import { deployToHackClubCDN } from "../../../libs/cdn"; 11 12 12 13 export default async function upload() { 13 14 slackApp.anyMessage(async ({ payload, context }) => { ··· 102 103 .replace(/~(.*?)~/g, "~~$1~~") // Strikethrough 103 104 .replace(/<(https?:\/\/[^|]+)\|([^>]+)>/g, "[$2]($1)"); // Links 104 105 105 - const mediaUrls = []; 106 - 107 - if (payload.files && payload.files.length > 0) { 108 - for (const file of payload.files) { 109 - if ( 110 - file.mimetype && 111 - (file.mimetype.startsWith("image/") || 112 - file.mimetype.startsWith("video/")) 113 - ) { 114 - const fileres = await slackClient.files.sharedPublicURL( 115 - { 116 - file: file.id as string, 117 - token: process.env.SLACK_USER_TOKEN, 118 - }, 119 - ); 120 - 121 - const fetchRes = await fetch( 122 - fileres.file?.permalink_public as string, 123 - ); 124 - const html = await fetchRes.text(); 125 - const match = html.match( 126 - /https:\/\/files.slack.com\/files-pri\/[^"]+pub_secret=([^"&]*)/, 127 - ); 128 - const filePublicUrl = match?.[0]; 129 - 130 - if (filePublicUrl) { 131 - mediaUrls.push(filePublicUrl); 132 - } 133 - } 134 - } 135 - } 106 + const mediaUrls = payload.files?.length 107 + ? await deployToHackClubCDN( 108 + payload.files.map((file) => file.url_private), 109 + ).then((res) => res.files) 110 + : []; 136 111 137 112 // fetch time spent on project via hackatime 138 113 const timeSpent = await fetchHackatimeSummary(