clear releaseTime when not set

This commit is contained in:
Victor Shyba 2019-01-22 20:55:35 -03:00
parent 567c23e10f
commit 0d90b82287
2 changed files with 9 additions and 1 deletions

View file

@ -14,6 +14,10 @@ def encode_fields(claim_dictionary, detached_signature: Signature):
claim_value = claim_dictionary[claim_type]
if claim_type == CLAIM_TYPES[STREAM_TYPE]:
claim_value['source']['source'] = binascii.hexlify(claim_value['source']['source']).decode()
if 'releaseTime' in claim_value['metadata']:
release_time = int(claim_value['metadata'].pop('releaseTime'))
if release_time != 0:
claim_value['metadata']['releaseTime'] = release_time
if 'fee' in claim_value['metadata']:
try:
address = encode_address(claim_value['metadata']['fee']['address'])

View file

@ -14,4 +14,8 @@ class Metadata(Schema):
if 'fee' in _metadata:
fee_pb = Fee.load(_metadata.pop('fee'))
_message_pb.fee.CopyFrom(fee_pb)
return cls._load(_metadata, _message_pb)
_message_pb.releaseTime = int(_metadata.get('releaseTime', 0))
built_message = cls._load(_metadata, _message_pb)
if built_message.releaseTime == 0:
built_message.ClearField('releaseTime')
return built_message