feat(files_sharing): configure public share link base URL#62146
Conversation
838a43c to
9df6210
Compare
Documentation for nextcloud/server#62146 Signed-off-by: Ali Aslam <ali.aslam@zohomail.com> Signed-off-by: Ali Aslam <ali.aslam@zohomail.com>
|
Documentation added in nextcloud/documentation#15361 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9df62106ca
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| private LoggerInterface $logger, | ||
| private IMailer $mailer, | ||
| private IURLGenerator $urlGenerator, | ||
| private PublicShareUrlGenerator $publicShareUrlGenerator, |
There was a problem hiding this comment.
Avoid requiring files_sharing from sharebymail
When sharebymail is enabled without files_sharing (its appinfo/info.xml does not declare a files_sharing dependency), autowiring this provider now has to resolve OCA\Files_Sharing\PublicShareUrlGenerator from an app whose autoloader is not registered for that request. That can make ProviderFactory::getShareByMailProvider() fail while enumerating or resolving mail-share providers, before the app can handle the missing sharing UI/routes gracefully; either keep the URL helper in a dependency that sharebymail owns/core owns, or declare/load the files_sharing dependency explicitly.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Added a try/catch to cover that edge case, pls review again
Assisted-by: Codex:GPT-5 Signed-off-by: Ali Aslam <ali.aslam@zohomail.com>
Assisted-by: Codex:GPT-5 Signed-off-by: Ali Aslam <ali.aslam@zohomail.com>
Assisted-by: Codex:GPT-5 Signed-off-by: Ali Aslam <ali.aslam@zohomail.com>
Assisted-by: Codex:GPT-5 Signed-off-by: Ali Aslam <ali.aslam@zohomail.com>
Build the share link path through the router instead of hardcoding
'/s/{token}' so instances without pretty URLs keep their '/index.php'
front controller prefix when a custom base URL is configured. The
instance webroot is still replaced by the configured base URL.
Also trim surrounding whitespace from the configured value and log a
warning (once per process) when a non-empty value is rejected, instead
of falling back silently.
Assisted-by: ClaudeCode:kimi-k3[1m]
Signed-off-by: Ali Aslam <ali.aslam@zohomail.com>
The share notification and note emails still built the share link with the instance URL generator, so recipients received links pointing at the internal host even when shareapi_public_link_base_url was set. Generate them through PublicShareUrlGenerator like the other public share links. Assisted-by: ClaudeCode:kimi-k3[1m] Signed-off-by: Ali Aslam <ali.aslam@zohomail.com>
Assisted-by: ClaudeCode:kimi-k3[1m] Signed-off-by: Ali Aslam <ali.aslam@zohomail.com>
Wrap Server::get(ShareByMailProvider::class) in a try/catch so that if the provider's dependencies cannot be resolved (e.g. PublicShareUrlGenerator from files_sharing is not autoloaded when the app is disabled), the provider factory falls back to null instead of throwing, matching the pattern already used for registered share providers. Assisted-by: ClaudeCode:kimi-k3[1m] Signed-off-by: Ali Aslam <ali.aslam@zohomail.com>
9df6210 to
eded848
Compare
Summary
Adds an optional 'shareapi_public_link_base_url' config flag to set a custom base URL just for share links. When unset, Nextcloud behaves exactly the same.
The new "PublicShareUrlGenerator" reads the config value and validates that it's a valid HTTP(S) URL. If it's unset or if the URL is invalid, we fall back to Nextcloud's existing URL generator. Existing references to the current URL generator are replaced with this new one for the OCS Share API URL field, public shares, and public link reminder emails.
At the same time, all URLs unrelated to sharing remain unchanged and still use the standard UrlGenerator.
The web UI is also updated to use the OCS response's URL field, instead of reconstructing the share link from the current base URL. Again, if the flag is unset, we fall back to the existing local construction.
TYPE_EMAIL shares now expose a URL field in the OCS response. Also, ShareByMailProvider now takes PublicShareUrlGenerator, both email paths use it (sendEmail() and sendNote()).
This is my first contribution to this project, so I'd appreciate any feedback or guidance on how to approach the documentation and other details.
Assisted-by: Codex:GPT-5.6
Before:
After:
Updated Documentation PR
TODO
Manual live testing
Screenshots
Update documentation (
occ config:app:set core shareapi_public_link_base_url --value='https://example.com/')Checklist
3. to review, feature component)stable32)AI (if applicable)