summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2018-10-12 20:15:40 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-11-02 01:57:48 +0100
commitfe8a67f5175b687ec6cc8230c7759ddddbe25b0a (patch)
treea696489d59ef601eb74bf43b751627dd4aab0e79
parent52cada951ba2f1849c0034e06520719c21fed9b2 (diff)
downloadnextcloud-server-fe8a67f5175b687ec6cc8230c7759ddddbe25b0a.tar.gz
nextcloud-server-fe8a67f5175b687ec6cc8230c7759ddddbe25b0a.zip
Store "sendPasswordByTalk" property of link shares in the database
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
-rw-r--r--lib/private/Share20/DefaultShareProvider.php4
-rw-r--r--tests/lib/Share20/DefaultShareProviderTest.php9
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php
index 50111054546..589b64fc58a 100644
--- a/lib/private/Share20/DefaultShareProvider.php
+++ b/lib/private/Share20/DefaultShareProvider.php
@@ -156,6 +156,8 @@ class DefaultShareProvider implements IShareProvider {
$qb->setValue('password', $qb->createNamedParameter($share->getPassword()));
}
+ $qb->setValue('password_by_talk', $qb->createNamedParameter($share->getSendPasswordByTalk(), IQueryBuilder::PARAM_BOOL));
+
//If an expiration date is set store it
if ($share->getExpirationDate() !== null) {
$qb->setValue('expiration', $qb->createNamedParameter($share->getExpirationDate(), 'datetime'));
@@ -293,6 +295,7 @@ class DefaultShareProvider implements IShareProvider {
$qb->update('share')
->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId())))
->set('password', $qb->createNamedParameter($share->getPassword()))
+ ->set('password_by_talk', $qb->createNamedParameter($share->getSendPasswordByTalk(), IQueryBuilder::PARAM_BOOL))
->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()))
->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()))
->set('permissions', $qb->createNamedParameter($share->getPermissions()))
@@ -938,6 +941,7 @@ class DefaultShareProvider implements IShareProvider {
$share->setSharedWith($data['share_with']);
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
$share->setPassword($data['password']);
+ $share->setSendPasswordByTalk((bool)$data['password_by_talk']);
$share->setToken($data['token']);
}
diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php
index d368304453f..578225840b6 100644
--- a/tests/lib/Share20/DefaultShareProviderTest.php
+++ b/tests/lib/Share20/DefaultShareProviderTest.php
@@ -363,6 +363,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
->values([
'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK),
'password' => $qb->expr()->literal('password'),
+ 'password_by_talk' => $qb->expr()->literal(true),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
'item_type' => $qb->expr()->literal('file'),
@@ -392,6 +393,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals(\OCP\Share::SHARE_TYPE_LINK, $share->getShareType());
$this->assertNull($share->getSharedWith());
$this->assertEquals('password', $share->getPassword());
+ $this->assertEquals(true, $share->getSendPasswordByTalk());
$this->assertEquals('sharedBy', $share->getSharedBy());
$this->assertEquals('shareOwner', $share->getShareOwner());
$this->assertEquals($ownerPath, $share->getNode());
@@ -775,6 +777,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share->setNode($path);
$share->setPermissions(1);
$share->setPassword('password');
+ $share->setSendPasswordByTalk(true);
$share->setToken('token');
$expireDate = new \DateTime();
$share->setExpirationDate($expireDate);
@@ -792,6 +795,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertLessThanOrEqual(new \DateTime(), $share2->getShareTime());
$this->assertSame($path, $share2->getNode());
$this->assertSame('password', $share2->getPassword());
+ $this->assertSame(true, $share2->getSendPasswordByTalk());
$this->assertSame('token', $share2->getToken());
$this->assertEquals($expireDate->getTimestamp(), $share2->getExpirationDate()->getTimestamp());
}
@@ -803,6 +807,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
->values([
'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK),
'password' => $qb->expr()->literal('password'),
+ 'password_by_talk' => $qb->expr()->literal(true),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
'item_type' => $qb->expr()->literal('file'),
@@ -825,6 +830,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertSame('sharedBy', $share->getSharedBy());
$this->assertSame('secrettoken', $share->getToken());
$this->assertSame('password', $share->getPassword());
+ $this->assertSame(true, $share->getSendPasswordByTalk());
$this->assertSame(null, $share->getSharedWith());
}
@@ -1833,6 +1839,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->provider->getShareById($id);
$share->setPassword('password');
+ $share->setSendPasswordByTalk(true);
$share->setSharedBy('user4');
$share->setShareOwner('user5');
$share->setNode($file2);
@@ -1842,6 +1849,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals($id, $share2->getId());
$this->assertEquals('password', $share2->getPassword());
+ $this->assertSame(true, $share2->getSendPasswordByTalk());
$this->assertSame('user4', $share2->getSharedBy());
$this->assertSame('user5', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
@@ -1850,6 +1858,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals($id, $share2->getId());
$this->assertEquals('password', $share2->getPassword());
+ $this->assertSame(true, $share2->getSendPasswordByTalk());
$this->assertSame('user4', $share2->getSharedBy());
$this->assertSame('user5', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());