Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Implement MSC4039 download_file action #99
Implement MSC4039 download_file action #99
Changes from 2 commits
d64636a
7c06a33
be97fad
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check warning on line 333 in src/ClientWidgetApi.ts
GitHub Actions / build
Check warning on line 440 in src/ClientWidgetApi.ts
GitHub Actions / build
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.
Again, more for the MSC but... what about large files? I guess the answer is that since there's no specific limit on postMessage, we can add a different API later if it's needed?
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.
I don't see an obvious issue with postMessage at a glance. Mostly, we assume that we can do whatever we already can do for uploading. This update to MSC4039 seeks to address Authenticated Media, which got overlooked so far for the widget API. The real answer is probably to revamp the widget API entirely to enable widgets to use their own scoped access tokens to access the C-S API directly, but we won't get there before Matrix 1.12.
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.
Well, I don't think trying to download a 1GB file over the postmessage API is going to be a great user experience, but yeah, if this is more of a stop-gap solution until we have scoped access tokens then that's probably okay.
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.
Why does this need to be an exception? Is it taken directly from the wire and we don't want to convert?
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.
same as e.g.
matrix-widget-api/src/interfaces/OpenIDCredentialsAction.ts
Line 24 in 3c9543c
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.
OK, careful of cargoculting then - the other instance has zero comments on why the exception exists too. Doesn't feel like a blocker though.
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.
I guess this is more a comment on the MSC, but maybe
body
would be a better name for this?file
implies https://developer.mozilla.org/en-US/docs/Web/API/File which is not one of the many things this type can be. Probably doesn't need to match the upload type (although that isn't a file object either...)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.
Also, another comment that's really on the MSC, but... why
XMLHttpRequestBodyInit
? This seems like a bit of a weird union type defined in the fetch API for... actually I'm not even sure why, it doesn't seem like it's referenced. The react-sdk impl just sends a blob. If something sends ones of the other types, how would it go about determining what it's actually got?instanceof
in js can be... special.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.
The explanations I can offer is, quoting from the MSC:
To your first question:
To be consistent, would you think that we would also have to rename the upload's data.file? We would then need to spend some thoughts on backwards compatibility.
To the second one:
XMLHttpRequestBodyInit
is reused again here because it was already used inmatrix-widget-api/src/interfaces/UploadFileAction.ts
Line 23 in 3c9543c
Again, to be consistent we would need to change it there too and manage version incompatibilities.
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.
Well, IMO renaming file on the upload API would be clearer, but that's for the MSC discussion anyway. If we think the right way to go is to change upload too, then we'd need a new version of the MSC anyway, so we may as well implement download as the MSC is now and then change both at the same time, at a later date?