From: Vsevolod Stakhov Date: Tue, 18 Nov 2025 10:01:44 +0000 (+0000) Subject: [Minor] Migrate src/plugins/lua/contextal.lua to lua_shape X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d4516e4a963686c5e64f7c223abffd5c0a8bf1c4;p=thirdparty%2Frspamd.git [Minor] Migrate src/plugins/lua/contextal.lua to lua_shape Replace tableshape with lua_shape in Contextal plugin. Changes: - Uses lua_redis.enrich_schema() which returns lua_shape with mixins - ts.string, ts.boolean, ts.number → T.string(), T.boolean(), T.number() - ts.array_of(x) → T.array(x) - :is_optional() → :optional() - Added comprehensive documentation to all fields Schema: config_schema with Redis common fields plus Contextal-specific settings for API URLs, caching, timeouts, and custom actions. --- diff --git a/src/plugins/lua/contextal.lua b/src/plugins/lua/contextal.lua index b613733890..22ef6476c6 100644 --- a/src/plugins/lua/contextal.lua +++ b/src/plugins/lua/contextal.lua @@ -32,7 +32,7 @@ local redis_cache = require "lua_cache" local rspamd_http = require "rspamd_http" local rspamd_logger = require "rspamd_logger" local rspamd_util = require "rspamd_util" -local ts = require("tableshape").types +local T = require "lua_shape.core" local ucl = require "ucl" local cache_context, redis_params @@ -46,23 +46,23 @@ local contextal_actions = { } local config_schema = lua_redis.enrich_schema { - action_symbol_prefix = ts.string:is_optional(), - base_url = ts.string:is_optional(), - cache_prefix = ts.string:is_optional(), - cache_timeout = ts.number:is_optional(), - cache_ttl = ts.number:is_optional(), - custom_actions = ts.array_of(ts.string):is_optional(), - defer_if_no_result = ts.boolean:is_optional(), - defer_message = ts.string:is_optional(), - enabled = ts.boolean:is_optional(), - http_timeout = ts.number:is_optional(), - request_ttl = ts.number:is_optional(), - submission_symbol = ts.string:is_optional(), + action_symbol_prefix = T.string():optional():doc({ summary = "Prefix for action symbols" }), + base_url = T.string():optional():doc({ summary = "Base URL for Contextal API" }), + cache_prefix = T.string():optional():doc({ summary = "Redis cache key prefix" }), + cache_timeout = T.number():optional():doc({ summary = "Cache lookup timeout (seconds)" }), + cache_ttl = T.number():optional():doc({ summary = "Cache TTL (seconds)" }), + custom_actions = T.array(T.string()):optional():doc({ summary = "Additional custom actions" }), + defer_if_no_result = T.boolean():optional():doc({ summary = "Defer message if no result yet" }), + defer_message = T.string():optional():doc({ summary = "Defer message text" }), + enabled = T.boolean():optional():doc({ summary = "Enable the plugin" }), + http_timeout = T.number():optional():doc({ summary = "HTTP request timeout (seconds)" }), + request_ttl = T.number():optional():doc({ summary = "Result polling timeout (seconds)" }), + submission_symbol = T.string():optional():doc({ summary = "Submission symbol name" }), -- staged timeouts - connect_timeout = ts.number:is_optional(), - ssl_timeout = ts.number:is_optional(), - write_timeout = ts.number:is_optional(), - read_timeout = ts.number:is_optional(), + connect_timeout = T.number():optional():doc({ summary = "Connection timeout (seconds)" }), + ssl_timeout = T.number():optional():doc({ summary = "SSL negotiation timeout (seconds)" }), + write_timeout = T.number():optional():doc({ summary = "Write timeout (seconds)" }), + read_timeout = T.number():optional():doc({ summary = "Read timeout (seconds)" }), } local settings = {