Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
/*Codes_SRS_NODE_IOTHUB_AMQPMSG_16_006: [The `toMessage` method shall set the `Message.expiryTimeUtc` property to the `AmqpMessage.absolute_expiry_time` value if it is present.]*/
if (amqpMessage.absolute_expiry_time) {
msg.expiryTimeUtc = amqpMessage.absolute_expiry_time;
}
//
// The rhea library will de-serialize an encoded uuid (0x98) as a 16 byte buffer.
// Since common messages should only have type string it is safe to decode
// these as strings.
//
/*Codes_SRS_NODE_IOTHUB_AMQPMSG_16_004: [The `toMessage` method shall set the `Message.messageId` property to the `AmqpMessage.message_id` value if it is present.]*/
if (amqpMessage.message_id) {
if (((amqpMessage.message_id as any) instanceof Buffer) && (amqpMessage.message_id.length === 16)) {
msg.messageId = rheaUuidToString(amqpMessage.message_id as any);
} else {
msg.messageId = amqpMessage.message_id;
}
}
/*Codes_SRS_NODE_IOTHUB_AMQPMSG_16_003: [The `toMessage` method shall set the `Message.correlationId` property to the `AmqpMessage.correlation_id` value if it is present.]*/
if (amqpMessage.correlation_id) {
if (((amqpMessage.correlation_id as any) instanceof Buffer) && (amqpMessage.correlation_id.length === 16)) {
msg.correlationId = rheaUuidToString(amqpMessage.correlation_id as any);
} else {
msg.correlationId = amqpMessage.correlation_id;
}
}
/*Codes_SRS_NODE_IOTHUB_AMQPMSG_16_016: [The `toMessage` method shall set the `Message.contentType` property to the `AmqpMessage.content_type` value if it is present. ]*/
if (amqpMessage.content_type) {
// Since common messages should only have type string it is safe to decode
// these as strings.
//
/*Codes_SRS_NODE_IOTHUB_AMQPMSG_16_004: [The `toMessage` method shall set the `Message.messageId` property to the `AmqpMessage.message_id` value if it is present.]*/
if (amqpMessage.message_id) {
if (((amqpMessage.message_id as any) instanceof Buffer) && (amqpMessage.message_id.length === 16)) {
msg.messageId = rheaUuidToString(amqpMessage.message_id as any);
} else {
msg.messageId = amqpMessage.message_id;
}
}
/*Codes_SRS_NODE_IOTHUB_AMQPMSG_16_003: [The `toMessage` method shall set the `Message.correlationId` property to the `AmqpMessage.correlation_id` value if it is present.]*/
if (amqpMessage.correlation_id) {
if (((amqpMessage.correlation_id as any) instanceof Buffer) && (amqpMessage.correlation_id.length === 16)) {
msg.correlationId = rheaUuidToString(amqpMessage.correlation_id as any);
} else {
msg.correlationId = amqpMessage.correlation_id;
}
}
/*Codes_SRS_NODE_IOTHUB_AMQPMSG_16_016: [The `toMessage` method shall set the `Message.contentType` property to the `AmqpMessage.content_type` value if it is present. ]*/
if (amqpMessage.content_type) {
msg.contentType = amqpMessage.content_type;
}
/*Codes_SRS_NODE_IOTHUB_AMQPMSG_16_017: [The `toMessage` method shall set the `Message.contentEncoding` property to the `AmqpMessage.content_encoding` value if it is present. ]*/
if (amqpMessage.content_encoding) {
msg.contentEncoding = amqpMessage.content_encoding;
}
/*Codes_SRS_NODE_IOTHUB_AMQPMSG_16_007: [The `toMessage` method shall convert the user-defined `AmqpMessage.applicationProperties` to a `Properties` collection stored in `Message.properties`.]*/