|
|
|
@ -6,8 +6,10 @@ let bridge;
|
|
|
|
|
let tmiListener;
|
|
|
|
|
|
|
|
|
|
// permissions
|
|
|
|
|
const admins = process.env.ADMINS.split(',');
|
|
|
|
|
const users = process.env.USERS.split(',').concat(admins);
|
|
|
|
|
const admins = (process.env.ADMINS || '').split(',');
|
|
|
|
|
console.log('admins:', admins);
|
|
|
|
|
const users = (process.env.USERS || '').split(',').concat(admins);
|
|
|
|
|
console.log('users:', users);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -16,7 +18,11 @@ async function checkAdminPermissions(sender) {
|
|
|
|
|
return admins.includes(sender);
|
|
|
|
|
}
|
|
|
|
|
async function checkUserPermissions(sender) {
|
|
|
|
|
return users.includes(sender);
|
|
|
|
|
if(process.env.ALLOW_ALL_USERS === 'true' || users.includes(sender)) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
async function bridgeRoom(sender, matrixRoom, remoteRoom) {
|
|
|
|
|
await bridge.getRoomStore().linkRooms(matrixRoom, remoteRoom);
|
|
|
|
@ -115,9 +121,14 @@ new mx.Cli({
|
|
|
|
|
callback(reg);
|
|
|
|
|
},
|
|
|
|
|
run: async (port, config) => {
|
|
|
|
|
const homeserver = process.env.HOMESERVER || 'http://localhost:8008';
|
|
|
|
|
console.log('homeserver:', homeserver);
|
|
|
|
|
const domain = process.env.DOMAIN || 'localhost';
|
|
|
|
|
console.log('domain:', domain);
|
|
|
|
|
|
|
|
|
|
bridge = new mx.Bridge({
|
|
|
|
|
homeserverUrl: process.env.HOMESEVER || 'http://localhost:8008',
|
|
|
|
|
domain: process.env.DOMAIN || 'localhost',
|
|
|
|
|
homeserverUrl: homeserver,
|
|
|
|
|
domain: domain,
|
|
|
|
|
registration: 'matritch-registration.yaml',
|
|
|
|
|
controller: {
|
|
|
|
|
onUserQuery: queriedUser => {
|
|
|
|
|