Fix lint errors in VectorConferenceHandler.js
Signed-off-by: Aaron Raimist <aaron@raim.ist>
This commit is contained in:
parent
6c3acdff82
commit
a2944c9faa
1 changed files with 22 additions and 22 deletions
|
@ -17,9 +17,9 @@ limitations under the License.
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import Promise from 'bluebird';
|
import Promise from 'bluebird';
|
||||||
var Matrix = require("matrix-js-sdk");
|
const Matrix = require("matrix-js-sdk");
|
||||||
var Room = Matrix.Room;
|
const Room = Matrix.Room;
|
||||||
var CallHandler = require('./CallHandler');
|
const CallHandler = require('./CallHandler');
|
||||||
|
|
||||||
// FIXME: this is Riot (Vector) specific code, but will be removed shortly when
|
// FIXME: this is Riot (Vector) specific code, but will be removed shortly when
|
||||||
// we switch over to jitsi entirely for video conferencing.
|
// we switch over to jitsi entirely for video conferencing.
|
||||||
|
@ -28,8 +28,8 @@ var CallHandler = require('./CallHandler');
|
||||||
// This is bad because it prevents people running their own ASes from being used.
|
// This is bad because it prevents people running their own ASes from being used.
|
||||||
// This isn't permanent and will be customisable in the future: see the proposal
|
// This isn't permanent and will be customisable in the future: see the proposal
|
||||||
// at docs/conferencing.md for more info.
|
// at docs/conferencing.md for more info.
|
||||||
var USER_PREFIX = "fs_";
|
const USER_PREFIX = "fs_";
|
||||||
var DOMAIN = "matrix.org";
|
const DOMAIN = "matrix.org";
|
||||||
|
|
||||||
function ConferenceCall(matrixClient, groupChatRoomId) {
|
function ConferenceCall(matrixClient, groupChatRoomId) {
|
||||||
this.client = matrixClient;
|
this.client = matrixClient;
|
||||||
|
@ -38,14 +38,14 @@ function ConferenceCall(matrixClient, groupChatRoomId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ConferenceCall.prototype.setup = function() {
|
ConferenceCall.prototype.setup = function() {
|
||||||
var self = this;
|
const self = this;
|
||||||
return this._joinConferenceUser().then(function() {
|
return this._joinConferenceUser().then(function() {
|
||||||
return self._getConferenceUserRoom();
|
return self._getConferenceUserRoom();
|
||||||
}).then(function(room) {
|
}).then(function(room) {
|
||||||
// return a call for *this* room to be placed. We also tack on
|
// return a call for *this* room to be placed. We also tack on
|
||||||
// confUserId to speed up lookups (else we'd need to loop every room
|
// confUserId to speed up lookups (else we'd need to loop every room
|
||||||
// looking for a 1:1 room with this conf user ID!)
|
// looking for a 1:1 room with this conf user ID!)
|
||||||
var call = Matrix.createNewMatrixCall(self.client, room.roomId);
|
const call = Matrix.createNewMatrixCall(self.client, room.roomId);
|
||||||
call.confUserId = self.confUserId;
|
call.confUserId = self.confUserId;
|
||||||
call.groupRoomId = self.groupRoomId;
|
call.groupRoomId = self.groupRoomId;
|
||||||
return call;
|
return call;
|
||||||
|
@ -54,11 +54,11 @@ ConferenceCall.prototype.setup = function() {
|
||||||
|
|
||||||
ConferenceCall.prototype._joinConferenceUser = function() {
|
ConferenceCall.prototype._joinConferenceUser = function() {
|
||||||
// Make sure the conference user is in the group chat room
|
// Make sure the conference user is in the group chat room
|
||||||
var groupRoom = this.client.getRoom(this.groupRoomId);
|
const groupRoom = this.client.getRoom(this.groupRoomId);
|
||||||
if (!groupRoom) {
|
if (!groupRoom) {
|
||||||
return Promise.reject("Bad group room ID");
|
return Promise.reject("Bad group room ID");
|
||||||
}
|
}
|
||||||
var member = groupRoom.getMember(this.confUserId);
|
const member = groupRoom.getMember(this.confUserId);
|
||||||
if (member && member.membership === "join") {
|
if (member && member.membership === "join") {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
@ -67,10 +67,10 @@ ConferenceCall.prototype._joinConferenceUser = function() {
|
||||||
|
|
||||||
ConferenceCall.prototype._getConferenceUserRoom = function() {
|
ConferenceCall.prototype._getConferenceUserRoom = function() {
|
||||||
// Use an existing 1:1 with the conference user; else make one
|
// Use an existing 1:1 with the conference user; else make one
|
||||||
var rooms = this.client.getRooms();
|
const rooms = this.client.getRooms();
|
||||||
var confRoom = null;
|
let confRoom = null;
|
||||||
for (var i = 0; i < rooms.length; i++) {
|
for (let i = 0; i < rooms.length; i++) {
|
||||||
var confUser = rooms[i].getMember(this.confUserId);
|
const confUser = rooms[i].getMember(this.confUserId);
|
||||||
if (confUser && confUser.membership === "join" &&
|
if (confUser && confUser.membership === "join" &&
|
||||||
rooms[i].getJoinedMemberCount() === 2) {
|
rooms[i].getJoinedMemberCount() === 2) {
|
||||||
confRoom = rooms[i];
|
confRoom = rooms[i];
|
||||||
|
@ -82,7 +82,7 @@ ConferenceCall.prototype._getConferenceUserRoom = function() {
|
||||||
}
|
}
|
||||||
return this.client.createRoom({
|
return this.client.createRoom({
|
||||||
preset: "private_chat",
|
preset: "private_chat",
|
||||||
invite: [this.confUserId]
|
invite: [this.confUserId],
|
||||||
}).then(function(res) {
|
}).then(function(res) {
|
||||||
return new Room(res.room_id, null, client.getUserId());
|
return new Room(res.room_id, null, client.getUserId());
|
||||||
});
|
});
|
||||||
|
@ -97,9 +97,9 @@ module.exports.isConferenceUser = function(userId) {
|
||||||
if (userId.indexOf("@" + USER_PREFIX) !== 0) {
|
if (userId.indexOf("@" + USER_PREFIX) !== 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var base64part = userId.split(":")[0].substring(1 + USER_PREFIX.length);
|
const base64part = userId.split(":")[0].substring(1 + USER_PREFIX.length);
|
||||||
if (base64part) {
|
if (base64part) {
|
||||||
var decoded = new Buffer(base64part, "base64").toString();
|
const decoded = new Buffer(base64part, "base64").toString();
|
||||||
// ! $STUFF : $STUFF
|
// ! $STUFF : $STUFF
|
||||||
return /^!.+:.+/.test(decoded);
|
return /^!.+:.+/.test(decoded);
|
||||||
}
|
}
|
||||||
|
@ -108,23 +108,23 @@ module.exports.isConferenceUser = function(userId) {
|
||||||
|
|
||||||
module.exports.getConferenceUserIdForRoom = function(roomId) {
|
module.exports.getConferenceUserIdForRoom = function(roomId) {
|
||||||
// abuse browserify's core node Buffer support (strip padding ='s)
|
// abuse browserify's core node Buffer support (strip padding ='s)
|
||||||
var base64RoomId = new Buffer(roomId).toString("base64").replace(/=/g, "");
|
const base64RoomId = new Buffer(roomId).toString("base64").replace(/=/g, "");
|
||||||
return "@" + USER_PREFIX + base64RoomId + ":" + DOMAIN;
|
return "@" + USER_PREFIX + base64RoomId + ":" + DOMAIN;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.createNewMatrixCall = function(client, roomId) {
|
module.exports.createNewMatrixCall = function(client, roomId) {
|
||||||
var confCall = new ConferenceCall(
|
const confCall = new ConferenceCall(
|
||||||
client, roomId
|
client, roomId,
|
||||||
);
|
);
|
||||||
return confCall.setup();
|
return confCall.setup();
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.getConferenceCallForRoom = function(roomId) {
|
module.exports.getConferenceCallForRoom = function(roomId) {
|
||||||
// search for a conference 1:1 call for this group chat room ID
|
// search for a conference 1:1 call for this group chat room ID
|
||||||
var activeCall = CallHandler.getAnyActiveCall();
|
const activeCall = CallHandler.getAnyActiveCall();
|
||||||
if (activeCall && activeCall.confUserId) {
|
if (activeCall && activeCall.confUserId) {
|
||||||
var thisRoomConfUserId = module.exports.getConferenceUserIdForRoom(
|
const thisRoomConfUserId = module.exports.getConferenceUserIdForRoom(
|
||||||
roomId
|
roomId,
|
||||||
);
|
);
|
||||||
if (thisRoomConfUserId === activeCall.confUserId) {
|
if (thisRoomConfUserId === activeCall.confUserId) {
|
||||||
return activeCall;
|
return activeCall;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue