Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: mail provider backend #45383

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft

Conversation

SebastianKrupinski
Copy link
Contributor

Summary

Initial Mail Provider Implementation

TODO

  • Copyright
  • Comments
  • Minor code improvements

Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
@@ -431,6 +435,13 @@
$taskProcessingTaskTypeClass
);
}

public function registerMailProvider(string $mailProviderClass): void {

Check failure

Code scanning / Psalm

ParamNameMismatch Error

Argument 1 of OC\AppFramework\Bootstrap\_home_runner_actions_runner__work_server_server_lib_private_AppFramework_Bootstrap_RegistrationContext_php_161_4839::registerMailProvider has wrong name $mailProviderClass, expecting $class as defined by OCP\AppFramework\Bootstrap\IRegistrationContext::registerMailProvider
@@ -968,4 +985,11 @@
public function getTaskProcessingTaskTypes(): array {
return $this->taskProcessingTaskTypes;
}

/**
* @return ServiceRegistration<IMailProviders>[]

Check failure

Code scanning / Psalm

UndefinedDocblockClass Error

Docblock-defined class, interface or enum named OC\AppFramework\Bootstrap\IMailProviders does not exist
lib/private/Mail/Provider/Manager.php Fixed Show fixed Hide fixed
lib/private/Mail/Provider/Manager.php Fixed Show fixed Hide fixed
lib/private/Mail/Provider/Manager.php Fixed Show fixed Hide fixed
lib/private/Mail/Provider/Manager.php Fixed Show fixed Hide fixed
lib/private/Mail/Provider/Manager.php Fixed Show fixed Hide fixed
apps/dav/lib/CalDAV/Schedule/IMipPlugin.php Fixed Show fixed Hide fixed
apps/dav/lib/CalDAV/Schedule/IMipPlugin.php Fixed Show fixed Hide fixed
apps/dav/lib/CalDAV/Schedule/IMipPlugin.php Fixed Show fixed Hide fixed
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
lib/private/Mail/Provider/Address.php Fixed Show fixed Hide fixed
lib/private/Mail/Provider/Address.php Fixed Show fixed Hide fixed
lib/private/Mail/Provider/Attachment.php Fixed Show fixed Hide fixed
lib/private/Mail/Provider/Message.php Fixed Show fixed Hide fixed
lib/private/Mail/Provider/Message.php Fixed Show fixed Hide fixed
lib/public/Mail/Provider/IAttachment.php Fixed Show fixed Hide fixed
apps/dav/lib/CalDAV/Schedule/IMipPlugin.php Fixed Show fixed Hide fixed
apps/dav/lib/CalDAV/Schedule/IMipPlugin.php Dismissed Show dismissed Hide dismissed
apps/dav/lib/CalDAV/Schedule/IMipPlugin.php Dismissed Show dismissed Hide dismissed
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

Psalm found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@SebastianKrupinski
Copy link
Contributor Author

TODO: Separate attachment handling for local files (saved on the system) and streamed files (generate in memory)

Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
apps/dav/lib/CalDAV/Schedule/IMipPlugin.php Fixed Show fixed Hide fixed
lib/private/Mail/Provider/Manager.php Fixed Show fixed Hide fixed
lib/public/Mail/Provider/Message.php Fixed Show fixed Hide fixed
lib/public/Mail/Provider/Message.php Fixed Show fixed Hide fixed
lib/public/Mail/Provider/Message.php Fixed Show fixed Hide fixed
lib/public/Mail/Provider/IService.php Fixed Show fixed Hide fixed
lib/public/Mail/Provider/Message.php Fixed Show fixed Hide fixed
lib/public/Mail/Provider/Message.php Fixed Show fixed Hide fixed
lib/public/Mail/Provider/Message.php Fixed Show fixed Hide fixed
lib/public/Mail/Provider/Message.php Fixed Show fixed Hide fixed
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
lib/private/Mail/Provider/Manager.php Fixed Show fixed Hide fixed
lib/private/Mail/Provider/Manager.php Fixed Show fixed Hide fixed
lib/private/Mail/Provider/Manager.php Fixed Show fixed Hide fixed
lib/private/Mail/Provider/Manager.php Fixed Show fixed Hide fixed
lib/private/Mail/Provider/Manager.php Fixed Show fixed Hide fixed
apps/dav/lib/CalDAV/Schedule/IMipPlugin.php Fixed Show fixed Hide fixed
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
lib/private/Mail/Provider/Manager.php Fixed Show fixed Hide fixed
lib/private/Mail/Provider/Manager.php Dismissed Show dismissed Hide dismissed
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
apps/dav/lib/CalDAV/Schedule/IMipPlugin.php Dismissed Show dismissed Hide dismissed
// load mail provider manager
$mailManager = \OC::$server->get(\OC\Mail\Provider\Manager::class);
// retrieve all services
$mailService = $mailManager->findServiceByAddress($this->userSession->getUser()->getUID(), $sender);

Check notice

Code scanning / Psalm

PossiblyNullReference Note

Cannot call method getUID on possibly null value
apps/dav/lib/CalDAV/Schedule/IMipPlugin.php Fixed Show fixed Hide fixed
apps/dav/lib/CalDAV/Schedule/IMipPlugin.php Fixed Show fixed Hide fixed
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
$services[$entry->id()] = $entry->listServices($uid);
}
// return collection
return $services;

Check failure

Code scanning / Psalm

InvalidReturnStatement Error

The inferred type 'array<string, non-empty-array<string, OCP\Mail\Provider\IService>>' does not match the declared return type 'array<string, OCP\Mail\Provider\IService>' for OC\Mail\Provider\Manager::services
// retrieve all services
$mailService = $mailManager->findServiceByAddress($this->userSession->getUser()->getUID(), $sender);
// evaluate if a mail service was found and has sending capabilities
if ($mailService !== null && $mailService->capable('MessageSend')) {

Check notice

Code scanning / Psalm

RiskyTruthyFalsyComparison Note

Operand of type array<array-key, mixed>|bool contains type array<array-key, mixed>, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead.
if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $color)) {
return BackgroundService::DEFAULT_COLOR;
// try admin color
$defaultColor = $this->config->getAppValue(Application::APP_ID, 'primary_color', '');

Check notice

Code scanning / Psalm

DeprecatedMethod Note

The method OCP\IConfig::getAppValue has been marked as deprecated
@@ -366,7 +379,7 @@
$variables['image-login-background'] = "url('".$this->imageManager->getImageUrl('background')."')";
$variables['image-login-plain'] = 'false';

if ($this->config->getAppValue('theming', 'color', '') !== '') {
if ($this->config->getAppValue('theming', 'primary_color', '') !== '') {

Check notice

Code scanning / Psalm

DeprecatedMethod Note

The method OCP\IConfig::getAppValue has been marked as deprecated
}

public function setDefaultBackground(): void {
$this->config->deleteUserValue($this->userId, Application::APP_ID, 'background_image');
$this->config->deleteUserValue($this->userId, Application::APP_ID, 'background_color');
$this->config->deleteUserValue($this->userId, Application::APP_ID, 'primary_color');

Check notice

Code scanning / Psalm

PossiblyNullArgument Note

Argument 1 of OCP\IConfig::deleteUserValue cannot be null, possibly null value provided
* Default background color only taking admin setting into account
*/
public function getDefaultColorBackground(): string {
$defaultColor = $this->config->getAppValue(Application::APP_ID, 'background_color', '');

Check notice

Code scanning / Psalm

DeprecatedMethod Note

The method OCP\IConfig::getAppValue has been marked as deprecated
@@ -77,7 +79,11 @@
case 'favicon':
return $this->urlGenerator->imagePath('core', 'logo/logo.png') . '?v=' . $cacheBusterCounter;
case 'background':
return $this->urlGenerator->linkTo(Application::APP_ID, 'img/background/' . BackgroundService::DEFAULT_BACKGROUND_IMAGE);
// Removing the background defines its mime as 'backgroundColor'
$mimeSetting = $this->config->getAppValue('theming', 'backgroundMime', '');

Check notice

Code scanning / Psalm

DeprecatedMethod Note

The method OCP\IConfig::getAppValue has been marked as deprecated
/** URL of admin configured background image */
'backgroundImage' => $this->themingDefaults->getBackground(),
/** `backgroundColor` if disabled, mime type if defined and empty by default */
'backgroundMime' => $this->config->getAppValue('theming', 'backgroundMime', ''),

Check notice

Code scanning / Psalm

DeprecatedMethod Note

The method OCP\IConfig::getAppValue has been marked as deprecated
// If a background image is set we revert to the mean image color
if ($this->imageManager->hasImage('background')) {
$file = $this->imageManager->getImage('background');
$returnValue = $this->backgroundService->setGlobalBackground($file->read()) ?? '';

Check notice

Code scanning / Psalm

PossiblyFalseArgument Note

Argument 1 of OCA\Theming\Service\BackgroundService::setGlobalBackground cannot be false, possibly resource|string value expected
if ($handle && $image->loadFromFileHandle($handle) !== false) {
$meanColor = $this->calculateMeanColor($image);
if ($meanColor !== false) {
$this->config->setAppValue(Application::APP_ID, 'background_color', $meanColor);

Check notice

Code scanning / Psalm

DeprecatedMethod Note

The method OCP\IConfig::setAppValue has been marked as deprecated
imagedestroy($outputImage);
}
} catch (\Exception $e) {
if (isset($outputImage) && is_resource($outputImage) || $outputImage instanceof \GdImage) {

Check notice

Code scanning / Psalm

PossiblyUndefinedVariable Note

Possibly undefined variable $outputImage defined in try block
@SebastianKrupinski
Copy link
Contributor Author

TODO: unit tests

Copy link

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calendar invites: Administrator shall choose if server's or user's email adress is used
1 participant