# HG changeset patch # User Kim Alvefur # Date 1639091652 -3600 # Node ID d66162e850cd491279a21457c3b1e5395b5a47d5 # Parent e8e0cb97c480fc7c683fbf401e62f10d8772e95d mod_export_skeletons: Generate ids based on log2 of the original length diff -r e8e0cb97c480 -r d66162e850cd mod_export_skeletons/README.md --- a/mod_export_skeletons/README.md Fri Dec 10 00:04:56 2021 +0100 +++ b/mod_export_skeletons/README.md Fri Dec 10 00:14:12 2021 +0100 @@ -35,7 +35,8 @@ Top level attributes are given special treatment since they carry protocol semantics. Notably the `@to` and `@from` JIDs are replaced by symbolic labels to convey what form (bare, full or host) they had. The -`@id` attribute is replaced with a string of the same length. +`@id` attribute is replaced with a string with the length based on log2 +of the original length. ## Example diff -r e8e0cb97c480 -r d66162e850cd mod_export_skeletons/mod_export_skeletons.lua --- a/mod_export_skeletons/mod_export_skeletons.lua Fri Dec 10 00:04:56 2021 +0100 +++ b/mod_export_skeletons/mod_export_skeletons.lua Fri Dec 10 00:14:12 2021 +0100 @@ -61,7 +61,7 @@ -- Normalize top level attributes clean.attr.type = item.attr.type; if clean.attr.type == nil and clean.name == "message" then clean.attr.type = "normal"; end - clean.attr.id = string.rep("x", #(item.attr.id or "")); -- worth rounding to nearest power of two or so? + clean.attr.id = string.rep("x", math.floor(math.log(1+#(item.attr.id or ""), 2))); clean.attr.from = classify_jid(item.attr.from); clean.attr.to = classify_jid(item.attr.to); print(clean);