Merge pull request #198 from matrix-org/matthew/confjoinparts
prettyprint conference joins and parts properly
This commit is contained in:
commit
22bd0f9aa0
2 changed files with 40 additions and 3 deletions
|
@ -327,6 +327,10 @@ var callHandler = {
|
||||||
|
|
||||||
setConferenceHandler: function(confHandler) {
|
setConferenceHandler: function(confHandler) {
|
||||||
ConferenceHandler = confHandler;
|
ConferenceHandler = confHandler;
|
||||||
|
},
|
||||||
|
|
||||||
|
getConferenceHandler: function() {
|
||||||
|
return ConferenceHandler;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// Only things in here which actually need to be global are the
|
// Only things in here which actually need to be global are the
|
||||||
|
|
|
@ -1,9 +1,27 @@
|
||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
var MatrixClientPeg = require("./MatrixClientPeg");
|
var MatrixClientPeg = require("./MatrixClientPeg");
|
||||||
|
var CallHandler = require("./CallHandler");
|
||||||
|
|
||||||
function textForMemberEvent(ev) {
|
function textForMemberEvent(ev) {
|
||||||
// XXX: SYJS-16 "sender is sometimes null for join messages"
|
// XXX: SYJS-16 "sender is sometimes null for join messages"
|
||||||
var senderName = ev.sender ? ev.sender.name : ev.getSender();
|
var senderName = ev.sender ? ev.sender.name : ev.getSender();
|
||||||
var targetName = ev.target ? ev.target.name : ev.getStateKey();
|
var targetName = ev.target ? ev.target.name : ev.getStateKey();
|
||||||
|
var ConferenceHandler = CallHandler.getConferenceHandler();
|
||||||
var reason = ev.getContent().reason ? (
|
var reason = ev.getContent().reason ? (
|
||||||
" Reason: " + ev.getContent().reason
|
" Reason: " + ev.getContent().reason
|
||||||
) : "";
|
) : "";
|
||||||
|
@ -18,9 +36,14 @@ function textForMemberEvent(ev) {
|
||||||
return targetName + " accepted an invitation.";
|
return targetName + " accepted an invitation.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if (ConferenceHandler && ConferenceHandler.isConferenceUser(ev.getStateKey())) {
|
||||||
|
return senderName + " requested a VoIP conference";
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return senderName + " invited " + targetName + ".";
|
return senderName + " invited " + targetName + ".";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
case 'ban':
|
case 'ban':
|
||||||
return senderName + " banned " + targetName + "." + reason;
|
return senderName + " banned " + targetName + "." + reason;
|
||||||
case 'join':
|
case 'join':
|
||||||
|
@ -42,13 +65,23 @@ function textForMemberEvent(ev) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!ev.target) console.warn("Join message has no target! -- " + ev.getContent().state_key);
|
if (!ev.target) console.warn("Join message has no target! -- " + ev.getContent().state_key);
|
||||||
|
if (ConferenceHandler && ConferenceHandler.isConferenceUser(ev.getStateKey())) {
|
||||||
|
return "VoIP conference started";
|
||||||
|
}
|
||||||
|
else {
|
||||||
return targetName + " joined the room.";
|
return targetName + " joined the room.";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return '';
|
return '';
|
||||||
case 'leave':
|
case 'leave':
|
||||||
if (ev.getSender() === ev.getStateKey()) {
|
if (ev.getSender() === ev.getStateKey()) {
|
||||||
|
if (ConferenceHandler && ConferenceHandler.isConferenceUser(ev.getStateKey())) {
|
||||||
|
return "VoIP conference finished";
|
||||||
|
}
|
||||||
|
else {
|
||||||
return targetName + " left the room.";
|
return targetName + " left the room.";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (ev.getPrevContent().membership === "ban") {
|
else if (ev.getPrevContent().membership === "ban") {
|
||||||
return senderName + " unbanned " + targetName + ".";
|
return senderName + " unbanned " + targetName + ".";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue