-
Notifications
You must be signed in to change notification settings - Fork 497
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
Feat/download via share link #3666
base: master
Are you sure you want to change the base?
Conversation
@advplyr I think this should be ready to go, but let me know if you have any thoughts or think anything should be changed. I added to the download method in the LibraryItemController to handle share items, but there might be a better way to handle it that I didn't think of. Also, I'm not sure if the migration script name needs to be changed since the server version was updated after I started this PR. |
@@ -157,33 +157,49 @@ class LibraryItemController { | |||
* @param {Response} res | |||
*/ | |||
async download(req, res) { |
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.
Using this endpoint isn't going to work because all of the endpoints in /api/
are authenticated. The reason it would have worked in your testing is because you're still authenticated via the session. You can test it by using the share link in incognito.
The download functionality should be in the ShareController
which gets served from the unauthenticated PublicRouter
. Most of those functions are authenticating using the share_session_id cookie.
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.
Ah, got it. I didn't test in an incognito and didn't realize all endpoints in /api/
were authenticated, but that makes sense! I'll move the download functionality to the ShareController.
* @param {MigrationOptions} options - an object containing the migration context. | ||
* @returns {Promise<void>} - A promise that resolves when the migration is complete. | ||
*/ | ||
module.exports = { |
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.
Migrations should keep the same format of using individual functions up
and down
for consistency. The JSDoc types also aren't going to work when they are above the export like that.
If you're not using an editor that can use JSDocs I highly recommend it.
The other migrations have a log for BEGIN/END on up and down which we should keep consistent
*/ | ||
module.exports = { | ||
up: async ({ context: { queryInterface, logger } }) => { | ||
await queryInterface.addColumn('mediaItemShares', 'isDownloadable', { |
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.
Since the mediaItemShares
table was added later someone may be upgrading from a version that doesn't have the table yet which will cause this to crash. See v2.17.3-fk-constraints
migration on wrapping this in a tableExists
check.
Also, we want these migrations to be idempotent. If this migration were to run and the isDownloadable
column already exists, the migration should still run.
Yeah if you can merge master and update the name of the migration file to v2.17.5 |
There is also a changelog.md in the migrations folder that should have a short description of each migration |
@advplyr I think all the updates should be complete now, but let me know if I missed something or need to change anything. |
This feature adds an option when sharing a media item to allow users to download the zip file.
This resolves #3606
This is still a work in progress, but I've added the toggle to the share modal, updated the MediaItemShare model to include a field for whether or not the item is downloadable, added the migration file for the updated column, and updated the ShareController.