envelopeTypeToCiphertextType: Handle all envelope types
Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
parent
9f42aa3e72
commit
dd12c6f599
|
@ -2792,14 +2792,35 @@ export default class MessageReceiver
|
||||||
}
|
}
|
||||||
|
|
||||||
function envelopeTypeToCiphertextType(type: number | undefined): number {
|
function envelopeTypeToCiphertextType(type: number | undefined): number {
|
||||||
if (type === Proto.Envelope.Type.CIPHERTEXT) {
|
const { Type } = Proto.Envelope;
|
||||||
|
|
||||||
|
if (type === Type.CIPHERTEXT) {
|
||||||
return CiphertextMessageType.Whisper;
|
return CiphertextMessageType.Whisper;
|
||||||
}
|
}
|
||||||
if (type === Proto.Envelope.Type.PLAINTEXT_CONTENT) {
|
if (type === Type.KEY_EXCHANGE) {
|
||||||
|
throw new Error(
|
||||||
|
'envelopeTypeToCiphertextType: Cannot process KEY_EXCHANGE messages'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (type === Type.PLAINTEXT_CONTENT) {
|
||||||
return CiphertextMessageType.Plaintext;
|
return CiphertextMessageType.Plaintext;
|
||||||
}
|
}
|
||||||
if (type === Proto.Envelope.Type.PREKEY_BUNDLE) {
|
if (type === Type.PREKEY_BUNDLE) {
|
||||||
return CiphertextMessageType.PreKey;
|
return CiphertextMessageType.PreKey;
|
||||||
}
|
}
|
||||||
|
if (type === Type.RECEIPT) {
|
||||||
|
return CiphertextMessageType.Plaintext;
|
||||||
|
}
|
||||||
|
if (type === Type.UNIDENTIFIED_SENDER) {
|
||||||
|
throw new Error(
|
||||||
|
'envelopeTypeToCiphertextType: Cannot process UNIDENTIFIED_SENDER messages'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (type === Type.UNKNOWN) {
|
||||||
|
throw new Error(
|
||||||
|
'envelopeTypeToCiphertextType: Cannot process UNKNOWN messages'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
throw new Error(`envelopeTypeToCiphertextType: Unknown type ${type}`);
|
throw new Error(`envelopeTypeToCiphertextType: Unknown type ${type}`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue