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\Mail\Provider\IManager as IMailManager;
use OCP\IAppConfig;

/**
* Class ShareByMail
Expand All @@ -58,6 +60,7 @@

public function __construct(
private IConfig $config,
private IAppConfig $appConfig,
private IDBConnection $dbConnection,
private ISecureRandom $secureRandom,
private IUserManager $userManager,
Expand All @@ -70,6 +73,7 @@
private SettingsManager $settingsManager,
private Defaults $defaults,
private IHasher $hasher,
private IMailManager $mailManager,
private IEventDispatcher $eventDispatcher,
private IShareManager $shareManager,
private IEmailValidator $emailValidator,
Expand Down Expand Up @@ -327,6 +331,7 @@
$shareWith = $share->getSharedWith();

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

Expand Down Expand Up @@ -386,7 +391,17 @@
]
);
}
$message->setFrom([Util::getDefaultEmailAddress($instanceName) => $senderName]);
$fromAddress = Util::getDefaultEmailAddress(user_part: $instanceName);
$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 404 in apps/sharebymail/lib/ShareByMailProvider.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

InvalidArrayOffset

apps/sharebymail/lib/ShareByMailProvider.php:404: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