-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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(Reference): Add public API endpoints to get references #46378
Conversation
* Depends on nextcloud/server#46378 * Contributes to nextcloud/server#45978 Signed-off-by: Jonas <jonas@freesources.org>
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.
Haven't tested yet but looks good from a first read
6922479
to
224d292
Compare
$cached = $this->cache->get($cacheKey); | ||
if ($cached) { | ||
return Reference::fromCache($cached); | ||
} | ||
|
||
$reference = $matchedProvider->resolveReference($referenceId); | ||
if ($public) { | ||
$reference = $matchedProvider->resolveReferencePublic($referenceId, $sharingToken); |
Check failure
Code scanning / Psalm
UndefinedInterfaceMethod Error
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.
break; | ||
} | ||
|
||
$result[$reference] = $resolve ? $this->referenceManager->resolveReference($reference, true, $sharingToken)->jsonSerialize() : null; |
Check notice
Code scanning / Psalm
PossiblyNullReference Note
* Depends on nextcloud/server#46378 * Contributes to nextcloud/server#45978 Signed-off-by: Jonas <jonas@freesources.org>
224d292
to
f447eb1
Compare
Allow to resolve page references by share token to support lookups from public shares. This adds link previews for links to other pages in the same collective in public shares. It requires the new public reference API from nextcloud/server#46378 and the Text app being built with nextcloud-libraries/nextcloud-vue#5800. Fixes: #1275 Contributes to nextcloud/text#5520 Signed-off-by: Jonas <jonas@freesources.org>
Allow to resolve page references by share token to support lookups from public shares. This adds link previews for links to other pages in the same collective in public shares. It requires the new public reference API from nextcloud/server#46378 and the Text app being built with nextcloud-libraries/nextcloud-vue#5800. Fixes: #1275 Contributes to nextcloud/text#5520 Signed-off-by: Jonas <jonas@freesources.org>
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.
One comment that will need to be addressed I think.
$cached = $this->cache->get($cacheKey); | ||
if ($cached) { | ||
return Reference::fromCache($cached); | ||
} | ||
|
||
$reference = $matchedProvider->resolveReference($referenceId); | ||
if ($public) { | ||
$reference = $matchedProvider->resolveReferencePublic($referenceId, $sharingToken); |
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.
Calling the public API endpoints will check for matching registered reference providers that implement `IPublicReferenceProvider` and call their respective functions. If no matching provider is found, the default `LinkReferenceProvider` will be used to provide open graph data. The frontend reference widget components will call these endpoints from unauthorized sessions, e.g. in public shares. If present, the sharing token of the origin URL is passed to `resolveReferencePublic()` as additional information for the reference provider to determine the access scope. This allows the respective reference providers to determine whether the origin share has access to the linked resource. `getCacheKeyPublic` also gets the sharing token so it can scope the cached entry to it. Contributes to #45978 Signed-off-by: Jonas <jonas@freesources.org>
f447eb1
to
1671bf3
Compare
* Depends on nextcloud/server#46378 * Contributes to nextcloud/server#45978 Signed-off-by: Jonas <jonas@freesources.org>
Allow to resolve page references by share token to support lookups from public shares. This adds link previews for links to other pages in the same collective in public shares. It requires the new public reference API from nextcloud/server#46378 and the Text app being built with nextcloud-libraries/nextcloud-vue#5800. Fixes: #1275 Contributes to nextcloud/text#5520 Signed-off-by: Jonas <jonas@freesources.org>
/** | ||
* @since 30.0.0 | ||
*/ | ||
interface IPublicReferenceProvider extends IReferenceProvider { |
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.
@mejo- Please document in https://docs.nextcloud.com/server/latest/developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_30.html#id1
(also all other API additions/changes in lib/public/)
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.
Done so now in nextcloud/documentation#12037. The HTTP API additions got already documented with nextcloud/documentation#12030
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.
A bit late to the party... LGTM
@@ -26,7 +26,7 @@ | |||
/** | |||
* @since 29.0.0 | |||
*/ | |||
class LinkReferenceProvider implements IReferenceProvider { | |||
class LinkReferenceProvider implements IReferenceProvider, IPublicReferenceProvider { |
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.
IPublicReferenceProvider
extends IReferenceProvider
so LinkReferenceProvider
could just extend IPublicReferenceProvider
, right?
* Depends on nextcloud/server#46378 * Contributes to nextcloud/server#45978 Signed-off-by: Jonas <jonas@freesources.org>
* Depends on nextcloud/server#46378 * Contributes to nextcloud/server#45978 Signed-off-by: Jonas <jonas@freesources.org>
* Depends on nextcloud/server#46378 * Contributes to nextcloud/server#45978 Signed-off-by: Jonas <jonas@freesources.org>
Allow to resolve page references by share token to support lookups from public shares. This adds link previews for links to other pages in the same collective in public shares. It requires the new public reference API from nextcloud/server#46378 and the Text app being built with nextcloud-libraries/nextcloud-vue#5800. Fixes: #1275 Contributes to nextcloud/text#5520 Signed-off-by: Jonas <jonas@freesources.org>
Allow to resolve page references by share token to support lookups from public shares. This adds link previews for links to other pages in the same collective in public shares. It requires the new public reference API from nextcloud/server#46378 and the Text app being built with nextcloud-libraries/nextcloud-vue#5800. Fixes: #1275 Contributes to nextcloud/text#5520 Signed-off-by: Jonas <jonas@freesources.org>
Allow to resolve page references by share token to support lookups from public shares. This adds link previews for links to other pages in the same collective in public shares. It requires the new public reference API from nextcloud/server#46378 and the Text app being built with nextcloud-libraries/nextcloud-vue#5800. Fixes: #1275 Contributes to nextcloud/text#5520 Signed-off-by: Jonas <jonas@freesources.org>
Allow to resolve page references by share token to support lookups from public shares. This adds link previews for links to other pages in the same collective in public shares. It requires the new public reference API from nextcloud/server#46378 and the Text app being built with nextcloud-libraries/nextcloud-vue#5800. Fixes: #1275 Contributes to nextcloud/text#5520 Signed-off-by: Jonas <jonas@freesources.org>
Calling the public API endpoints will check for matching registered reference providers that implement
IPublicReferenceProvider
and call their respective functions. If no matching provider is found, the defaultLinkReferenceProvider
will be used to provide open graph data.The frontend reference widget components will call these endpoints from unauthorized sessions, e.g. in public shares.
If present, the sharing token of the origin URL is passed to
resolveReferencePublic()
as additional information for the reference provider to determine the access scope. This allows the respective reference providers to determine whether the origin share has access to the linked resource.getCacheKeyPublic
also gets the sharing token so it can scope the cached entry to it.Contributes to #45978
Checklist