This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 834
move everything not explicitly riot (or status) branded into matrix-react-sdk #1836
Merged
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
8ab8f76
move non-Riot-specific components over from riot-web
ara4n 178fb64
move notifications logic over from riot-web
ara4n 70f3804
move room directory logic over from riot-web
ara4n 79d3cca
move components' CSS to be in the same repo as their JS
ara4n cdb5d48
organise themes (even light & dark) in the SDK layer
ara4n 848403a
move default fonts over from riot-web
ara4n 8ce4df7
move non-Riot image resources over from riot-web
ara4n 8371774
move default ringtones over from riot-web
ara4n 7ae1b37
add notif UTs
ara4n cc904be
add NVL
ara4n 40a67ca
point imports at the new locations
ara4n 5d03eab
rethemedex
ara4n 5f3e444
fix theme paths
ara4n 0336d99
move VectorConferenceHandler over and use getUpdateCheckStatusEnum vi…
ara4n efe466e
move rageshake to sdk
ara4n 1376563
use new rageshake location
ara4n 610747e
fix paths and updateCheckStatusEnum
ara4n a30fdaf
copy all the i18n over from vector-web via copy-i18n.py
ara4n cb5ff40
fix missing i18n
ara4n faa1924
run gen-i18n to normalise en_EN and remove stuff still in vector-web
ara4n df564af
run prune-i18n to bring the translations back in line with normalised…
ara4n fe5e68d
fix tests
ara4n 4da804f
Merge branch 'develop' into matthew/fix_layering
ara4n 32dd7f9
merge vector-im/riot-web#5881 into matrix-react-sdk
ara4n f1f7673
ignore lint errors in stuff moved over from vector-web for now
ara4n 46f5c0d
finish merging vector-im/riot-web#5881 into matrix-react-sdk
ara4n eca5a96
add i18n which weren't correctly copied over from vector-web by copy-…
ara4n ce809e1
fix i18n thinko on createTrackedDialog
ara4n d91c7f5
Add comment about enum hijinks
ara4n 7b53e36
retheming commentary
ara4n 6d15634
fix missing NLs
ara4n f84573e
convert HomePage to ES6 and split out the vectory bit
ara4n 0571c59
move deps from vector-web to sdk; resolve version mismatches...
ara4n 92c98aa
displayName should be tracked as static
ara4n File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* | ||
Copyright 2015, 2016 OpenMarket Ltd | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
"use strict"; | ||
|
||
import Promise from 'bluebird'; | ||
var Matrix = require("matrix-js-sdk"); | ||
var Room = Matrix.Room; | ||
var CallHandler = require('./CallHandler'); | ||
|
||
// FIXME: this is Riot (Vector) specific code, but will be removed shortly when | ||
// we switch over to jitsi entirely for video conferencing. | ||
|
||
// FIXME: This currently forces Vector to try to hit the matrix.org AS for conferencing. | ||
// 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 | ||
// at docs/conferencing.md for more info. | ||
var USER_PREFIX = "fs_"; | ||
var DOMAIN = "matrix.org"; | ||
|
||
function ConferenceCall(matrixClient, groupChatRoomId) { | ||
this.client = matrixClient; | ||
this.groupRoomId = groupChatRoomId; | ||
this.confUserId = module.exports.getConferenceUserIdForRoom(this.groupRoomId); | ||
} | ||
|
||
ConferenceCall.prototype.setup = function() { | ||
var self = this; | ||
return this._joinConferenceUser().then(function() { | ||
return self._getConferenceUserRoom(); | ||
}).then(function(room) { | ||
// 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 | ||
// looking for a 1:1 room with this conf user ID!) | ||
var call = Matrix.createNewMatrixCall(self.client, room.roomId); | ||
call.confUserId = self.confUserId; | ||
call.groupRoomId = self.groupRoomId; | ||
return call; | ||
}); | ||
}; | ||
|
||
ConferenceCall.prototype._joinConferenceUser = function() { | ||
// Make sure the conference user is in the group chat room | ||
var groupRoom = this.client.getRoom(this.groupRoomId); | ||
if (!groupRoom) { | ||
return Promise.reject("Bad group room ID"); | ||
} | ||
var member = groupRoom.getMember(this.confUserId); | ||
if (member && member.membership === "join") { | ||
return Promise.resolve(); | ||
} | ||
return this.client.invite(this.groupRoomId, this.confUserId); | ||
}; | ||
|
||
ConferenceCall.prototype._getConferenceUserRoom = function() { | ||
// Use an existing 1:1 with the conference user; else make one | ||
var rooms = this.client.getRooms(); | ||
var confRoom = null; | ||
for (var i = 0; i < rooms.length; i++) { | ||
var confUser = rooms[i].getMember(this.confUserId); | ||
if (confUser && confUser.membership === "join" && | ||
rooms[i].getJoinedMembers().length === 2) { | ||
confRoom = rooms[i]; | ||
break; | ||
} | ||
} | ||
if (confRoom) { | ||
return Promise.resolve(confRoom); | ||
} | ||
return this.client.createRoom({ | ||
preset: "private_chat", | ||
invite: [this.confUserId] | ||
}).then(function(res) { | ||
return new Room(res.room_id); | ||
}); | ||
}; | ||
|
||
/** | ||
* Check if this user ID is in fact a conference bot. | ||
* @param {string} userId The user ID to check. | ||
* @return {boolean} True if it is a conference bot. | ||
*/ | ||
module.exports.isConferenceUser = function(userId) { | ||
if (userId.indexOf("@" + USER_PREFIX) !== 0) { | ||
return false; | ||
} | ||
var base64part = userId.split(":")[0].substring(1 + USER_PREFIX.length); | ||
if (base64part) { | ||
var decoded = new Buffer(base64part, "base64").toString(); | ||
// ! $STUFF : $STUFF | ||
return /^!.+:.+/.test(decoded); | ||
} | ||
return false; | ||
}; | ||
|
||
module.exports.getConferenceUserIdForRoom = function(roomId) { | ||
// abuse browserify's core node Buffer support (strip padding ='s) | ||
var base64RoomId = new Buffer(roomId).toString("base64").replace(/=/g, ""); | ||
return "@" + USER_PREFIX + base64RoomId + ":" + DOMAIN; | ||
}; | ||
|
||
module.exports.createNewMatrixCall = function(client, roomId) { | ||
var confCall = new ConferenceCall( | ||
client, roomId | ||
); | ||
return confCall.setup(); | ||
}; | ||
|
||
module.exports.getConferenceCallForRoom = function(roomId) { | ||
// search for a conference 1:1 call for this group chat room ID | ||
var activeCall = CallHandler.getAnyActiveCall(); | ||
if (activeCall && activeCall.confUserId) { | ||
var thisRoomConfUserId = module.exports.getConferenceUserIdForRoom( | ||
roomId | ||
); | ||
if (thisRoomConfUserId === activeCall.confUserId) { | ||
return activeCall; | ||
} | ||
} | ||
return null; | ||
}; | ||
|
||
module.exports.ConferenceCall = ConferenceCall; | ||
|
||
module.exports.slot = 'conference'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving a comment to explain why this is being done would be very useful.