Skip to content

Commit

Permalink
refactor: Add in slackbot pdfssssssssssssssssssssssssssssssssssss
Browse files Browse the repository at this point in the history
  • Loading branch information
charlie-map committed Oct 5, 2024
1 parent 9a44679 commit a52ccdb
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 19 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"google-spreadsheet": "3.3.0",
"lock": "1.1.0",
"node-cron": "3.0.3",
"node-fetch": "^3.3.2",
"tsup": "8.1.0"
}
}
42 changes: 42 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 27 additions & 19 deletions src/bot/requestReview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,20 @@ export const requestReview = {
},
},
},
// {
// type: 'input',
// block_id: ActionId.PDF_IDENTIFIER,
// label: {
// text: 'Input PDF File',
// type: 'plain_text',
// },
// element: {
// type: 'file_input',
// action_id: ActionId.PDF_IDENTIFIER,
// max_files: 1,
// filetypes: ['pdf'],
// },
// },
{
type: 'input',
block_id: ActionId.PDF_IDENTIFIER,
label: {
text: 'Input PDF File',
type: 'plain_text',
},
element: {
type: 'file_input',
action_id: ActionId.PDF_IDENTIFIER,
max_files: 1,
filetypes: ['pdf'],
},
},
],
submit: {
type: 'plain_text',
Expand Down Expand Up @@ -172,13 +172,21 @@ export const requestReview = {
const candidateIdentifier = blockUtils.getBlockValue(body, ActionId.CANDIDATE_IDENTIFIER);
const reviewType = blockUtils.getBlockValue(body, ActionId.REVIEW_TYPE).selected_option.text
.text;
// const pdf = blockUtils.getBlockValue(body, ActionId.PDF_IDENTIFIER);
// log.d(pdf);
const fileInput = blockUtils.getBlockValue(body, ActionId.PDF_IDENTIFIER);
const pdf = fileInput.files[0];
const pdfIdentifier = pdf.name;
const pdfDownloadUrl = pdf.url_private_download;

const pdfBuffer = await new Promise(resolve => {
fetch(pdfDownloadUrl)
.then(res => res.arrayBuffer())
.then(buffer => {
return resolve(buffer);
});
});

// Upload PDF to S3 here.
const pdfIdentifier = 'Report_Tech_Trials__Auth___Analysis_bskiff_sourceallies.com.pdf';
const pdf = Buffer.from('test file should be here not this');
await putPdfToS3(pdfIdentifier, pdf);
await putPdfToS3(pdfIdentifier, pdfBuffer);

const numberOfReviewersValue = numberOfReviewers.value;
const deadlineValue = deadline.selected_option.value;
Expand Down

0 comments on commit a52ccdb

Please sign in to comment.