fix: Open PDF file in "richdocuments" if it is not downloadable #1203
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.

The PDF viewer must be able to download the file to show it, and if the file is not downloadable an error message was just shown. However, Nextcloud Office ("richdocuments") is able to show PDF files even if they can not be downloaded, so now the viewer is reopened forcing "richdocuments" to handle opening the file when it is not downloadable.
Although this will make possible to show public shares with "Hide download" enabled in Nextcloud 31.0.0 to 31.0.4 (as it behaved as "Prevent download" until the previous behaviour was restored) note that this fix applies mainly to internal shares, so it needs to be backported up to Nextcloud 30.
The fix is a bit hacky, as it opens again the file while it was being already being opened, but unfortunately I did not find any better approach with the current Viewer API. Hopefully with conditional handlers in the Viewer 4.0 API it will be possible to directly open Nextcloud Office if the file does not have download permissions :-)
How to test
Result with this pull request
Nextcloud Office shows the PDF file
Result without this pull request
The PDF viewer shows To view a shared PDF file, the download needs to be allowed for this file share