Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
'OCA\\Files_Sharing\\ISharedStorage' => $baseDir . '/../lib/ISharedStorage.php',
'OCA\\Files_Sharing\\Listener\\BeforeDirectFileDownloadListener' => $baseDir . '/../lib/Listener/BeforeDirectFileDownloadListener.php',
'OCA\\Files_Sharing\\Listener\\BeforeZipCreatedListener' => $baseDir . '/../lib/Listener/BeforeZipCreatedListener.php',
'OCA\\Files_Sharing\\Listener\\GroupDeletedListener' => $baseDir . '/../lib/Listener/GroupDeletedListener.php',
'OCA\\Files_Sharing\\Listener\\LoadAdditionalListener' => $baseDir . '/../lib/Listener/LoadAdditionalListener.php',
'OCA\\Files_Sharing\\Listener\\LoadPublicFileRequestAuthListener' => $baseDir . '/../lib/Listener/LoadPublicFileRequestAuthListener.php',
'OCA\\Files_Sharing\\Listener\\LoadSidebarListener' => $baseDir . '/../lib/Listener/LoadSidebarListener.php',
Expand Down
1 change: 1 addition & 0 deletions apps/files_sharing/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class ComposerStaticInitFiles_Sharing
'OCA\\Files_Sharing\\ISharedStorage' => __DIR__ . '/..' . '/../lib/ISharedStorage.php',
'OCA\\Files_Sharing\\Listener\\BeforeDirectFileDownloadListener' => __DIR__ . '/..' . '/../lib/Listener/BeforeDirectFileDownloadListener.php',
'OCA\\Files_Sharing\\Listener\\BeforeZipCreatedListener' => __DIR__ . '/..' . '/../lib/Listener/BeforeZipCreatedListener.php',
'OCA\\Files_Sharing\\Listener\\GroupDeletedListener' => __DIR__ . '/..' . '/../lib/Listener/GroupDeletedListener.php',
'OCA\\Files_Sharing\\Listener\\LoadAdditionalListener' => __DIR__ . '/..' . '/../lib/Listener/LoadAdditionalListener.php',
'OCA\\Files_Sharing\\Listener\\LoadPublicFileRequestAuthListener' => __DIR__ . '/..' . '/../lib/Listener/LoadPublicFileRequestAuthListener.php',
'OCA\\Files_Sharing\\Listener\\LoadSidebarListener' => __DIR__ . '/..' . '/../lib/Listener/LoadSidebarListener.php',
Expand Down
2 changes: 2 additions & 0 deletions apps/files_sharing/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use OCA\Files_Sharing\Helper;
use OCA\Files_Sharing\Listener\BeforeDirectFileDownloadListener;
use OCA\Files_Sharing\Listener\BeforeZipCreatedListener;
use OCA\Files_Sharing\Listener\GroupDeletedListener;
use OCA\Files_Sharing\Listener\LoadAdditionalListener;
use OCA\Files_Sharing\Listener\LoadPublicFileRequestAuthListener;
use OCA\Files_Sharing\Listener\LoadSidebarListener;
Expand Down Expand Up @@ -86,6 +87,7 @@ function () use ($c) {
$context->registerEventListener(UserDeletedEvent::class, DisplayNameCache::class);
$context->registerEventListener(GroupChangedEvent::class, GroupDisplayNameCache::class);
$context->registerEventListener(GroupDeletedEvent::class, GroupDisplayNameCache::class);
$context->registerEventListener(GroupDeletedEvent::class, GroupDeletedListener::class);

// Sidebar and files scripts
$context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class);
Expand Down
31 changes: 31 additions & 0 deletions apps/files_sharing/lib/Listener/GroupDeletedListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Files_Sharing\Listener;

use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Group\Events\GroupDeletedEvent;
use OCP\Share\IManager as IShareManager;

/** @template-implements IEventListener<GroupDeletedEvent> */
class GroupDeletedListener implements IEventListener {
public function __construct(
private IShareManager $shareManager,
) {
}

public function handle(Event $event): void {
if (!($event instanceof GroupDeletedEvent)) {
return;
}
$group = $event->getGroup();
$this->shareManager->groupDeleted($group->getGID());
}
}
4 changes: 3 additions & 1 deletion apps/files_sharing/src/views/SharingList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
-->

<template>
<ul class="sharing-sharee-list" :aria-label="t('files_sharing', 'Shares')">
<ul class="sharing-sharee-list"
:aria-label="t('files_sharing', 'Shares')"
data-cy-files-sharing-internal-list>
<SharingEntry v-for="share in shares"
:key="share.id"
:file-info="fileInfo"
Expand Down
65 changes: 65 additions & 0 deletions cypress/e2e/files_sharing/group-deleted.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*!
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import type { User } from '@nextcloud/cypress'

import { createShare, openSharingPanel } from './FilesSharingUtils.ts'

describe('files_sharing: Group deleted', { testIsolation: true }, () => {
let user: User
let file: string
let group1: string
let group2: string

before(() => {
cy.createRandomUser().then((randomUser) => {
user = randomUser

file = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) + '.txt'
cy.uploadContent(user, new Blob(['share to user'], { type: 'text/plain' }), 'text/plain', `/${file}`)

group1 = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10)
group2 = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10)
cy.runOccCommand(`group:add ${group1}`)
cy.runOccCommand(`group:add ${group2}`)

cy.login(user)
cy.visit('/apps/files')
createShare(file, group1)
createShare(file, group2)
})
})

it('deleted groups are removed from shares', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

For PHP code its more common to add integration tests (behat) that Cypress.

cy.login(user)
cy.visit('/apps/files')

openSharingPanel(file)
cy.get('[data-cy-files-sharing-internal-list]').within(() => {
// see that file is shared with group1
cy.contains('li', `${group1} (group)`)
.should('exist')
// see that file is also shared with group2
cy.contains('li', `${group2} (group)`)
.should('exist')
})

// delete group1
cy.runOccCommand(`group:delete ${group1}`)

// reload the page
cy.reload()

openSharingPanel(file)
cy.get('[data-cy-files-sharing-internal-list]').within(() => {
// see that file is no longer shared with the deleted group1
cy.contains('li', `${group1} (group)`)
.should('not.exist')
// see that file is still shared with group2
cy.contains('li', `${group2} (group)`)
.should('exist')
})
})
})
4 changes: 2 additions & 2 deletions dist/9452-9452.js → dist/2212-2212.js

Large diffs are not rendered by default.

File renamed without changes.
1 change: 1 addition & 0 deletions dist/2212-2212.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/2212-2212.js.map.license
1 change: 0 additions & 1 deletion dist/9452-9452.js.map

This file was deleted.

1 change: 0 additions & 1 deletion dist/9452-9452.js.map.license

This file was deleted.

4 changes: 2 additions & 2 deletions dist/files_sharing-files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-files_sharing_tab.js.map

Large diffs are not rendered by default.

Loading