Gitter migration: Setup redirects (rollout pt. 3)
[gitter.git] / shared / backend-utils.js
blob093412b2f6f81ddceaa8e729a7db9efe76d41244
1 'use strict';
3 // Accepts a serialized room or backbone model for a room
4 function getBackendForRoom(room) {
5 let backend = (room.get && room.get('backend')) || room.backend;
6 // When the room security descriptor is referencing the group, use that security descriptor instead
7 if (backend && backend.type === 'GROUP') {
8 const group = (room.get && room.get('group')) || room.group;
9 backend = group.backedBy;
12 return backend;
15 function getLinkPathCond(type, object) {
16 var backend = (object.get && object.get('backend')) || object.backend;
17 if (!backend) return;
18 if (backend.type === type) return backend.linkPath;
21 module.exports = {
22 getBackendForRoom,
23 getLinkPathCond