Skip to content

Commit

Permalink
Fixes #37039 - use default_language as default
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 committed Mar 2, 2020
1 parent 8382368 commit 96e7e11
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
3 changes: 3 additions & 0 deletions changelog/unreleased/37039
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Change: Respect default_language when sending email notifications

https://github.com/owncloud/core/issues/37039
3 changes: 2 additions & 1 deletion lib/private/Share/MailNotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ public function sendInternalShareMail($sender, $node, $shareType, $recipientList
$unescapedFilename = $filename;
$link = $filter->getLink();

$recipientLanguageCode = $this->config->getUserValue($recipient->getUID(), 'core', 'lang', 'en');
$defaultLang = $this->config->getSystemValue('default_language', 'en');
$recipientLanguageCode = $this->config->getUserValue($recipient->getUID(), 'core', 'lang', $defaultLang);
$recipientL10N = \OC::$server->getL10N('lib');
if ($this->l->getLanguageCode() !== $recipientLanguageCode) {
$recipientL10N = \OC::$server->getL10N('lib', $recipientLanguageCode);
Expand Down
18 changes: 13 additions & 5 deletions tests/lib/Share/MailNotificationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -563,23 +563,27 @@ protected function getShareMock(array $shareData) {
return $share;
}

public function providesLanguages() {
public function providesLanguages(): array {
return [
['es', 'en'],
['en', 'en']
['es', 'en', 'TestUser ha compartido »<welcome>.txt« contigo'],
['en', 'en', 'TestUser shared »<welcome>.txt« with you']
];
}

/**
* @dataProvider providesLanguages
* @param string $recipientLanguage
* @param string $senderLanguage
* @param string $expectedSubject
* @throws \OCP\Files\NotFoundException
* @throws \OCP\Share\Exceptions\GenericShareException
*/
public function testSendInternalShareWithRecipientLanguageCode($recipientLanguage, $senderLanguage) {
public function testSendInternalShareWithRecipientLanguageCode($recipientLanguage, $senderLanguage, $expectedSubject) {
$this->config
->method('getAppValue')
->with('core', 'shareapi_allow_mail_notification', 'no')
->willReturn('yes');
$this->setupMailerMock('TestUser shared »<welcome>.txt« with you', false);
$this->setupMailerMock($expectedSubject, false);
$shareMock = $this->getShareMock(
['file_target' => '/<welcome>.txt', 'item_source' => 123, 'expiration' => '2017-01-01T15:03:01.012345Z']
);
Expand All @@ -595,6 +599,10 @@ public function testSendInternalShareWithRecipientLanguageCode($recipientLanguag
->willReturn('Recipient');
$recipient->method('getUID')
->willReturn('Recipient');
$this->config->expects($this->once())
->method('getSystemValue')
->with('default_language', 'en')
->willReturn('en');
$this->config->expects($this->once())
->method('getUserValue')
->with('Recipient', 'core', 'lang', 'en')
Expand Down

0 comments on commit 96e7e11

Please sign in to comment.