Skip to content

Commit

Permalink
remove the 'shareapi_allow_mail_notification' setting
Browse files Browse the repository at this point in the history
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
  • Loading branch information
schiessle committed Nov 2, 2016
1 parent a87fbc9 commit 11ad9d4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
6 changes: 5 additions & 1 deletion apps/files_sharing/appinfo/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@

// Migration OC8.2 -> OC9
if (version_compare($installedVersion, '0.9.1', '<')) {
$m = new Migration(\OC::$server->getDatabaseConnection());
$m = new Migration(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig());
$m->removeReShares();
$m->updateInitiatorInfo();
}

if (version_compare($installedVersion, '1.1.1', '<')) {
$m = new Migration(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig());
}
15 changes: 14 additions & 1 deletion apps/files_sharing/lib/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

use Doctrine\DBAL\Connection;
use OCP\ICache;
use OCP\IConfig;
use OCP\IDBConnection;
use OC\Cache\CappedMemoryCache;

Expand All @@ -41,14 +42,18 @@ class Migration {
/** @var IDBConnection */
private $connection;

/** @var IConfig */
private $config;

/** @var ICache with all shares we already saw */
private $shareCache;

/** @var string */
private $table = 'share';

public function __construct(IDBConnection $connection) {
public function __construct(IDBConnection $connection, IConfig $config) {
$this->connection = $connection;
$this->config = $config;

// We cache up to 10k share items (~20MB)
$this->shareCache = new CappedMemoryCache(10000);
Expand Down Expand Up @@ -110,6 +115,14 @@ public function updateInitiatorInfo() {
}
}

/**
* this was dropped for Nextcloud 11 in favour of share by mail
*/
public function removeSendMailOption() {
$this->config->deleteAppValue('core', 'shareapi_allow_mail_notification');
$this->config->deleteAppValue('core', 'shareapi_allow_public_notification');
}

/**
* find the owner of a re-shared file/folder
*
Expand Down
28 changes: 27 additions & 1 deletion apps/files_sharing/tests/MigrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class MigrationTest extends TestCase {
/** @var \OCP\IDBConnection */
private $connection;

/** @var \OCP\IConfig */
private $config;

/** @var Migration */
private $migration;

Expand All @@ -48,7 +51,8 @@ public function setUp() {
parent::setUp();

$this->connection = \OC::$server->getDatabaseConnection();
$this->migration = new Migration($this->connection);
$this->config = \OC::$server->getConfig();
$this->migration = new Migration($this->connection, $this->config);

$this->cleanDB();
}
Expand Down Expand Up @@ -351,4 +355,26 @@ public function test1001DeepReshares() {
$stmt->closeCursor();
$this->assertEquals(1001, $i);
}

/**
* test that we really remove the "shareapi_allow_mail_notification" setting only
*/
public function testRemoveSendMailOption() {
$this->config->setAppValue('core', 'shareapi_setting1', 'dummy-value');
$this->config->setAppValue('core', 'shareapi_allow_mail_notification', 'no');
$this->config->setAppValue('core', 'shareapi_allow_public_notification', 'no');

$this->migration->removeSendMailOption();

$this->assertNull(
$this->config->getAppValue('core', 'shareapi_allow_mail_notification', null)
);
$this->assertNull(
$this->config->getAppValue('core', 'shareapi_allow_public_notification', null)
);

$this->assertSame('dummy-value',
$this->config->getAppValue('core', 'shareapi_setting1', null)
);
}
}

0 comments on commit 11ad9d4

Please sign in to comment.