-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Hoang Pham <hoangmaths96@gmail.com>
- Loading branch information
Showing
15 changed files
with
433 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
|
||
namespace OCA\Whiteboard\Listener; | ||
|
||
use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent; | ||
use OCP\AppFramework\Services\IInitialState; | ||
use OCP\EventDispatcher\Event; | ||
use OCP\EventDispatcher\IEventListener; | ||
|
||
/** @template-implements IEventListener<BeforeTemplateRenderedEvent|Event> */ | ||
class BeforeTemplateRenderedListener implements IEventListener { | ||
Check failure on line 19 in lib/Listener/BeforeTemplateRenderedListener.php GitHub Actions / static-psalm-analysisUndefinedDocblockClass
Check failure on line 19 in lib/Listener/BeforeTemplateRenderedListener.php GitHub Actions / static-psalm-analysisInvalidTemplateParam
|
||
public function __construct( | ||
private IInitialState $initialState, | ||
) { | ||
} | ||
|
||
public function handle(Event $event): void { | ||
Check failure on line 25 in lib/Listener/BeforeTemplateRenderedListener.php GitHub Actions / static-psalm-analysisMoreSpecificImplementedParamType
|
||
if (!($event instanceof BeforeTemplateRenderedEvent)) { | ||
Check failure on line 26 in lib/Listener/BeforeTemplateRenderedListener.php GitHub Actions / static-psalm-analysisUndefinedClass
|
||
return; | ||
} | ||
|
||
$this->initialState->provideInitialState( | ||
'file_id', | ||
$event->getShare()->getNodeId() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\Whiteboard\Model; | ||
|
||
use OCP\IUser; | ||
|
||
class AuthenticatedUser implements User { | ||
public function __construct(private IUser $user) { | ||
} | ||
|
||
public function getUID(): string { | ||
return $this->user->getUID(); | ||
} | ||
|
||
public function getDisplayName(): string { | ||
return $this->user->getDisplayName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\Whiteboard\Model; | ||
|
||
class PublicSharingUser implements User { | ||
public function __construct( | ||
private string $publicSharingToken | ||
) { | ||
} | ||
|
||
public function getUID(): string { | ||
return $this->generateRandomUID(); | ||
} | ||
|
||
public function getDisplayName(): string { | ||
return $this->generateRandomDisplayName(); | ||
} | ||
|
||
public function getPublicSharingToken(): string { | ||
return $this->publicSharingToken; | ||
} | ||
|
||
private function generateRandomUID(): string { | ||
return 'shared_' . $this->publicSharingToken . '_' . bin2hex(random_bytes(8)); | ||
} | ||
|
||
private function generateRandomDisplayName(): string { | ||
$adjectives = ['Anonymous', 'Mysterious', 'Incognito', 'Unknown', 'Unnamed']; | ||
$nouns = ['User', 'Visitor', 'Guest', 'Collaborator', 'Participant']; | ||
|
||
$adjective = $adjectives[array_rand($adjectives)]; | ||
$noun = $nouns[array_rand($nouns)]; | ||
|
||
return $adjective . ' ' . $noun; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\Whiteboard\Model; | ||
|
||
interface User | ||
{ | ||
public function getUID(): string; | ||
public function getDisplayName(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.