Skip to content

Commit

Permalink
Merge pull request #17575 from nextcloud/include-the-share-in-the-fil…
Browse files Browse the repository at this point in the history
…es_sharing-loadadditionalscripts-event

Include the share in the Files_Sharing::loadAdditionalScripts event
  • Loading branch information
rullzer authored Oct 19, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents dd0e738 + 5c7c308 commit b425b34
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion apps/files_sharing/lib/Controller/ShareController.php
Original file line number Diff line number Diff line change
@@ -445,7 +445,8 @@ public function showShare($path = ''): TemplateResponse {
\OCP\Util::addHeader('meta', ['property' => "og:type", 'content' => "object"]);
\OCP\Util::addHeader('meta', ['property' => "og:image", 'content' => $ogPreview]);

$this->eventDispatcher->dispatch('OCA\Files_Sharing::loadAdditionalScripts');
$event = new GenericEvent(null, ['share' => $share]);
$this->eventDispatcher->dispatch('OCA\Files_Sharing::loadAdditionalScripts', $event);

$csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
$csp->addAllowedFrameDomain('\'self\'');
14 changes: 12 additions & 2 deletions apps/files_sharing/tests/Controller/ShareControllerTest.php
Original file line number Diff line number Diff line change
@@ -254,7 +254,12 @@ public function testShowShare() {

$this->eventDispatcher->expects($this->once())
->method('dispatch')
->with('OCA\Files_Sharing::loadAdditionalScripts');
->with(
'OCA\Files_Sharing::loadAdditionalScripts',
$this->callback(function($event) use ($share) {
return $event->getArgument('share') === $share;
})
);

$this->l10n->expects($this->any())
->method('t')
@@ -374,7 +379,12 @@ public function testShowShareHideDownload() {

$this->eventDispatcher->expects($this->once())
->method('dispatch')
->with('OCA\Files_Sharing::loadAdditionalScripts');
->with(
'OCA\Files_Sharing::loadAdditionalScripts',
$this->callback(function($event) use ($share) {
return $event->getArgument('share') === $share;
})
);

$this->l10n->expects($this->any())
->method('t')

0 comments on commit b425b34

Please sign in to comment.