Store "sendPasswordByTalk" property of link shares in the database
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
parent
52cada951b
commit
fe8a67f517
2 changed files with 13 additions and 0 deletions
|
@ -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']);
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in a new issue