Merge pull request #25927 from nextcloud/enh/sharebymail/set_expiration_on_creation
Sharebymail: set expiration on creation
This commit is contained in:
commit
b0fe408d1f
|
@ -321,7 +321,8 @@ class ShareByMailProvider implements IShareProvider {
|
||||||
$share->getToken(),
|
$share->getToken(),
|
||||||
$share->getPassword(),
|
$share->getPassword(),
|
||||||
$share->getSendPasswordByTalk(),
|
$share->getSendPasswordByTalk(),
|
||||||
$share->getHideDownload()
|
$share->getHideDownload(),
|
||||||
|
$share->getExpirationDate()
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -658,9 +659,10 @@ class ShareByMailProvider implements IShareProvider {
|
||||||
* @param string $password
|
* @param string $password
|
||||||
* @param bool $sendPasswordByTalk
|
* @param bool $sendPasswordByTalk
|
||||||
* @param bool $hideDownload
|
* @param bool $hideDownload
|
||||||
|
* @param \DateTime|null $expirationTime
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
protected function addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $password, $sendPasswordByTalk, $hideDownload) {
|
protected function addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $password, $sendPasswordByTalk, $hideDownload, $expirationTime) {
|
||||||
$qb = $this->dbConnection->getQueryBuilder();
|
$qb = $this->dbConnection->getQueryBuilder();
|
||||||
$qb->insert('share')
|
$qb->insert('share')
|
||||||
->setValue('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))
|
->setValue('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))
|
||||||
|
@ -677,6 +679,10 @@ class ShareByMailProvider implements IShareProvider {
|
||||||
->setValue('stime', $qb->createNamedParameter(time()))
|
->setValue('stime', $qb->createNamedParameter(time()))
|
||||||
->setValue('hide_download', $qb->createNamedParameter((int)$hideDownload, IQueryBuilder::PARAM_INT));
|
->setValue('hide_download', $qb->createNamedParameter((int)$hideDownload, IQueryBuilder::PARAM_INT));
|
||||||
|
|
||||||
|
if ($expirationTime !== null) {
|
||||||
|
$qb->setValue('expiration', $qb->createNamedParameter($expirationTime, IQueryBuilder::PARAM_DATE));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Added to fix https://github.com/owncloud/core/issues/22215
|
* Added to fix https://github.com/owncloud/core/issues/22215
|
||||||
* Can be removed once we get rid of ajax/share.php
|
* Can be removed once we get rid of ajax/share.php
|
||||||
|
|
|
@ -524,6 +524,7 @@ class ShareByMailProviderTest extends TestCase {
|
||||||
$password = 'password';
|
$password = 'password';
|
||||||
$sendPasswordByTalk = true;
|
$sendPasswordByTalk = true;
|
||||||
$hideDownload = true;
|
$hideDownload = true;
|
||||||
|
$expiration = new \DateTime();
|
||||||
|
|
||||||
|
|
||||||
$instance = $this->getInstance();
|
$instance = $this->getInstance();
|
||||||
|
@ -540,7 +541,8 @@ class ShareByMailProviderTest extends TestCase {
|
||||||
$token,
|
$token,
|
||||||
$password,
|
$password,
|
||||||
$sendPasswordByTalk,
|
$sendPasswordByTalk,
|
||||||
$hideDownload
|
$hideDownload,
|
||||||
|
$expiration
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -565,6 +567,7 @@ class ShareByMailProviderTest extends TestCase {
|
||||||
$this->assertSame($password, $result[0]['password']);
|
$this->assertSame($password, $result[0]['password']);
|
||||||
$this->assertSame($sendPasswordByTalk, (bool)$result[0]['password_by_talk']);
|
$this->assertSame($sendPasswordByTalk, (bool)$result[0]['password_by_talk']);
|
||||||
$this->assertSame($hideDownload, (bool)$result[0]['hide_download']);
|
$this->assertSame($hideDownload, (bool)$result[0]['hide_download']);
|
||||||
|
$this->assertSame($expiration->getTimestamp(), \DateTime::createFromFormat('Y-m-d H:i:s', $result[0]['expiration'])->getTimestamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUpdate() {
|
public function testUpdate() {
|
||||||
|
|
Loading…
Reference in New Issue