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

Sieve #4472

Merged
merged 1 commit into from
Feb 26, 2021
Merged

Sieve #4472

merged 1 commit into from
Feb 26, 2021

Conversation

kesselb
Copy link
Contributor

@kesselb kesselb commented Feb 3, 2021

Todo:

  • Add Managesieve as dependency
  • DB fields to store sieve configuration
  • Provisioning support
  • Account Form
  • Text-Editor for current sieve script
  • Custom Logger for ManageSieve (because Horde_Imap_Client_Base_Debug do not work)
  • Migration to add sieveEnabled = false to existing provisioning configurations
  • Unit-Test for SieveController
  • Test upgrade from 1.8.0 (with and without provisioning)

Nice to have:

  • Validation for sieve script (is done by managesieve itself)
  • Detect sieve/managesieve via capabilities
  • Move SieveController.updateAccount to service

CI:

Build fails because the sieve integration server uses self signed certificates.
We need horde/ManageSieve#1 or apply the patch on CI.

Screenshots:

image
image
image

lib/Service/SetupService.php Outdated Show resolved Hide resolved
@kesselb kesselb force-pushed the enh/sieve branch 3 times, most recently from 28b0e6e to 4e23769 Compare February 10, 2021 15:24
@kesselb kesselb force-pushed the enh/sieve branch 2 times, most recently from 20bf855 to a0e33df Compare February 17, 2021 17:13
@kesselb kesselb force-pushed the enh/sieve branch 4 times, most recently from 4796be8 to 37893a2 Compare February 23, 2021 11:20
@kesselb kesselb marked this pull request as ready for review February 23, 2021 11:20
@kesselb kesselb force-pushed the enh/sieve branch 2 times, most recently from 2c0f621 to 745eb36 Compare February 24, 2021 11:09
@kesselb
Copy link
Contributor Author

kesselb commented Feb 24, 2021

Did some testing today for the update path.

Test instance with 3 users and a provisioning configuration. In addition configured a normal email account. Migration added the new fields (to db and provisioning config).

Update gone through without issues. State after the update es expected (sieve disabled for all accounts).

textarea {
width: 100%;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#sieve-text-area {
font-size: 14px;
line-height: 22px;
font-family: monospace;
}

Copy link
Member

Choose a reason for hiding this comment

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

we will evaluate the usage of a nicer editor with syntax highlighting anyway, so let's address this later

Comment on lines +146 to 156
if ($config->getSieveEnabled()) {
$account->setSieveUser($config->buildSieveUser($user));
$account->setSieveHost($config->getSieveHost());
$account->setSievePort($config->getSievePort());
$account->setSieveSslMode($config->getSieveSslMode());
} else {
$account->setSieveUser(null);
$account->setSieveHost(null);
$account->setSievePort(null);
$account->setSieveSslMode(null);
}

return $account;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if ($config->getSieveEnabled()) {
$account->setSieveUser($config->buildSieveUser($user));
$account->setSieveHost($config->getSieveHost());
$account->setSievePort($config->getSievePort());
$account->setSieveSslMode($config->getSieveSslMode());
} else {
$account->setSieveUser(null);
$account->setSieveHost(null);
$account->setSievePort(null);
$account->setSieveSslMode(null);
}
return $account;
}
if ($config->getSieveEnabled()) {
$account->setSieveUser($config->buildSieveUser($user));
$account->setSieveHost($config->getSieveHost());
$account->setSievePort($config->getSievePort());
$account->setSieveSslMode($config->getSieveSslMode());
return $account;
}
$account->setSieveUser(null);
$account->setSieveHost(null);
$account->setSievePort(null);
$account->setSieveSslMode(null);
return $account;
}

No need to wait to return here, if the condition is fulfilled, we can safely return the set values.

Copy link
Member

Choose a reason for hiding this comment

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

yes and no 😉

I think this is one of those cases where the if and the else branch have equal importance. The early return would (to me) signal that it's some error condition or anything very specific.

I would keep the explicit if-else here.

But again, this formatting doesn't change any logic, nor does it make anything faster. I'm fine with either :)

Copy link
Contributor

@miaulalala miaulalala left a comment

Choose a reason for hiding this comment

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

It works fine, no issues.

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

Works very well! :shipit:

lib/Sieve/SieveClientFactory.php Outdated Show resolved Hide resolved
@dumblob
Copy link

dumblob commented Feb 26, 2021

Looks really good and minimal to me. Well done! Thanks a lot.

Dumb question (I didn't apply this patch yet) - has this been tested with multi-account setups?

@ChristophWurst
Copy link
Member

Dumb question (I didn't apply this patch yet) - has this been tested with multi-account setups?

Yes. There is a setting per account.

* Expose managesieve port
* Add sieve client factory
* Add support for sieve to provisioning
* Refactor test connectivity logic and add sieve.
* Add support for sieve to provisioning
* Add sieve to account form
* Add debug logger for ManageSieve
* Add api to get and update active script
* Add error for managesieve exception
* Add text editor to update existing script

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
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.

None yet

4 participants