Add labels to mail shares
Now the email is shown on a second line if a label is set. Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
parent
ae19cb168f
commit
100d5d9a47
|
@ -558,11 +558,11 @@ class ShareAPIController extends OCSController {
|
|||
// Only share by mail have a recipient
|
||||
if ($shareType === IShare::TYPE_EMAIL) {
|
||||
$share->setSharedWith($shareWith);
|
||||
} else {
|
||||
// Only link share have a label
|
||||
if (!empty($label)) {
|
||||
$share->setLabel($label);
|
||||
}
|
||||
}
|
||||
|
||||
// If we have a label, use it
|
||||
if (!empty($label)) {
|
||||
$share->setLabel($label);
|
||||
}
|
||||
|
||||
if ($sendPasswordByTalk === 'true') {
|
||||
|
@ -1127,8 +1127,7 @@ class ShareAPIController extends OCSController {
|
|||
$share->setPassword($password);
|
||||
}
|
||||
|
||||
// only link shares have labels
|
||||
if ($share->getShareType() === IShare::TYPE_LINK && $label !== null) {
|
||||
if ($label !== null) {
|
||||
if (strlen($label) > 255) {
|
||||
throw new OCSBadRequestException("Maxmimum label length is 255");
|
||||
}
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
<h5 :title="title">
|
||||
{{ title }}
|
||||
</h5>
|
||||
<p v-if="subtitle">
|
||||
{{ subtitle }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- clipboard -->
|
||||
|
@ -406,7 +409,6 @@ export default {
|
|||
|
||||
/**
|
||||
* Link share label
|
||||
* TODO: allow editing
|
||||
* @returns {string}
|
||||
*/
|
||||
title() {
|
||||
|
@ -424,6 +426,11 @@ export default {
|
|||
})
|
||||
}
|
||||
if (this.share.label && this.share.label.trim() !== '') {
|
||||
if (this.isEmailShareType) {
|
||||
return t('files_sharing', 'Mail share ({label})', {
|
||||
label: this.share.label.trim(),
|
||||
})
|
||||
}
|
||||
return t('files_sharing', 'Share link ({label})', {
|
||||
label: this.share.label.trim(),
|
||||
})
|
||||
|
@ -435,6 +442,18 @@ export default {
|
|||
return t('files_sharing', 'Share link')
|
||||
},
|
||||
|
||||
/**
|
||||
* Show the email on a second line if a label is set for mail shares
|
||||
* @returns {string}
|
||||
*/
|
||||
subtitle() {
|
||||
if (this.isEmailShareType
|
||||
&& this.title !== this.share.shareWith) {
|
||||
return this.share.shareWith
|
||||
}
|
||||
return null
|
||||
},
|
||||
|
||||
/**
|
||||
* Does the current share have an expiration date
|
||||
* @returns {boolean}
|
||||
|
@ -933,6 +952,9 @@ export default {
|
|||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
p {
|
||||
color: var(--color-text-maxcontrast);
|
||||
}
|
||||
}
|
||||
|
||||
&:not(.sharing-entry--share) &__actions {
|
||||
|
|
|
@ -322,6 +322,7 @@ class ShareByMailProvider implements IShareProvider {
|
|||
$share->getPassword(),
|
||||
$share->getSendPasswordByTalk(),
|
||||
$share->getHideDownload(),
|
||||
$share->getLabel(),
|
||||
$share->getExpirationDate()
|
||||
);
|
||||
|
||||
|
@ -659,10 +660,11 @@ class ShareByMailProvider implements IShareProvider {
|
|||
* @param string $password
|
||||
* @param bool $sendPasswordByTalk
|
||||
* @param bool $hideDownload
|
||||
* @param string $label
|
||||
* @param \DateTime|null $expirationTime
|
||||
* @return int
|
||||
*/
|
||||
protected function addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $password, $sendPasswordByTalk, $hideDownload, $expirationTime) {
|
||||
protected function addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $password, $sendPasswordByTalk, $hideDownload, $label, $expirationTime) {
|
||||
$qb = $this->dbConnection->getQueryBuilder();
|
||||
$qb->insert('share')
|
||||
->setValue('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))
|
||||
|
@ -677,7 +679,8 @@ class ShareByMailProvider implements IShareProvider {
|
|||
->setValue('password', $qb->createNamedParameter($password))
|
||||
->setValue('password_by_talk', $qb->createNamedParameter($sendPasswordByTalk, IQueryBuilder::PARAM_BOOL))
|
||||
->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))
|
||||
->setValue('label', $qb->createNamedParameter($label));
|
||||
|
||||
if ($expirationTime !== null) {
|
||||
$qb->setValue('expiration', $qb->createNamedParameter($expirationTime, IQueryBuilder::PARAM_DATE));
|
||||
|
@ -720,6 +723,7 @@ class ShareByMailProvider implements IShareProvider {
|
|||
->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()))
|
||||
->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()))
|
||||
->set('password', $qb->createNamedParameter($share->getPassword()))
|
||||
->set('label', $qb->createNamedParameter($share->getLabel()))
|
||||
->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()))
|
||||
|
@ -982,6 +986,7 @@ class ShareByMailProvider implements IShareProvider {
|
|||
$share->setShareTime($shareTime);
|
||||
$share->setSharedWith($data['share_with']);
|
||||
$share->setPassword($data['password']);
|
||||
$share->setLabel($data['label']);
|
||||
$share->setSendPasswordByTalk((bool)$data['password_by_talk']);
|
||||
$share->setHideDownload((bool)$data['hide_download']);
|
||||
|
||||
|
|
|
@ -524,6 +524,7 @@ class ShareByMailProviderTest extends TestCase {
|
|||
$password = 'password';
|
||||
$sendPasswordByTalk = true;
|
||||
$hideDownload = true;
|
||||
$label = 'label';
|
||||
$expiration = new \DateTime();
|
||||
|
||||
|
||||
|
@ -542,6 +543,7 @@ class ShareByMailProviderTest extends TestCase {
|
|||
$password,
|
||||
$sendPasswordByTalk,
|
||||
$hideDownload,
|
||||
$label,
|
||||
$expiration
|
||||
]
|
||||
);
|
||||
|
@ -567,6 +569,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($label, $result[0]['label']);
|
||||
$this->assertSame($expiration->getTimestamp(), \DateTime::createFromFormat('Y-m-d H:i:s', $result[0]['expiration'])->getTimestamp());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue