default to claimType == 1 when it is missing for old claim protobufs

This commit is contained in:
Lex Berezhny 2019-04-07 21:53:03 -04:00
parent b1f813782a
commit 449a583286

View file

@ -49,7 +49,10 @@ def from_old_json_schema(claim, payload: bytes):
def from_types_v1(claim, payload: bytes): def from_types_v1(claim, payload: bytes):
old = OldClaimMessage() old = OldClaimMessage()
old.ParseFromString(payload) old.ParseFromString(payload)
if old.claimType == 1: if old.claimType == 2:
channel = claim.channel
channel.public_key_bytes = old.certificate.publicKey
else:
stream = claim.stream stream = claim.stream
stream.title = old.stream.metadata.title stream.title = old.stream.metadata.title
stream.description = old.stream.metadata.description stream.description = old.stream.metadata.description
@ -82,9 +85,4 @@ def from_types_v1(claim, payload: bytes):
claim.signing_channel_hash = sig.certificateId[::-1] claim.signing_channel_hash = sig.certificateId[::-1]
old.ClearField("publisherSignature") old.ClearField("publisherSignature")
claim.unsigned_payload = old.SerializeToString() claim.unsigned_payload = old.SerializeToString()
elif old.claimType == 2:
channel = claim.channel
channel.public_key_bytes = old.certificate.publicKey
else:
raise DecodeError('claimType must be 1 for Streams and 2 for Channel')
return claim return claim