summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2021-03-09 20:21:04 +0100
committerGitHub <noreply@github.com>2021-03-09 20:21:04 +0100
commit1ac8630a512982ba301ef90fd8a40a0c79ba7982 (patch)
tree2fda49ada90b61f37c86d56c9a74f0f3a0c3de7e /apps
parent45cc358d7948ffce9d415f1f24c894f6d104d63e (diff)
parent8ab601cf66382b56bf7c057a6ab6acc72fa6407f (diff)
downloadnextcloud-server-1ac8630a512982ba301ef90fd8a40a0c79ba7982.tar.gz
nextcloud-server-1ac8630a512982ba301ef90fd8a40a0c79ba7982.zip
Merge pull request #25937 from nextcloud/backport/25927/stable21
[stable21] Sharebymail: set expiration on creation
Diffstat (limited to 'apps')
-rw-r--r--apps/sharebymail/lib/ShareByMailProvider.php10
-rw-r--r--apps/sharebymail/tests/ShareByMailProviderTest.php5
2 files changed, 12 insertions, 3 deletions
diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php
index 5977cbd18bb..6ac75ce85d9 100644
--- a/apps/sharebymail/lib/ShareByMailProvider.php
+++ b/apps/sharebymail/lib/ShareByMailProvider.php
@@ -321,7 +321,8 @@ class ShareByMailProvider implements IShareProvider {
$share->getToken(),
$share->getPassword(),
$share->getSendPasswordByTalk(),
- $share->getHideDownload()
+ $share->getHideDownload(),
+ $share->getExpirationDate()
);
try {
@@ -649,9 +650,10 @@ class ShareByMailProvider implements IShareProvider {
* @param string $password
* @param bool $sendPasswordByTalk
* @param bool $hideDownload
+ * @param \DateTime|null $expirationTime
* @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->insert('share')
->setValue('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))
@@ -668,6 +670,10 @@ class ShareByMailProvider implements IShareProvider {
->setValue('stime', $qb->createNamedParameter(time()))
->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
* Can be removed once we get rid of ajax/share.php
diff --git a/apps/sharebymail/tests/ShareByMailProviderTest.php b/apps/sharebymail/tests/ShareByMailProviderTest.php
index 6285de2188c..4989f33d0e2 100644
--- a/apps/sharebymail/tests/ShareByMailProviderTest.php
+++ b/apps/sharebymail/tests/ShareByMailProviderTest.php
@@ -524,6 +524,7 @@ class ShareByMailProviderTest extends TestCase {
$password = 'password';
$sendPasswordByTalk = true;
$hideDownload = true;
+ $expiration = new \DateTime();
$instance = $this->getInstance();
@@ -540,7 +541,8 @@ class ShareByMailProviderTest extends TestCase {
$token,
$password,
$sendPasswordByTalk,
- $hideDownload
+ $hideDownload,
+ $expiration
]
);
@@ -565,6 +567,7 @@ class ShareByMailProviderTest extends TestCase {
$this->assertSame($password, $result[0]['password']);
$this->assertSame($sendPasswordByTalk, (bool)$result[0]['password_by_talk']);
$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() {