-
Notifications
You must be signed in to change notification settings - Fork 0
Add file upload support #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| } | ||
|
|
||
| function call(method, body, workspace) { | ||
| function authHeaders(workspace) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: More general name, as it might have other headers in the future
| var options = { | ||
| headers: { | ||
| Authorization: 'Bearer ' + token, | ||
| ...authHeaders(workspace), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to headers: authHeaders(workspace), (or whatever we call it)
| }; | ||
|
|
||
| var payload = ''; | ||
| var form = undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're making it undefined, why initialize it at all?
| return []; | ||
| } | ||
|
|
||
| // TODO: figure out why this doesn't work |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop this. Rebase mistake?
| return collected; | ||
| } | ||
|
|
||
| async function get_event_files_data(event, workspace) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have this accept a files array instead of an event
| if(event.files) { | ||
| const uploaded_files = await upload_files(await get_event_files_data(event, workspace), paired.workspace, paired.channel); | ||
| message.attachments = uploaded_files | ||
| .filter(file => typeof file === 'object' && file.permalink) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove filter() because we can trust upload_files().
| const uploaded_files = await upload_files(await get_event_files_data(event, workspace), paired.workspace, paired.channel); | ||
| message.attachments = uploaded_files | ||
| .filter(file => typeof file === 'object' && file.permalink) | ||
| .map(file => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Closure style
| } | ||
|
|
||
| if(event.files) { | ||
| const uploaded_files = await upload_files(await get_event_files_data(event, workspace), paired.workspace, paired.channel); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: const
| "dependencies": { | ||
| "pg": "8.2.0" | ||
| "pg": "8.2.0", | ||
| "form-data": "3.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please alphabetize
| .map(file => { | ||
| if(!file.mimetype || !file.mimetype.includes('image/')) { | ||
| return { | ||
| text: `<${file.permalink}|${file.name}>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't appear to be working (at least for PDFs)
No description provided.