Rspamd spamfilter policy conf file not update on spamfilter policy score update via api

Discussion in 'Installation/Configuration' started by surajdadral, Nov 27, 2023.

  1. surajdadral

    surajdadral New Member

    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,
     
  2. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    Can you share your full API script?
     
  3. surajdadral

    surajdadral New Member

    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}
     
  4. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    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?
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    I agree with your findings. I guess we should consider adding this code to the API as well.
     
    surajdadral likes this.
  6. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

Share This Page