You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1004 B
JavaScript
30 lines
1004 B
JavaScript
"use strict";
|
|
|
|
const unreachable = require("@joepie91/unreachable");
|
|
|
|
const normalizeEncryptionAlgorithmName = require("../normalize-encryption-algorithm-name");
|
|
|
|
module.exports = function mapKeyRequestEvent(event, _context) {
|
|
if (event.content.action === "request") {
|
|
return {
|
|
type: "keyRequested",
|
|
user: event.sender,
|
|
deviceID: event.content.requesting_device_id,
|
|
requestID: event.content.request_id,
|
|
algorithm: normalizeEncryptionAlgorithmName(event.content.body.algorithm),
|
|
senderKey: event.content.body.sender_key, // TODO: Better name for senderKey? also elsewhere
|
|
roomID: event.content.body.room_id,
|
|
sessionID: event.content.body.session_id
|
|
};
|
|
} else if (event.content.action === "request_cancellation") {
|
|
return {
|
|
type: "keyRequestCancelled",
|
|
user: event.sender,
|
|
deviceID: event.content.requesting_device_id,
|
|
requestID: event.content.request_id,
|
|
};
|
|
} else {
|
|
unreachable(`Unrecognized action '${event.content.action}' for room_key_request`);
|
|
}
|
|
};
|