prettyprint conference joins and parts properly

This commit is contained in:
Matthew Hodgson 2016-03-05 02:30:18 +00:00
parent 05a3dab528
commit 0d841551a0
2 changed files with 40 additions and 3 deletions

View File

@ -327,6 +327,10 @@ var callHandler = {
setConferenceHandler: function(confHandler) {
ConferenceHandler = confHandler;
},
getConferenceHandler: function() {
return ConferenceHandler;
}
};
// Only things in here which actually need to be global are the

View File

@ -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 CallHandler = require("./CallHandler");
function textForMemberEvent(ev) {
// XXX: SYJS-16 "sender is sometimes null for join messages"
var senderName = ev.sender ? ev.sender.name : ev.getSender();
var targetName = ev.target ? ev.target.name : ev.getStateKey();
var ConferenceHandler = CallHandler.getConferenceHandler();
var reason = ev.getContent().reason ? (
" Reason: " + ev.getContent().reason
) : "";
@ -18,7 +36,12 @@ function textForMemberEvent(ev) {
".";
}
else {
return senderName + " invited " + targetName + ".";
if (ConferenceHandler && ConferenceHandler.isConferenceUser(ev.getStateKey())) {
return senderName + " requested a VoIP conference";
}
else {
return senderName + " invited " + targetName + ".";
}
}
case 'ban':
return senderName + " banned " + targetName + "." + reason;
@ -41,12 +64,22 @@ function textForMemberEvent(ev) {
}
} else {
if (!ev.target) console.warn("Join message has no target! -- " + ev.getContent().state_key);
return targetName + " joined the room.";
if (ConferenceHandler && ConferenceHandler.isConferenceUser(ev.getStateKey())) {
return "VoIP conference started";
}
else {
return targetName + " joined the room.";
}
}
return '';
case 'leave':
if (ev.getSender() === ev.getStateKey()) {
return targetName + " left the room.";
if (ConferenceHandler && ConferenceHandler.isConferenceUser(ev.getStateKey())) {
return "VoIP conference finished";
}
else {
return targetName + " left the room.";
}
}
else if (ev.getPrevContent().membership === "ban") {
return senderName + " unbanned " + targetName + ".";