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

[ENH] Added functionality to enable or disable Sieve Filters with toggle button #1104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

amaninyumu1
Copy link
Member

No description provided.

@amaninyumu1 amaninyumu1 force-pushed the add-a-toggle-top-activate-deactivate-a-Cypht-Sieve-rule branch from a8bd54f to b330c2b Compare June 27, 2024 08:57
@josaphatim josaphatim force-pushed the add-a-toggle-top-activate-deactivate-a-Cypht-Sieve-rule branch 2 times, most recently from fb9dc09 to 0bd8033 Compare July 2, 2024 15:02
@amaninyumu1 amaninyumu1 marked this pull request as ready for review July 4, 2024 20:04
Copy link
Member

@Shadow243 Shadow243 left a comment

Choose a reason for hiding this comment

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

Please make sure all tests pass successfully and also remove composer.lock it will be supported by this #1093 because we have some changes that must be applied in sievefilters/modules.php before.

@amaninyumu1 amaninyumu1 force-pushed the add-a-toggle-top-activate-deactivate-a-Cypht-Sieve-rule branch 2 times, most recently from aedb2a1 to fd4fdf2 Compare August 18, 2024 16:02
@amaninyumu1
Copy link
Member Author

hello @Shadow243 . I deleted the composer.lock file as you requested in your previous comment and all the tests passed successfully. please review

@marclaporte
Copy link
Member

Sorry, but there is another conflict.

@amaninyumu1 amaninyumu1 force-pushed the add-a-toggle-top-activate-deactivate-a-Cypht-Sieve-rule branch from fd4fdf2 to 37133d4 Compare September 12, 2024 18:22
@amaninyumu1
Copy link
Member Author

hello @marclaporte . conflict has been resolved

@@ -34,7 +34,7 @@ public function process() {
$this->out('conditions', json_encode(base64_decode($base64_obj)));
$base64_obj = str_replace("# ", "", preg_split('#\r?\n#', $script, 0)[2]);
$this->out('actions', json_encode(base64_decode($base64_obj)));
if (mb_strstr($script, 'allof')) {
if (strstr($script, 'allof')) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this intentional?

I am wondering because of #1224

Copy link
Member

Choose a reason for hiding this comment

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

We should keep multibyte functions in 99% of the places. There was only one exception when the size of a string was specified in bytes in the IMAP protocol (literals).

@@ -223,7 +263,7 @@ public function process() {
$blocked_wildcard = '@'.$domain;
$new_blocked_list = [];
foreach ($blocked_list as $idx => $blocked_sender) {
if (!mb_strstr($blocked_sender, $blocked_wildcard)) {
if (!strstr($blocked_sender, $blocked_wildcard)) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this intentional?

I am wondering because of #1224

Copy link
Member Author

Choose a reason for hiding this comment

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

no it was not intentional. I understand, I correct

@@ -635,7 +675,7 @@ public function process() {
$script_name = generate_filter_name($this->request->post['sieve_filter_name'], $priority);
$conditions = json_decode($this->request->post['conditions_json']);
$actions = json_decode($this->request->post['actions_json']);
$test_type = mb_strtolower($this->request->post['filter_test_type']);
$test_type = strtolower($this->request->post['filter_test_type']);
Copy link
Member

Choose a reason for hiding this comment

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

Is this intentional?

I am wondering because of #1224

Copy link
Member Author

Choose a reason for hiding this comment

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

no it was not intentional. I understand, I correct

composer.json Outdated
@@ -46,7 +46,7 @@
"ext-openssl": "*",
"ext-session": "*",
"ezyang/htmlpurifier": "^4.17",
"henrique-borba/php-sieve-manager": "^1.0",
"henrique-borba/php-sieve-manager": "~1.0.4",
Copy link
Member

Choose a reason for hiding this comment

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

We don't want such a hard constraint to this lib. It will prevent upgrades of the lib for non-major versions as 1.1.0.

modules/sievefilters/site.js Outdated Show resolved Hide resolved
);
}
if ($action->action == 'flag') {
$custom_condition->addAction(
new \PhpSieveManager\Filters\Actions\FlagFilterAction(['flags' => [$action->value]])
new \PhpSieveManager\Filters\Actions\FlagFilterAction([$action->value])
Copy link
Member

Choose a reason for hiding this comment

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

Why do you change all these FilterAction calls to constructors? I believe php-sieve-manager still expects the params in an associative array, doesn't it?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes

Copy link
Member

Choose a reason for hiding this comment

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

@kroky means that php-sieve-manager expects to receive associative arrays. with the changes you have applied, it will break sieve.

@amaninyumu1 amaninyumu1 force-pushed the add-a-toggle-top-activate-deactivate-a-Cypht-Sieve-rule branch 3 times, most recently from 768e378 to 5929ff7 Compare September 18, 2024 16:24
@amaninyumu1
Copy link
Member Author

Hello @kroky
I added echo json_encode([...]); to send a json response to ajax

@amaninyumu1 amaninyumu1 force-pushed the add-a-toggle-top-activate-deactivate-a-Cypht-Sieve-rule branch 4 times, most recently from 86542ca to 6ccac96 Compare September 20, 2024 08:19
Copy link
Member

@Shadow243 Shadow243 left a comment

Choose a reason for hiding this comment

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

It seems to me that you did a rebase which removed some important behavior. Can you review this PR carefully?

composer.json Outdated
@@ -46,7 +46,7 @@
"ext-openssl": "*",
"ext-session": "*",
"ezyang/htmlpurifier": "^4.17",
"henrique-borba/php-sieve-manager": "^1.0",
"henrique-borba/php-sieve-manager": "~1.0.4",
Copy link
Member

Choose a reason for hiding this comment

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

You don't need this too

);
}
if ($action->action == 'flag') {
$custom_condition->addAction(
new \PhpSieveManager\Filters\Actions\FlagFilterAction(['flags' => [$action->value]])
new \PhpSieveManager\Filters\Actions\FlagFilterAction([$action->value])
Copy link
Member

Choose a reason for hiding this comment

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

@kroky means that php-sieve-manager expects to receive associative arrays. with the changes you have applied, it will break sieve.

@@ -130,13 +130,6 @@ var hm_sieve_possible_actions = function() {
type: 'string',
extra_field: false
},
{
Copy link
Member

Choose a reason for hiding this comment

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

we are using this filter at https://github.com/cypht-org/cypht/blob/master/modules/sievefilters/modules.php#L915

I mean I don't understand why you are deleting this here.

Copy link
Member Author

Choose a reason for hiding this comment

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

From what I understand, the value $action->value passed into the addAction method is not explicitly an associative array in the current implementation. Could you please explain to me how this change might "break" sieve's behavior? It would help me better understand the issue and ensure that the implementation meets the expectations of PhpSieveManager. thanks

@@ -539,12 +532,6 @@ $(function () {
$('#stop_filtering').prop('checked', false);
current_account = $(this).attr('account');
edit_filter_modal.open();

// Reset the form fields when opening the modal
$(".modal_sieve_filter_name").val('');
Copy link
Member

Choose a reason for hiding this comment

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

By deleting this code, the form starts to keep the previous data again because it is this code which resets when we click on add again.

@@ -1179,9 +1216,6 @@ protected function output() {
$res .= get_script_modal_content();
$res .= '<div class="p-3">';
foreach($mailboxes as $idx => $mailbox) {
if (empty($mailbox['sieve_config_host'])) {
Copy link
Member

Choose a reason for hiding this comment

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

This condition remains important, isn't it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants