From 20fabeb0b56d7f3f0cd8d38569a23f3cea8af1d5 Mon Sep 17 00:00:00 2001 From: ZijianGuo Date: Mon, 7 Sep 2020 10:24:46 +0800 Subject: [PATCH] Fix the issue that the subscription api always returns unconfirmed Change-Id: Ie28aa35610d6fd0906eb20aec5d12e9b6f1a825d Closes-Bug: #1894520 Signed-off-by: ZijianGuo --- zaqar/storage/redis/models.py | 6 +++--- zaqar/storage/redis/subscriptions.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/zaqar/storage/redis/models.py b/zaqar/storage/redis/models.py index 666d2b741..1deda4dd8 100644 --- a/zaqar/storage/redis/models.py +++ b/zaqar/storage/redis/models.py @@ -133,7 +133,7 @@ class SubscriptionEnvelope(object): self.ttl = kwargs['ttl'] self.expires = kwargs.get('expires', float('inf')) self.options = kwargs['options'] - self.confirmed = kwargs.get('confirmed', 'True') + self.confirmed = kwargs.get('confirmed', 1) @staticmethod def from_redis(sid, client): @@ -154,7 +154,7 @@ class SubscriptionEnvelope(object): def to_basic(self, now): created = self.expires - self.ttl - is_confirmed = self.confirmed == str(True) + is_confirmed = bool(self.confirmed) basic_msg = { 'id': self.id, 'source': self.source.decode(), @@ -323,7 +323,7 @@ def _hmap_to_subenv_kwargs(hmap): 'ttl': int(hmap[b't']), 'expires': int(hmap[b'e']), 'options': _unpack(hmap[b'o']), - 'confirmed': hmap[b'c'] + 'confirmed': int(hmap[b'c']) } diff --git a/zaqar/storage/redis/subscriptions.py b/zaqar/storage/redis/subscriptions.py index b18a004f0..4679b4367 100644 --- a/zaqar/storage/redis/subscriptions.py +++ b/zaqar/storage/redis/subscriptions.py @@ -75,7 +75,7 @@ class SubscriptionController(base.Subscription): created = expires - ttl is_confirmed = 1 if len(record) == 6: - is_confirmed = record[5] + is_confirmed = int(record[5]) ret = { 'id': sid, 'source': record[0].decode(), @@ -83,7 +83,7 @@ class SubscriptionController(base.Subscription): 'ttl': ttl, 'age': now - created, 'options': self._unpacker(record[4]), - 'confirmed': is_confirmed.decode(), + 'confirmed': bool(is_confirmed), } marker_next['next'] = sid