"use strict";

const addCommonFields = require("../event-add-common-fields");
const normalizeEncryptionAlgorithmName = require("../normalize-encryption-algorithm-name");

module.exports = function mapEncryptionEvent(event, _context) {
	return addCommonFields(event, {
		type: "encryptionEnabled",
		sender: event.sender,
		algorithm: normalizeEncryptionAlgorithmName(event.content.algorithm),
		encryptionConfiguration: {
			rotateSessionAfterTime: event.content.rotation_period_ms,
			rotateSessionAfterMessages: event.content.rotation_period_msgs
		}
	});
};
