diff --git a/changedetectionio/conditions/__init__.py b/changedetectionio/conditions/__init__.py index 959f5abd..aa005859 100644 --- a/changedetectionio/conditions/__init__.py +++ b/changedetectionio/conditions/__init__.py @@ -116,8 +116,7 @@ def execute_ruleset_against_all_plugins(current_watch_uuid: str, application_dat if not jsonLogic(logic=ruleset, data=EXECUTE_DATA, operations=CUSTOM_OPERATIONS): result = False - return result - + return {'executed_data': EXECUTE_DATA, 'result': result} # Load plugins dynamically for plugin in plugin_manager.get_plugins(): diff --git a/changedetectionio/conditions/blueprint.py b/changedetectionio/conditions/blueprint.py index 5bd3bd39..9d8766e9 100644 --- a/changedetectionio/conditions/blueprint.py +++ b/changedetectionio/conditions/blueprint.py @@ -67,7 +67,8 @@ def construct_blueprint(datastore): return jsonify({ 'status': 'success', - 'result': result, + 'result': result.get('result'), + 'data': result.get('executed_data'), 'message': 'Condition passes' if result else 'Condition does not pass' }) diff --git a/changedetectionio/processors/text_json_diff/processor.py b/changedetectionio/processors/text_json_diff/processor.py index faeab5d2..5513fd04 100644 --- a/changedetectionio/processors/text_json_diff/processor.py +++ b/changedetectionio/processors/text_json_diff/processor.py @@ -334,12 +334,14 @@ class perform_site_check(difference_detection_processor): # And check if 'conditions' will let this pass through if watch.get('conditions') and watch.get('conditions_match_logic'): - if not execute_ruleset_against_all_plugins(current_watch_uuid=watch.get('uuid'), - application_datastruct=self.datastore.data, - ephemeral_data={ - 'text': stripped_text_from_html - } - ): + conditions_result = execute_ruleset_against_all_plugins(current_watch_uuid=watch.get('uuid'), + application_datastruct=self.datastore.data, + ephemeral_data={ + 'text': stripped_text_from_html + } + ) + + if not conditions_result.get('result'): # Conditions say "Condition not met" so we block it. blocked = True diff --git a/changedetectionio/static/js/conditions.js b/changedetectionio/static/js/conditions.js index 8c627d63..a33fafc6 100644 --- a/changedetectionio/static/js/conditions.js +++ b/changedetectionio/static/js/conditions.js @@ -52,7 +52,7 @@ $(document).ready(function () { // Create a rule object - const rule = { + let rule = { field: field, operator: operator, value: value @@ -96,6 +96,10 @@ $(document).ready(function () { contentType: false, // Let the browser set the correct content type success: function (response) { if (response.status === "success") { + if(rule['field'] !== "page_filtered_text") { + // A little debug helper for the user + $('#verify-state-text').text(`${rule['field']} was value "${response.data[rule['field']]}"`) + } if (response.result) { alert("✅ Condition PASSES verification against current snapshot!"); } else { diff --git a/changedetectionio/templates/edit.html b/changedetectionio/templates/edit.html index 3bda8e3f..ca60e286 100644 --- a/changedetectionio/templates/edit.html +++ b/changedetectionio/templates/edit.html @@ -305,8 +305,8 @@ Math: {{ 1 + 1 }}") }} {{ render_field(form.conditions_match_logic) }} {{ render_fieldlist_of_formfields_as_table(form.conditions) }}
-
- Use the verify (✓) button to test if a condition passes against the current snapshot.

+ +

Use the verify (✓) button to test if a condition passes against the current snapshot.

Did you know that conditions can be extended with your own custom plugin? tutorials coming soon!
diff --git a/changedetectionio/tests/unit/test_conditions.py b/changedetectionio/tests/unit/test_conditions.py index 72d8c56b..0de147cf 100644 --- a/changedetectionio/tests/unit/test_conditions.py +++ b/changedetectionio/tests/unit/test_conditions.py @@ -75,7 +75,7 @@ class TestTriggerConditions(unittest.TestCase): ephemeral_data={'text': "I saw 500 people at a rock show"}) # @todo - now we can test that 'Extract number' increased more than X since last time - self.assertTrue(result) + self.assertTrue(result.get('result')) if __name__ == '__main__':