Skip to content

Commit

Permalink
Refactor OC\Server::getMailer
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Summers <18727110+summersab@users.noreply.github.com>
  • Loading branch information
summersab committed Aug 30, 2023
1 parent 613cd16 commit 0ee4b70
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/private/Mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
*
* Example usage:
*
* $mailer = \OC::$server->getMailer();
* $mailer = \OC::$server->get(\OCP\Mail\IMailer::class);
* $message = $mailer->createMessage();
* $message->setSubject('Your Subject');
* $message->setFrom(array('cloud@domain.org' => 'ownCloud Notifier'));
Expand Down
5 changes: 3 additions & 2 deletions lib/private/Share20/ProviderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
use OCP\Defaults;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IServerContainer;
use OCP\Mail\IMailer;
use OCP\Share\IManager;
use OCP\Share\IProviderFactory;
use OCP\Share\IShare;
Expand Down Expand Up @@ -100,7 +101,7 @@ protected function defaultShareProvider() {
$this->serverContainer->getUserManager(),
$this->serverContainer->getGroupManager(),
$this->serverContainer->getLazyRootFolder(),
$this->serverContainer->getMailer(),
$this->serverContainer->get(IMailer::class),
$this->serverContainer->query(Defaults::class),
$this->serverContainer->getL10NFactory(),
$this->serverContainer->getURLGenerator(),
Expand Down Expand Up @@ -193,7 +194,7 @@ protected function getShareByMailProvider() {
$this->serverContainer->getLazyRootFolder(),
$this->serverContainer->getL10N('sharebymail'),
$this->serverContainer->getLogger(),
$this->serverContainer->getMailer(),
$this->serverContainer->get(IMailer::class),
$this->serverContainer->getURLGenerator(),
$this->serverContainer->getActivityManager(),
$settingsManager,
Expand Down
2 changes: 1 addition & 1 deletion lib/public/Mail/IMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*
* Example usage:
*
* $mailer = \OC::$server->getMailer();
* $mailer = \OC::$server->get(\OCP\Mail\IMailer::class);
* $message = $mailer->createMessage();
* $message->setSubject('Your Subject');
* $message->setFrom(['cloud@domain.org' => 'Nextcloud Notifier']);
Expand Down
3 changes: 2 additions & 1 deletion lib/public/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

use OC\AppScriptDependency;
use OC\AppScriptSort;
use OCP\Mail\IMailer;
use bantu\IniGetWrapper\IniGetWrapper;
use Psr\Container\ContainerExceptionInterface;

Expand Down Expand Up @@ -326,7 +327,7 @@ public static function getDefaultEmailAddress(string $user_part): string {
$host_name = $config->getSystemValueString('mail_domain', $host_name);
$defaultEmailAddress = $user_part.'@'.$host_name;

$mailer = \OC::$server->getMailer();
$mailer = \OC::$server->get(IMailer::class);
if ($mailer->validateMailAddress($defaultEmailAddress)) {
return $defaultEmailAddress;
}
Expand Down

0 comments on commit 0ee4b70

Please sign in to comment.