Skip to content

Add file upload support#1

Open
joshua-cain wants to merge 1 commit intomasterfrom
dev-attachment-support
Open

Add file upload support#1
joshua-cain wants to merge 1 commit intomasterfrom
dev-attachment-support

Conversation

@joshua-cain
Copy link
Copy Markdown

No description provided.

@joshua-cain joshua-cain requested a review from solb December 24, 2020 01:46
Comment thread index.js
}

function call(method, body, workspace) {
function authHeaders(workspace) {
Copy link
Copy Markdown
Contributor

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

Comment thread index.js
var options = {
headers: {
Authorization: 'Bearer ' + token,
...authHeaders(workspace),
Copy link
Copy Markdown
Contributor

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)

Comment thread index.js
};

var payload = '';
var form = undefined;
Copy link
Copy Markdown
Contributor

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?

Comment thread index.js
return [];
}

// TODO: figure out why this doesn't work
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop this. Rebase mistake?

Comment thread index.js
return collected;
}

async function get_event_files_data(event, workspace) {
Copy link
Copy Markdown
Contributor

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

Comment thread index.js
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)
Copy link
Copy Markdown
Contributor

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().

Comment thread index.js
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 => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Closure style

Comment thread index.js
}

if(event.files) {
const uploaded_files = await upload_files(await get_event_files_data(event, workspace), paired.workspace, paired.channel);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: const

Comment thread package.json
"dependencies": {
"pg": "8.2.0"
"pg": "8.2.0",
"form-data": "3.0.0"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please alphabetize

Comment thread index.js
.map(file => {
if(!file.mimetype || !file.mimetype.includes('image/')) {
return {
text: `<${file.permalink}|${file.name}>`
Copy link
Copy Markdown
Contributor

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants