Skip to content
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

doc: how to open a shared file #1241

Merged
merged 1 commit into from
Feb 25, 2023
Merged

doc: how to open a shared file #1241

merged 1 commit into from
Feb 25, 2023

Conversation

max-nextcloud
Copy link
Contributor

Document how to provide sharingToken in an app so shared files can be opened.

Signed-off-by: Max max@nextcloud.com

@skjnldsv
Copy link
Member

skjnldsv commented May 3, 2022

Hey @max-nextcloud , can you give me context on why you need to document that?

@skjnldsv skjnldsv added enhancement New feature or request 2. developing Work in progress labels May 3, 2022
@max-nextcloud
Copy link
Contributor Author

Hey @max-nextcloud , can you give me context on why you need to document that?

I ran into this twice recently. Once when opening linked files in the collectives app. Collectives can now be shared via links. Under the hood this results in sharing the collective folder. So we have a share token that we provide for Viewer.open to work and also because loading images in text relies on it.

The other occasion was when working on #995 with @vanpertsch. We ran into PROPFIND 404s when trying to open shared files. This time it turned out the sharingToken was already provided in the files_sharing app - so that was not the cause. However it made me realize that I knew we needed a sharingToken just because I recently introduced it to collectives. So it seems like something useful to document because it's hard to figure out otherwise.

I'm happy to document this elsewhere - maybe it already is and i just did not read those docs yet. What do you think would be the best place to document this?

@skjnldsv
Copy link
Member

skjnldsv commented May 5, 2022

I'm happy to document this elsewhere - maybe it already is and i just did not read those docs yet. What do you think would be the best place to document this?

I think this is more a bad API design than a need for documentation then :)
What differs in terms of template between a file share and a collective share?
Could you point me to the code? Maybe we could actually properly get the share token, but from the viewer api instead of expecting to find it on the page.

Second thing, is actually this: nextcloud/server#19700
If we would use the same type of endpoint for private and public view, we would not need the share token I think.

@max-nextcloud
Copy link
Contributor Author

What differs in terms of template between a file share and a collective share?

A collective share renders an empty div in the template and then loads the collectives vue app in there. So in terms of rendering it's a completely different approach from what the files_sharing app does for now.

The functionality in collectives that relies on the viewer API is opening a linked file such as a pdf on top of the collective.

Could you point me to the code? Maybe we could actually properly get the share token, but from the viewer api instead of expecting to find it on the page.
I'm not entirely sure which code you are referring to.

Viewer.open is currently called when a user clicks on a relative link to a file that is not a markdown file: https://gitlab.com/collectivecloud/collectives/-/blob/main/src/components/Page/RichText.vue#L164-172

Collectives provides the token as part of rendering the markdown view: https://gitlab.com/collectivecloud/collectives/-/blob/main/src/components/Page/RichText.vue#L3
OCA.Viewer will then pick it up here:

const getToken = function() {
return document.getElementById('sharingToken') && document.getElementById('sharingToken').value
}

@skjnldsv

This comment was marked as resolved.

Document how to provide `sharingToken` in an app so shared files can be opened.

Signed-off-by: Max <max@nextcloud.com>
@skjnldsv skjnldsv merged commit 1c94640 into master Feb 25, 2023
@skjnldsv skjnldsv deleted the doc/open-shared-file branch February 25, 2023 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants