Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion apps/sharebymail/lib/ShareByMailProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
use OCP\Share\IShareProviderWithNotification;
use OCP\Util;
use Psr\Log\LoggerInterface;
use OCP\IAppConfig;
use OCP\Mail\Provider\IManager as IMailManager;

/**
* Class ShareByMail
Expand All @@ -57,6 +59,7 @@

public function __construct(
private IConfig $config,
private IAppConfig $appConfig,
private IDBConnection $dbConnection,
private ISecureRandom $secureRandom,
private IUserManager $userManager,
Expand All @@ -72,6 +75,7 @@
private IEventDispatcher $eventDispatcher,
private IShareManager $shareManager,
private IEmailValidator $emailValidator,
private IMailManager $mailManager,
) {
}

Expand Down Expand Up @@ -322,6 +326,7 @@

$initiatorUser = $this->userManager->get($initiator);
$initiatorDisplayName = ($initiatorUser instanceof IUser) ? $initiatorUser->getDisplayName() : $initiator;
$initiatorEmail = ($initiatorUser instanceof IUser) ? $initiatorUser->getEMailAddress() : null;
$message = $this->mailer->createMessage();

$emailTemplate = $this->mailer->createEMailTemplate('sharebymail.RecipientNotification', [
Expand Down Expand Up @@ -380,7 +385,17 @@
]
);
}
$message->setFrom([Util::getDefaultEmailAddress($instanceName) => $senderName]);
$fromAddress = Util::getDefaultEmailAddress(user_part: $instanceName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you want to use the new function you added here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have implemented appConfig directly here instead of creating a new function. If you prefer, I can shift this to a new function.

$mailProvidersEnabled = $this->appConfig->getValueBool('core', 'mail_providers_enabled');
if ($mailProvidersEnabled && $this->mailManager->has()) {
if ($initiatorEmail !== null) {
$service = $this->mailManager->findServiceByAddress($initiator, $initiatorEmail);
if ($service !== null) {
$fromAddress = $service->getPrimaryAddress()->getAddress();
}
}
}
$message->setFrom([$fromAddress => $senderName]);

Check failure on line 398 in apps/sharebymail/lib/ShareByMailProvider.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

InvalidArrayOffset

apps/sharebymail/lib/ShareByMailProvider.php:398:21: InvalidArrayOffset: Cannot create offset of type null|string, expecting array-key (see https://psalm.dev/115)

// The "Reply-To" is set to the sharer if an mail address is configured
// also the default footer contains a "Do not reply" which needs to be adjusted.
Expand Down
Loading