Fix the issue that the subscription api always returns unconfirmed

Change-Id: Ie28aa35610d6fd0906eb20aec5d12e9b6f1a825d
Closes-Bug: #1894520
Signed-off-by: ZijianGuo <guozijn@gmail.com>
This commit is contained in:
ZijianGuo 2020-09-07 10:24:46 +08:00
parent 60cd2da34f
commit 20fabeb0b5
2 changed files with 5 additions and 5 deletions

View File

@ -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'])
}

View File

@ -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