.include(duplicate=append,priority=0) "{= env.TESTDIR =}/configs/plugins.conf"

lua = "{= env.LUA_SCRIPT =}";

settings {
  id_test {
    id = "id_test";
    apply {
      symbols_enabled = ["SIMPLE_TEST"];
    }
  }

  id_pre { # implicit id
    apply {
      symbols_enabled = ["SIMPLE_PRE"];
    }
  }

  id_virtual {
    apply {
      symbols_enabled = ["SIMPLE_VIRTUAL"];
    }
  }

  id_virtual1 {
    apply {
      symbols {
        EXPLICIT_VIRTUAL1 = 10.0
      }
       symbols_enabled = ["DEP_REAL"];
    }
  }

  id_virtual_group {
    user = "test@example.com";
    from = "test2@example.com";
    hostname = "example.com";
    selector = "rcpts:addr.in(test3@example.com)";
    header = {
      "Content-Transfer-Encoding" = "7bit";
      "Custom-Header" = true;
      "Mime-Version" = false;
    }
    request_header = {
      "Test" = "passed";
    }

    expression = 'user || from || hostname || selector:1 || header:mime_version || header:custom_header || header:content_transfer_encoding || request_header:test'
    apply {
      symbols_enabled {
        SIMPLE_VIRTUAL = 10.0;
      }
      symbols {
        EXPLICIT_VIRTUAL = 10.0
      }
    }
  }

  id_test_priority {
    priority = high;
    from = "user@test.com";
    apply {
      symbols_enabled {
        PRIORITY = 10.0;
      }
      symbols {
        PRIORITY_2 = 10.0
      }
    }
  }

  empty_symbols_enabled {
    ip = "5.5.5.5";
    apply {
      symbols_enabled = [];
    }
  }

  empty_groups_enabled {
    selector = "ip.in(\"5.5.5.6\")";
    apply {
      groups_enabled = [];
    }
  }

  external {
    disabled = true
    external_map = {
      map = {
        backend = "http://127.0.0.1:18080/settings";
        external = true;
        method = "body";
        encode = "json";
      }
      selector = "id('from');from('mime')";
    }
    register_symbols = {
      EXTERNAL_SETTINGS = { score = 1.0 }
    }
  }
}

classifier {
  backend = "sqlite3";
  statfile {
    spam = true;
    symbol = BAYES_SPAM;
    path = "/tmp/bayes.spam.sqlite3";
  }
  statfile {
    spam = false;
    symbol = BAYES_HAM;
    path = "/tmp/bayes.ham.sqlite3";
  }
  min_learns = 1;
  min_token_hits = 1;
}
