Hi, I am facing issue with mail user spamfilter settings. If I update rspamd spamfilter policy score (rspamd_spam_tag_level/rspamd_spam_kill_level) using `mail_policy_update` api action, then rsapmd spamfilter config file (/etc/rspamd/local.d/users/foo_example.com.conf, etc.) of related spamfilter users is not updated. If I do same from ispconfig admin console, then its working fine and the related users conf files got updated. My ISPConfig Version: 3.2.11p1 OS: Debian 10 Thanks,
Here is the curl request I am doing: Code: curl -X POST "https://mail.example.com:8080/remote/json.php?mail_policy_update" \ -H "Content-Type: application/json" \ -d '{ "session_id": "nf87a26f8b4cc760fefb6c8xfbb5034471c8212f4", "primary_id": 5, "params": { "policy_name": "Normal", "virus_lover": "N", "spam_lover": "N", "rspamd_spam_greylisting_level": 3.0, "rspamd_spam_tag_method": "rewrite_subject", "rspamd_spam_tag_level": 6.0, "rspamd_spam_kill_level": 10.0 } }' And response is: Code: {"code":"ok","message":"","response":1}
in spamfilter_policy_edit.php this is covered: PHP: function onAfterDatalogSave($insert = false) { global $app; if(!$insert && $this->record_has_changed){ $spamfilter_users = $app->db->queryAllRecords("SELECT * FROM spamfilter_users WHERE policy_id = ?", intval($this->id)); if(is_array($spamfilter_users) && !empty($spamfilter_users)){ foreach($spamfilter_users as $spamfilter_user){ $app->db->datalogUpdate('spamfilter_users', $spamfilter_user, 'id', $spamfilter_user["id"], true); // check if this is an email domain if(substr($spamfilter_user['email'],0,1) == '@') { $domain = substr($spamfilter_user['email'],1); // Nothing special to do for a domain } } } } } I think that this is not triggered by an API update. @till can you confirm, and do you have a suggestion on the best way to fix this?
Tried updating function mail_policy_update in file interface/lib/classes/remote.d/mail.inc.php: PHP: public function mail_policy_update($session_id, $client_id, $primary_id, $params) { global $app; if (!$this->checkPerm($session_id, 'mail_policy_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } $old_data = $this->mail_policy_get($session_id, $primary_id); $affected_rows = $this->updateQuery('../mail/form/spamfilter_policy.tform.php', $client_id, $primary_id, $params); $updated_data = $this->mail_policy_get($session_id, $primary_id); $record_has_changed = false; foreach($updated_data as $key => $val) { if ($key == 'policy_name') { continue; } // Don't trigger update of all spamfilter users if only policy_name is changed if(isset($old_data[$key]) && @$old_data[$key] != $val) { // Record has changed $record_has_changed = true; } } if($record_has_changed){ $spamfilter_users = $app->db->queryAllRecords("SELECT * FROM spamfilter_users WHERE policy_id = ?", intval($primary_id)); if(is_array($spamfilter_users) && !empty($spamfilter_users)){ foreach($spamfilter_users as $spamfilter_user){ $app->db->datalogUpdate('spamfilter_users', $spamfilter_user, 'id', $spamfilter_user["id"], true); } } } return $affected_rows; } Old: PHP: public function mail_policy_update($session_id, $client_id, $primary_id, $params) { if (!$this->checkPerm($session_id, 'mail_policy_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } $affected_rows = $this->updateQuery('../mail/form/spamfilter_policy.tform.php', $client_id, $primary_id, $params); return $affected_rows; } Working fine for me. Thanks,