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.

28 lines
532 B
JavaScript

"use strict";
function invertMapping(mapping) {
let invertedMapping = {};
for (let [ key, values ] of Object.entries(mapping)) {
for (let value of values) {
if (invertedMapping[value] == null) {
invertedMapping[value] = [];
}
invertedMapping[value].push(key);
}
}
return invertedMapping;
}
module.exports = function mapDirectEvent(event, _context) {
// Context: account data
return {
type: "directMessageRoomsChanged",
userToRooms: event.content,
roomToUsers: invertMapping(event.content)
};
};