add ALLOW_ALL_USERS env variable (and better logging)

master
lub 5 years ago
parent db709a342d
commit 89c5d71b50

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

Loading…
Cancel
Save