From: Vsevolod Stakhov Date: Tue, 18 Nov 2025 12:00:58 +0000 (+0000) Subject: [Minor] Migrate lualib/lua_selectors/common.lua to lua_shape X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=db4862661813c745271852f9af4943d901db3685;p=thirdparty%2Frspamd.git [Minor] Migrate lualib/lua_selectors/common.lua to lua_shape Replace tableshape with lua_shape in selectors common utilities. Changes: - ts.one_of { ... } → T.enum({ ... }) - :is_optional() → :optional() - Added documentation to schema fields Schema: digest_schema returns array with optional encoding format and optional hash algorithm for selector digest operations. --- diff --git a/lualib/lua_selectors/common.lua b/lualib/lua_selectors/common.lua index 7b2372da81..c375dd34e3 100644 --- a/lualib/lua_selectors/common.lua +++ b/lualib/lua_selectors/common.lua @@ -14,15 +14,17 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- -local ts = require("tableshape").types +local T = require "lua_shape.core" local exports = {} local cr_hash = require 'rspamd_cryptobox_hash' local blake2b_key = cr_hash.create_specific('blake2'):update('rspamd'):bin() local function digest_schema() - return { ts.one_of { 'hex', 'base32', 'bleach32', 'rbase32', 'base64' }:is_optional(), - ts.one_of { 'blake2', 'sha256', 'sha1', 'sha512', 'md5' }:is_optional() } + return { + T.enum({ 'hex', 'base32', 'bleach32', 'rbase32', 'base64' }):optional():doc({ summary = "Encoding format" }), + T.enum({ 'blake2', 'sha256', 'sha1', 'sha512', 'md5' }):optional():doc({ summary = "Hash algorithm" }) + } end exports.digest_schema = digest_schema