Skip to content

apply remove share for users/teams/groups#2728

Open
samin-z wants to merge 2 commits into
mainfrom
fix/1836-remove-recievers-share-after-delete
Open

apply remove share for users/teams/groups#2728
samin-z wants to merge 2 commits into
mainfrom
fix/1836-remove-recievers-share-after-delete

Conversation

@samin-z

@samin-z samin-z commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

IF user/team/groups is removed, all the connections with tables share is also removed.

Signed-off-by: samin-z <samin.zavarkesh@gmail.com>
@samin-z samin-z requested review from blizzz and enjeck as code owners June 16, 2026 15:19

@enjeck enjeck left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not sure if ready for review yet, but I have some preliminary comments

class ReceiverCleanupListener implements IEventListener {
public function __construct(
private ShareMapper $shareMapper,
private CirclesManager $circlesManager,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CirclesManager is a hard constructor dependency, but Circles is an optional app. When Circles is not available, this might crash?. Should use CircleHelper.php instead

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.

ok i see your point, circles is optional in tables and hard injecting CirclesManager does not match our existing CircleHelper pattern. i'll update it.


public function handle(Event $event): void {
if ($event instanceof UserDeletedEvent) {
$this->cleanupByParticipant('user', $event->getUser()->getUID());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

instead of hardcoding user, group, circle, use the constants e.g ShareReceiverType::USER

return;
}

$this->cleanupByParticipant('group', $singleId);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should this be 'circle' instead?

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.

if a group is added to table, in tables_shares table for receiver_type we have 'group'

}

private function cleanupByParticipant(string $type, string $participant): void {
$this->shareMapper->deleteByReceiver($participant, $type);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could throw an Exception, and nothing here catches it

Signed-off-by: samin-z <samin.zavarkesh@gmail.com>
@samin-z

samin-z commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

@enjeck i decided to simplify the logic and do a follow-up ticket on the case for checking groups before adding and also removing them if exist.

@samin-z samin-z requested a review from enjeck June 17, 2026 10:11
$context->registerEventListener(TableOwnershipTransferredEvent::class, WhenTableTransferredAuditLogListener::class);
$context->registerEventListener(AddMissingIndicesEvent::class, AddMissingIndicesListener::class);
$context->registerEventListener(UserDeletedEvent::class, ReceiverCleanupListener::class);
$context->registerEventListener(BeforeGroupDeletedEvent::class, ReceiverCleanupListener::class);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Group deletion may still be aborted at this stage. Like with the other events, GroupDeletedEvent should be used here instead, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants