Skip to content
Merged
Prev Previous commit
Next Next commit
Store "sendPasswordByTalk" property of mail shares in the database
Signed-off-by: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu committed Jul 24, 2018
commit dd0c5e297e3190b1f4324fb2e88e08760d8d71b8
10 changes: 8 additions & 2 deletions apps/sharebymail/lib/ShareByMailProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ protected function createMailShare(IShare $share) {
$share->getShareOwner(),
$share->getPermissions(),
$share->getToken(),
$share->getPassword()
$share->getPassword(),
$share->getSendPasswordByTalk()
);

try {
Expand Down Expand Up @@ -660,9 +661,11 @@ public function getChildren(IShare $parent) {
* @param string $uidOwner
* @param int $permissions
* @param string $token
* @param string $password
* @param bool $sendPasswordByTalk
* @return int
*/
protected function addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $password) {
protected function addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $password, $sendPasswordByTalk) {
$qb = $this->dbConnection->getQueryBuilder();
$qb->insert('share')
->setValue('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))
Expand All @@ -675,6 +678,7 @@ protected function addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $
->setValue('permissions', $qb->createNamedParameter($permissions))
->setValue('token', $qb->createNamedParameter($token))
->setValue('password', $qb->createNamedParameter($password))
->setValue('password_by_talk', $qb->createNamedParameter($sendPasswordByTalk, IQueryBuilder::PARAM_BOOL))
->setValue('stime', $qb->createNamedParameter(time()));

/*
Expand Down Expand Up @@ -716,6 +720,7 @@ public function update(IShare $share, $plainTextPassword = null) {
->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()))
->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()))
->set('password', $qb->createNamedParameter($share->getPassword()))
->set('password_by_talk', $qb->createNamedParameter($share->getSendPasswordByTalk(), IQueryBuilder::PARAM_BOOL))
->set('expiration', $qb->createNamedParameter($share->getExpirationDate(), IQueryBuilder::PARAM_DATE))
->set('note', $qb->createNamedParameter($share->getNote()))
->execute();
Expand Down Expand Up @@ -972,6 +977,7 @@ protected function createShareObject($data) {
$share->setShareTime($shareTime);
$share->setSharedWith($data['share_with']);
$share->setPassword($data['password']);
$share->setSendPasswordByTalk($data['password_by_talk']);

if ($data['uid_initiator'] !== null) {
$share->setShareOwner($data['uid_owner']);
Expand Down
5 changes: 4 additions & 1 deletion apps/sharebymail/tests/ShareByMailProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ public function testAddShareToDB() {
$permissions = 1;
$token = 'token';
$password = 'password';
$sendPasswordByTalk = true;


$instance = $this->getInstance();
Expand All @@ -310,7 +311,8 @@ public function testAddShareToDB() {
$uidOwner,
$permissions,
$token,
$password
$password,
$sendPasswordByTalk
]
);

Expand All @@ -330,6 +332,7 @@ public function testAddShareToDB() {
$this->assertSame($permissions, (int)$result[0]['permissions']);
$this->assertSame($token, $result[0]['token']);
$this->assertSame($password, $result[0]['password']);
$this->assertSame($sendPasswordByTalk, (bool)$result[0]['password_by_talk']);

}

Expand Down