From 7551959a4c269b0acde6a6a897a91bcbaab8a495 Mon Sep 17 00:00:00 2001 From: Christina Date: Wed, 22 Nov 2023 16:15:52 +0100 Subject: [PATCH] filter out unsupported policies --- src/lavinmq/policy.cr | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lavinmq/policy.cr b/src/lavinmq/policy.cr index 7ffb073880..0a8e00a9a5 100644 --- a/src/lavinmq/policy.cr +++ b/src/lavinmq/policy.cr @@ -10,6 +10,10 @@ module LavinMQ end class Policy + SUPPORTED_POLICIES = ["max-length", "max-length-bytes", "message-ttl", "expires", "overflow", + "dead-letter-exchange", "dead-letter-routing-key", "federation-upstream", + "federation-upstream-set", "delivery-limit", "max-age", + "alternate-exchange", "delayed-message"] enum Target All Queues @@ -67,15 +71,15 @@ module LavinMQ merged[k] = v end end - merged + merged.select { |key, _| SUPPORTED_POLICIES.includes?(key) } end def self.merge_definitions(p1 : Nil, p2 : Policy) : Hash(String, JSON::Any) - p2.definition + p2.definition.select { |key, _| SUPPORTED_POLICIES.includes?(key) } end def self.merge_definitions(p1 : Policy, p2 : Nil) : Hash(String, JSON::Any) - p1.definition + p1.definition.select { |key, _| SUPPORTED_POLICIES.includes?(key) } end def self.merge_definitions(p1 : Nil, p2 : Nil) : Hash(String, JSON::Any)