Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions lib/Listener/ShareCreatedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
namespace OCA\Guests\Listener;

use OCA\Guests\AppInfo\Application;
use OCA\Guests\Config;
use OCA\Guests\GuestManager;
use OCA\Guests\Service\InviteService;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Share\Events\ShareCreatedEvent;
use OCP\Share\IShare;
Expand All @@ -28,7 +28,7 @@ class ShareCreatedListener implements IEventListener {
public function __construct(
private readonly LoggerInterface $logger,
private readonly IUserSession $userSession,
private readonly IUserManager $userManager,
private readonly Config $config,
private readonly GuestManager $guestManager,
private readonly InviteService $inviteService,
) {
Expand All @@ -53,12 +53,16 @@ public function handle(Event $event): void {
return;
}

$shareWith = $share->getSharedWith();
$guestId = $share->getSharedWith();
if ($share->getShareType() === IShare::TYPE_EMAIL && $this->config->useHashedEmailAsUserID()) {
$email = strtolower($guestId);
$guestId = hash('sha256', $email);
}

$isGuest = $this->guestManager->isGuest($shareWith);
$isGuest = $this->guestManager->isGuest($guestId);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while isGuest also does this check we need the conversion anyways later for the sendInvite

if (!$isGuest) {
$this->logger->debug(
"ignoring user '" . $shareWith . "', not a guest",
"ignoring user '" . $guestId . "', not a guest",
['app' => Application::APP_ID]
);
return;
Expand All @@ -80,11 +84,11 @@ public function handle(Event $event): void {
);
}

$this->logger->debug("checking if '" . $shareWith . "' has a password",
$this->logger->debug("checking if '" . $guestId . "' has a password",
['app' => Application::APP_ID]);

$uid = $user->getUID();

$this->inviteService->sendInvite($uid, $shareWith, $share);
$this->inviteService->sendInvite($uid, $guestId, $share);
}
}
Loading