Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/integration-pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
- 'sharing-3'
- 'sharing-4'
php-versions: ['8.3']
server-versions: ['master']
server-versions: ['share-mount-validation-on-share']
guests-versions: ['main']
circles-versions: ['master']
notifications-versions: ['master']
Expand Down
18 changes: 18 additions & 0 deletions lib/Service/ParticipantService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

namespace OCA\Talk\Service;

use OC\User\LazyUser;
use OCA\Circles\CirclesManager;
use OCA\Circles\Model\Circle;
use OCA\Circles\Model\Member;
use OCA\Files_Sharing\Event\UserShareAccessUpdatedEvent;
use OCA\Talk\CachePrefix;
use OCA\Talk\Chat\ChatManager;
use OCA\Talk\Config;
Expand Down Expand Up @@ -629,6 +631,11 @@
}

$readPrivacy = $this->talkConfig->getUserReadPrivacy($participant['actorId']);

// Clear share access cache
$user = new LazyUser($participant['actorId'], $this->userManager);

Check failure on line 636 in lib/Service/ParticipantService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedClass

lib/Service/ParticipantService.php:636:17: UndefinedClass: Class, interface or enum named OC\User\LazyUser does not exist (see https://psalm.dev/019)
$event = new UserShareAccessUpdatedEvent($user);

Check failure on line 637 in lib/Service/ParticipantService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedClass

lib/Service/ParticipantService.php:637:18: UndefinedClass: Class, interface or enum named OCA\Files_Sharing\Event\UserShareAccessUpdatedEvent does not exist (see https://psalm.dev/019)
$this->dispatcher->dispatchTyped($event);

Check failure on line 638 in lib/Service/ParticipantService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

InvalidArgument

lib/Service/ParticipantService.php:638:38: InvalidArgument: Argument 1 of OCP\EventDispatcher\IEventDispatcher::dispatchTyped expects OCP\EventDispatcher\Event, but OCA\Files_Sharing\Event\UserShareAccessUpdatedEvent provided (see https://psalm.dev/004)
} elseif ($participant['actorType'] === Attendee::ACTOR_FEDERATED_USERS) {
if ($addedBy === null) {
throw new \Exception('$addedBy must be set to add a federated user');
Expand Down Expand Up @@ -1103,6 +1110,13 @@
$this->sessionMapper->deleteByAttendeeId($participant->getAttendee()->getId());
$this->attendeeMapper->delete($participant->getAttendee());

if ($participant->getAttendee()->getActorType() === Attendee::ACTOR_USERS) {
// Clear share access cache
$user = new LazyUser($participant->getAttendee()->getActorId(), $this->userManager);

Check failure on line 1115 in lib/Service/ParticipantService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedClass

lib/Service/ParticipantService.php:1115:16: UndefinedClass: Class, interface or enum named OC\User\LazyUser does not exist (see https://psalm.dev/019)
$event = new UserShareAccessUpdatedEvent($user);

Check failure on line 1116 in lib/Service/ParticipantService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedClass

lib/Service/ParticipantService.php:1116:17: UndefinedClass: Class, interface or enum named OCA\Files_Sharing\Event\UserShareAccessUpdatedEvent does not exist (see https://psalm.dev/019)
$this->dispatcher->dispatchTyped($event);
}

$event = new AttendeeRemovedEvent($room, $participant->getAttendee(), $reason, $sessions);
$this->dispatcher->dispatchTyped($event);

Expand Down Expand Up @@ -1251,6 +1265,10 @@

$this->attendeeMapper->delete($attendee);

// Clear share access cache
$event = new UserShareAccessUpdatedEvent($user);

Check failure on line 1269 in lib/Service/ParticipantService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedClass

lib/Service/ParticipantService.php:1269:16: UndefinedClass: Class, interface or enum named OCA\Files_Sharing\Event\UserShareAccessUpdatedEvent does not exist (see https://psalm.dev/019)
$this->dispatcher->dispatchTyped($event);

$attendeeEvent = new AttendeeRemovedEvent($room, $attendee, $reason, $sessions);
$this->dispatcher->dispatchTyped($attendeeEvent);

Expand Down
12 changes: 12 additions & 0 deletions lib/Service/RoomService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
namespace OCA\Talk\Service;

use InvalidArgumentException;
use OC\User\LazyUser;
use OCA\Files_Sharing\Event\UserShareAccessUpdatedEvent;
use OCA\Talk\Config;
use OCA\Talk\Events\AParticipantModifiedEvent;
use OCA\Talk\Events\ARoomModifiedEvent;
Expand Down Expand Up @@ -63,6 +65,7 @@
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Log\Audit\CriticalActionPerformedEvent;
use OCP\Security\Events\ValidatePasswordPolicyEvent;
use OCP\Security\IHasher;
Expand All @@ -89,6 +92,7 @@
protected LoggerInterface $logger,
protected IL10N $l10n,
protected IManager $calendarManager,
protected IUserManager $userManager,
) {
}

Expand Down Expand Up @@ -1440,6 +1444,14 @@
$delete->executeStatement();
}

// Clear share access cache
$userIds = $this->participantService->getParticipantUserIds($room);
foreach ($userIds as $userId) {
$user = new LazyUser($userId, $this->userManager);

Check failure on line 1450 in lib/Service/RoomService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedClass

lib/Service/RoomService.php:1450:16: UndefinedClass: Class, interface or enum named OC\User\LazyUser does not exist (see https://psalm.dev/019)
$event = new UserShareAccessUpdatedEvent($user);

Check failure on line 1451 in lib/Service/RoomService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedClass

lib/Service/RoomService.php:1451:17: UndefinedClass: Class, interface or enum named OCA\Files_Sharing\Event\UserShareAccessUpdatedEvent does not exist (see https://psalm.dev/019)
$this->dispatcher->dispatchTyped($event);

Check failure on line 1452 in lib/Service/RoomService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

InvalidArgument

lib/Service/RoomService.php:1452:37: InvalidArgument: Argument 1 of OCP\EventDispatcher\IEventDispatcher::dispatchTyped expects OCP\EventDispatcher\Event, but OCA\Files_Sharing\Event\UserShareAccessUpdatedEvent provided (see https://psalm.dev/004)
}

// Delete attendees
$delete = $this->db->getQueryBuilder();
$delete->delete('talk_attendees')
Expand Down
33 changes: 32 additions & 1 deletion lib/Share/RoomShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace OCA\Talk\Share;

use OC\Files\Cache\Cache;
use OC\User\LazyUser;
use OCA\Talk\Events\BeforeDuplicateShareSentEvent;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Exceptions\RoomNotFoundException;
Expand All @@ -27,13 +28,16 @@
use OCP\Files\Node;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Security\ISecureRandom;
use OCP\Share\Exceptions\GenericShareException;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager as IShareManager;
use OCP\Share\IPartialShareProvider;
use OCP\Share\IShare;
use OCP\Share\IShareProvider;
use OCP\Share\IShareProviderGetUsers;

/**
* Share provider for room shares.
Expand All @@ -45,7 +49,7 @@
* Like in group shares, a recipient can move or delete a share without
* modifying the share for the other users in the room.
*/
class RoomShareProvider implements IShareProvider, IPartialShareProvider {
class RoomShareProvider implements IShareProvider, IPartialShareProvider, IShareProviderGetUsers {
use TTransactional;
// Special share type for user modified room shares
public const SHARE_TYPE_USERROOM = 11;
Expand All @@ -66,6 +70,7 @@
protected ITimeFactory $timeFactory,
private IL10N $l,
private IMimeTypeLoader $mimeTypeLoader,
private IUserManager $userManager,
) {
$this->sharesByIdCache = new CappedMemoryCache();
}
Expand Down Expand Up @@ -1230,4 +1235,30 @@
}
$cursor->closeCursor();
}

public function getUsersForShare(IShare $share): iterable {

Check failure on line 1239 in lib/Share/RoomShareProvider.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

MissingOverrideAttribute

lib/Share/RoomShareProvider.php:1239:2: MissingOverrideAttribute: Method OCA\Talk\Share\RoomShareProvider::getusersforshare should have the "Override" attribute (see https://psalm.dev/358)
if ($share->getShareType() === self::SHARE_TYPE_USERROOM) {
// User record for a share, user is the shared_with
return [new LazyUser($share->getSharedWith(), $this->userManager)];
}

if ($share->getShareType() !== IShare::TYPE_ROOM) {
return [];
}

// Room share entry, shared_with is the conversation token
try {
$room = $this->manager->getRoomByToken($share->getSharedWith());
} catch (RoomNotFoundException) {
return [];
}

if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
return array_map(fn (string $userId): IUser => new LazyUser($userId, $this->userManager), json_decode($room->getName(), true));
}

// Get all user ids for the room
$userIds = $this->participantService->getParticipantUserIds($room);
return array_map(fn (string $userId): IUser => new LazyUser($userId, $this->userManager), $userIds);
}
}
5 changes: 5 additions & 0 deletions tests/php/Service/RoomServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Security\IHasher;
use OCP\Server;
use OCP\Share\IManager as IShareManager;
Expand All @@ -52,6 +53,7 @@ class RoomServiceTest extends TestCase {
protected LoggerInterface&MockObject $logger;
protected IL10N&MockObject $l10n;
protected IManager $calendarManager;
protected IUserManager&MockObject $userManager;
protected EmojiService $emojiService;
protected ?RoomService $service = null;

Expand All @@ -70,6 +72,7 @@ public function setUp(): void {
$this->l10n = $this->createMock(IL10N::class);
$this->emojiService = Server::get(EmojiService::class);
$this->calendarManager = $this->createMock(IManager::class);
$this->userManager = $this->createMock(IUserManager::class);
$this->service = new RoomService(
$this->manager,
$this->participantService,
Expand All @@ -84,6 +87,7 @@ public function setUp(): void {
$this->logger,
$this->l10n,
$this->calendarManager,
$this->userManager,
);
}

Expand Down Expand Up @@ -340,6 +344,7 @@ public function testVerifyPassword(): void {
$this->logger,
$this->l10n,
$this->calendarManager,
$this->userManager,
);

$room = new Room(
Expand Down
Loading