Merge remote-tracking branch 'origin/develop' into merge_pdu_event_objects

This commit is contained in:
Mark Haines 2014-11-17 10:21:51 +00:00
commit 1d3ef8734c
18 changed files with 481 additions and 249 deletions

1
synctl Symbolic link
View File

@ -0,0 +1 @@
./synapse/app/synctl.py

View File

@ -699,7 +699,7 @@ textarea, input {
vertical-align: middle; vertical-align: middle;
*/ */
display: inline-block; display: inline-block;
max-width: 90%; max-width: 80%;
padding-left: 1em; padding-left: 1em;
padding-right: 1em; padding-right: 1em;
padding-top: 2px; padding-top: 2px;
@ -721,6 +721,7 @@ textarea, input {
text-align: right; text-align: right;
} }
/*
.text.emote .bubble, .text.emote .bubble,
.text.membership .bubble, .text.membership .bubble,
.mine .text.emote .bubble, .mine .text.emote .bubble,
@ -729,6 +730,7 @@ textarea, input {
background-color: transparent ! important; background-color: transparent ! important;
border: 0px ! important; border: 0px ! important;
} }
*/
.mine .text .bubble { .mine .text .bubble {
/* /*

View File

@ -25,7 +25,8 @@ angular.module('mFileInput', [])
return { return {
restrict: 'A', restrict: 'A',
transclude: 'true', transclude: 'true',
template: '<div ng-transclude></div><input ng-hide="true" type="file" accept="image/*"/>', // FIXME: add back in accept="image/*" when needed - e.g. for avatars
template: '<div ng-transclude></div><input ng-hide="true" type="file"/>',
scope: { scope: {
selectedFile: '=mFileInput' selectedFile: '=mFileInput'
}, },

View File

@ -47,28 +47,29 @@ angular.module('mFileUpload', ['matrixService', 'mUtilities'])
}; };
/* /*
* Upload an image file plus generate a thumbnail of it and upload it so that * Upload an file plus generate a thumbnail of it (if possible) and upload it so that
* we will have all information to fulfill an image message request data. * we will have all information to fulfill an file/image message request
* @param {File} imageFile the imageFile to send * @param {File} file the file to send
* @param {Integer} thumbnailSize the max side size of the thumbnail to create * @param {Integer} thumbnailSize the max side size of the thumbnail to create
* @returns {promise} A promise that will be resolved by a image message object * @returns {promise} A promise that will be resolved by a message object
* ready to be send with the Matrix API * ready to be send with the Matrix API
*/ */
this.uploadImageAndThumbnail = function(imageFile, thumbnailSize) { this.uploadFileAndThumbnail = function(file, thumbnailSize) {
var self = this; var self = this;
var deferred = $q.defer(); var deferred = $q.defer();
console.log("uploadImageAndThumbnail " + imageFile.name + " - thumbnailSize: " + thumbnailSize); console.log("uploadFileAndThumbnail " + file.name + " - thumbnailSize: " + thumbnailSize);
// The message structure that will be returned in the promise // The message structure that will be returned in the promise will look something like:
var imageMessage = { var message = {
/*
msgtype: "m.image", msgtype: "m.image",
url: undefined, url: undefined,
body: "Image", body: "Image",
info: { info: {
size: undefined, size: undefined,
w: undefined, w: undefined,
h: undefined, h: undefined,
mimetype: undefined mimetype: undefined
}, },
thumbnail_url: undefined, thumbnail_url: undefined,
@ -78,101 +79,128 @@ angular.module('mFileUpload', ['matrixService', 'mUtilities'])
h: undefined, h: undefined,
mimetype: undefined mimetype: undefined
} }
*/
}; };
// First, get the image size if (file.type.indexOf("image/") === 0) {
mUtilities.getImageSize(imageFile).then( // it's an image - try to do clientside thumbnailing.
function(size) { mUtilities.getImageSize(file).then(
console.log("image size: " + JSON.stringify(size)); function(size) {
console.log("image size: " + JSON.stringify(size));
// The final operation: send imageFile // The final operation: send file
var uploadImage = function() { var uploadImage = function() {
self.uploadFile(imageFile).then( self.uploadFile(file).then(
function(url) { function(url) {
// Update message metadata // Update message metadata
imageMessage.url = url; message.url = url;
imageMessage.info = { message.msgtype = "m.image";
size: imageFile.size, message.body = file.name;
w: size.width, message.info = {
h: size.height, size: file.size,
mimetype: imageFile.type w: size.width,
}; h: size.height,
mimetype: file.type
};
// If there is no thumbnail (because the original image is smaller than thumbnailSize), // If there is no thumbnail (because the original image is smaller than thumbnailSize),
// reuse the original image info for thumbnail data // reuse the original image info for thumbnail data
if (!imageMessage.thumbnail_url) { if (!message.thumbnail_url) {
imageMessage.thumbnail_url = imageMessage.url; message.thumbnail_url = message.url;
imageMessage.thumbnail_info = imageMessage.info; message.thumbnail_info = message.info;
}
// We are done
deferred.resolve(imageMessage);
},
function(error) {
console.log(" -> Can't upload image");
deferred.reject(error);
}
);
};
// Create a thumbnail if the image size exceeds thumbnailSize
if (Math.max(size.width, size.height) > thumbnailSize) {
console.log(" Creating thumbnail...");
mUtilities.resizeImage(imageFile, thumbnailSize).then(
function(thumbnailBlob) {
// Get its size
mUtilities.getImageSize(thumbnailBlob).then(
function(thumbnailSize) {
console.log(" -> Thumbnail size: " + JSON.stringify(thumbnailSize));
// Upload it to the server
self.uploadFile(thumbnailBlob).then(
function(thumbnailUrl) {
// Update image message data
imageMessage.thumbnail_url = thumbnailUrl;
imageMessage.thumbnail_info = {
size: thumbnailBlob.size,
w: thumbnailSize.width,
h: thumbnailSize.height,
mimetype: thumbnailBlob.type
};
// Then, upload the original image
uploadImage();
},
function(error) {
console.log(" -> Can't upload thumbnail");
deferred.reject(error);
}
);
},
function(error) {
console.log(" -> Failed to get thumbnail size");
deferred.reject(error);
} }
);
}, // We are done
function(error) { deferred.resolve(message);
console.log(" -> Failed to create thumbnail: " + error); },
deferred.reject(error); function(error) {
} console.log(" -> Can't upload image");
); deferred.reject(error);
} }
else { );
// No need of thumbnail };
console.log(" Thumbnail is not required");
uploadImage();
}
}, // Create a thumbnail if the image size exceeds thumbnailSize
function(error) { if (Math.max(size.width, size.height) > thumbnailSize) {
console.log(" -> Failed to get image size"); console.log(" Creating thumbnail...");
deferred.reject(error); mUtilities.resizeImage(file, thumbnailSize).then(
} function(thumbnailBlob) {
);
// Get its size
mUtilities.getImageSize(thumbnailBlob).then(
function(thumbnailSize) {
console.log(" -> Thumbnail size: " + JSON.stringify(thumbnailSize));
// Upload it to the server
self.uploadFile(thumbnailBlob).then(
function(thumbnailUrl) {
// Update image message data
message.thumbnail_url = thumbnailUrl;
message.thumbnail_info = {
size: thumbnailBlob.size,
w: thumbnailSize.width,
h: thumbnailSize.height,
mimetype: thumbnailBlob.type
};
// Then, upload the original image
uploadImage();
},
function(error) {
console.log(" -> Can't upload thumbnail");
deferred.reject(error);
}
);
},
function(error) {
console.log(" -> Failed to get thumbnail size");
deferred.reject(error);
}
);
},
function(error) {
console.log(" -> Failed to create thumbnail: " + error);
deferred.reject(error);
}
);
}
else {
// No need of thumbnail
console.log(" Thumbnail is not required");
uploadImage();
}
},
function(error) {
console.log(" -> Failed to get image size");
deferred.reject(error);
}
);
}
else {
// it's a random file - just upload it.
self.uploadFile(file).then(
function(url) {
// Update message metadata
message.url = url;
message.msgtype = "m.file";
message.body = file.name;
message.info = {
size: file.size,
mimetype: file.type
};
// We are done
deferred.resolve(message);
},
function(error) {
console.log(" -> Can't upload file");
deferred.reject(error);
}
);
}
return deferred.promise; return deferred.promise;
}; };

View File

@ -501,51 +501,7 @@ function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificati
eventContainsBingWord: function(event) { eventContainsBingWord: function(event) {
return containsBingWord(event); return containsBingWord(event);
},
/**
* Return the last message event of a room
* @param {String} room_id the room id
* @param {Boolean} filterFake true to not take into account fake messages
* @returns {undefined | Event} the last message event if available
*/
getLastMessage: function(room_id, filterEcho) {
var lastMessage;
var events = modelService.getRoom(room_id).events;
for (var i = events.length - 1; i >= 0; i--) {
var message = events[i];
if (!filterEcho || undefined === message.echo_msg_state) {
lastMessage = message;
break;
}
}
return lastMessage;
},
/**
* Compute the room users number, ie the number of members who has joined the room.
* @param {String} room_id the room id
* @returns {undefined | Number} the room users number if available
*/
getUsersCountInRoom: function(room_id) {
var memberCount;
var room = modelService.getRoom(room_id);
memberCount = 0;
for (var i in room.current_room_state.members) {
if (!room.current_room_state.members.hasOwnProperty(i)) continue;
var member = room.current_room_state.members[i].event;
if ("join" === member.content.membership) {
memberCount = memberCount + 1;
}
}
return memberCount;
} }
}; };
}]); }]);

View File

@ -284,6 +284,52 @@ angular.module('modelService', [])
} }
} }
return powerLevel; return powerLevel;
},
/**
* Compute the room users number, ie the number of members who has joined the room.
* @param {String} room_id the room id
* @returns {undefined | Number} the room users number if available
*/
getUserCountInRoom: function(room_id) {
var memberCount;
var room = this.getRoom(room_id);
memberCount = 0;
for (var i in room.current_room_state.members) {
if (!room.current_room_state.members.hasOwnProperty(i)) continue;
var member = room.current_room_state.members[i].event;
if ("join" === member.content.membership) {
memberCount = memberCount + 1;
}
}
return memberCount;
},
/**
* Return the last message event of a room
* @param {String} room_id the room id
* @param {Boolean} filterFake true to not take into account fake messages
* @returns {undefined | Event} the last message event if available
*/
getLastMessage: function(room_id, filterEcho) {
var lastMessage;
var events = this.getRoom(room_id).events;
for (var i = events.length - 1; i >= 0; i--) {
var message = events[i];
// TODO: define a better marker than echo_msg_state
if (!filterEcho || undefined === message.echo_msg_state) {
lastMessage = message;
break;
}
}
return lastMessage;
} }
}; };

View File

@ -11,17 +11,17 @@
<meta name="viewport" content="width=device-width"> <meta name="viewport" content="width=device-width">
<script type='text/javascript' src='js/jquery-1.8.3.min.js'></script> <script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="https://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script> <script type="text/javascript" src="js/recaptcha_ajax.js"></script>
<script src="js/angular.js"></script> <script src="js/angular.js"></script>
<script src="js/angular-route.min.js"></script> <script src="js/angular-route.min.js"></script>
<script src="js/angular-sanitize.min.js"></script> <script src="js/angular-sanitize.min.js"></script>
<script src="js/jquery.peity.min.js"></script> <script src="js/jquery.peity.min.js"></script>
<script src="js/angular-peity.js"></script> <script src="js/angular-peity.js"></script>
<script type='text/javascript' src="js/ui-bootstrap-tpls-0.11.2.js"></script> <script type="text/javascript" src="js/ui-bootstrap-tpls-0.11.2.js"></script>
<script type='text/javascript' src='js/ng-infinite-scroll-matrix.js'></script> <script type="text/javascript" src="js/ng-infinite-scroll-matrix.js"></script>
<script type='text/javascript' src='js/autofill-event.js'></script> <script type="text/javascript" src="js/autofill-event.js"></script>
<script type='text/javascript' src='js/elastic.js'></script> <script type="text/javascript" src="js/elastic.js"></script>
<script src="app.js"></script> <script src="app.js"></script>
<script src="config.js"></script> <script src="config.js"></script>
<script src="app-controller.js"></script> <script src="app-controller.js"></script>

File diff suppressed because one or more lines are too long

View File

@ -20,7 +20,7 @@ angular.module('RegisterController', ['matrixService'])
'use strict'; 'use strict';
var config = window.webClientConfig; var config = window.webClientConfig;
var useCaptcha = true; var useCaptcha = false; // default to no captcha to make it easier to get a homeserver up and running...
if (config !== undefined) { if (config !== undefined) {
useCaptcha = config.useCaptcha; useCaptcha = config.useCaptcha;
} }
@ -167,16 +167,10 @@ angular.module('RegisterController', ['matrixService'])
var setupCaptcha = function() { var setupCaptcha = function() {
console.log("Setting up ReCaptcha") console.log("Setting up ReCaptcha")
var config = window.webClientConfig; var public_key = window.webClientConfig.recaptcha_public_key;
var public_key = undefined; if (public_key === undefined) {
if (config === undefined) { console.error("No public key defined for captcha!")
console.error("Couldn't find webClientConfig. Cannot get public key for captcha."); return;
}
else {
public_key = webClientConfig.recaptcha_public_key;
if (public_key === undefined) {
console.error("No public key defined for captcha!")
}
} }
Recaptcha.create(public_key, Recaptcha.create(public_key,
"regcaptcha", "regcaptcha",

View File

@ -17,11 +17,11 @@
'use strict'; 'use strict';
angular.module('RecentsController', ['matrixService', 'matrixFilter']) angular.module('RecentsController', ['matrixService', 'matrixFilter'])
.controller('RecentsController', ['$rootScope', '$scope', 'eventHandlerService', 'modelService', 'recentsService', .controller('RecentsController', ['$rootScope', '$scope', 'modelService', 'recentsService',
function($rootScope, $scope, eventHandlerService, modelService, recentsService) { function($rootScope, $scope, modelService, recentsService) {
// Expose the service to the view // Expose the service to the view
$scope.eventHandlerService = eventHandlerService; $scope.modelService = modelService;
// retrieve all rooms and expose them // retrieve all rooms and expose them
$scope.rooms = modelService.getRooms(); $scope.rooms = modelService.getRooms();

View File

@ -17,7 +17,7 @@
'use strict'; 'use strict';
angular.module('RecentsController') angular.module('RecentsController')
.filter('orderRecents', ["matrixService", "eventHandlerService", "modelService", function(matrixService, eventHandlerService, modelService) { .filter('orderRecents', ["matrixService", "modelService", function(matrixService, modelService) {
return function(rooms) { return function(rooms) {
var user_id = matrixService.config().user_id; var user_id = matrixService.config().user_id;
@ -39,8 +39,8 @@ angular.module('RecentsController')
room.recent.inviter = member.user_id; room.recent.inviter = member.user_id;
} }
// Count users here // Count users here
// TODO: Compute it directly in eventHandlerService // TODO: Compute it directly in modelService
room.recent.numUsersInRoom = eventHandlerService.getUsersCountInRoom(room_id); room.recent.numUsersInRoom = modelService.getUserCountInRoom(room_id);
filtered.push(room); filtered.push(room);
} }
@ -54,8 +54,8 @@ angular.module('RecentsController')
// The room with the latest message at first // The room with the latest message at first
filtered.sort(function (roomA, roomB) { filtered.sort(function (roomA, roomB) {
var lastMsgRoomA = eventHandlerService.getLastMessage(roomA.room_id, true); var lastMsgRoomA = modelService.getLastMessage(roomA.room_id, true);
var lastMsgRoomB = eventHandlerService.getLastMessage(roomB.room_id, true); var lastMsgRoomB = modelService.getLastMessage(roomB.room_id, true);
// Invite message does not have a body message nor ts // Invite message does not have a body message nor ts
// Puth them at the top of the list // Puth them at the top of the list

View File

@ -16,7 +16,7 @@
<td class="recentsRoomSummaryTS"> <td class="recentsRoomSummaryTS">
<!-- Use a temp var as alias to the last room message. <!-- Use a temp var as alias to the last room message.
Declaring it in this way ensures the data-binding --> Declaring it in this way ensures the data-binding -->
{{ lastMsg = eventHandlerService.getLastMessage(room.room_id, true);"" }} {{ lastMsg = modelService.getLastMessage(room.room_id, true);"" }}
{{ (lastMsg.origin_server_ts) | date:'MMM d HH:mm' }} {{ (lastMsg.origin_server_ts) | date:'MMM d HH:mm' }}
@ -84,7 +84,7 @@
</div> </div>
<div ng-switch-default> <div ng-switch-default>
{{ lastMsg.content }} {{ lastMsg.content.body | linky:'_blank' }}
</div> </div>
</div> </div>
</div> </div>

View File

@ -495,6 +495,7 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput', 'a
}); });
}; };
// used to send an image based on just a URL, rather than uploading one
$scope.sendImage = function(url, body) { $scope.sendImage = function(url, body) {
scrollToBottom(true); scrollToBottom(true);
@ -507,23 +508,23 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput', 'a
}); });
}; };
$scope.imageFileToSend; $scope.fileToSend;
$scope.$watch("imageFileToSend", function(newValue, oldValue) { $scope.$watch("fileToSend", function(newValue, oldValue) {
if ($scope.imageFileToSend) { if ($scope.fileToSend) {
// Upload this image with its thumbnail to Internet // Upload this file
mFileUpload.uploadImageAndThumbnail($scope.imageFileToSend, THUMBNAIL_SIZE).then( mFileUpload.uploadFileAndThumbnail($scope.fileToSend, THUMBNAIL_SIZE).then(
function(imageMessage) { function(fileMessage) {
// imageMessage is complete message structure, send it as is // fileMessage is complete message structure, send it as is
matrixService.sendMessage($scope.room_id, undefined, imageMessage).then( matrixService.sendMessage($scope.room_id, undefined, fileMessage).then(
function() { function() {
console.log("Image message sent"); console.log("File message sent");
}, },
function(error) { function(error) {
$scope.feedback = "Failed to send image message: " + error.data.error; $scope.feedback = "Failed to send file message: " + error.data.error;
}); });
}, },
function(error) { function(error) {
$scope.feedback = "Can't upload image"; $scope.feedback = "Can't upload file";
} }
); );
} }

View File

@ -198,31 +198,45 @@
{{ msg.user_id }} changed their display name from {{ msg.prev_content.displayname }} to {{ msg.content.displayname }} {{ msg.user_id }} changed their display name from {{ msg.prev_content.displayname }} to {{ msg.content.displayname }}
</span> </span>
<span ng-show='msg.content.msgtype === "m.emote"' <span ng-show='msg.type === "m.room.message"' ng-switch='msg.content.msgtype'>
ng-class="msg.echo_msg_state" <span ng-switch-when="m.emote"
ng-bind-html="'* ' + (msg.__room_member.cnt.displayname || msg.user_id) + ' ' + msg.content.body | linky:'_blank'" ng-class="containsBingWord(msg) && msg.user_id != state.user_id ? msg.echo_msg_state + ' messageBing' : msg.echo_msg_state"
/> ng-bind-html="'* ' + (msg.__room_member.cnt.displayname || msg.user_id) + ' ' + msg.content.body | linky:'_blank'"
/>
<span ng-show='msg.content.msgtype === "m.text"' <span ng-switch-when="m.text"
class="message" class="message"
ng-class="containsBingWord(msg) && msg.user_id != state.user_id ? msg.echo_msg_state + ' messageBing' : msg.echo_msg_state" ng-class="containsBingWord(msg) && msg.user_id != state.user_id ? msg.echo_msg_state + ' messageBing' : msg.echo_msg_state"
ng-bind-html="(msg.content.msgtype === 'm.text' && msg.type === 'm.room.message' && msg.content.format === 'org.matrix.custom.html') ? ng-bind-html="(msg.content.format === 'org.matrix.custom.html') ? (msg.content.formatted_body | unsanitizedLinky) : (msg.content.body | linky:'_blank') "/>
(msg.content.formatted_body | unsanitizedLinky) :
(msg.content.msgtype === 'm.text' && msg.type === 'm.room.message') ? (msg.content.body | linky:'_blank') : '' "/> <div ng-switch-when="m.image">
<div ng-hide='msg.content.thumbnail_url' ng-style="msg.content.body.h && { 'height' : (msg.content.body.h < 320) ? msg.content.body.h : 320}">
<img class="image" ng-src="{{ msg.content.url }}"/>
</div>
<div ng-show='msg.content.thumbnail_url' ng-style="{ 'height' : msg.content.thumbnail_info.h }">
<img class="image mouse-pointer" ng-src="{{ msg.content.thumbnail_url }}"
ng-click="$parent.$parent.fullScreenImageURL = msg.content.url; $event.stopPropagation();"/>
</div>
</div>
<span ng-switch-when="m.file" ng-class="msg.echo_msg_state">
<a href="{{ msg.content.url}}" target="_blank">{{ msg.content.body }}</a>
<div ng-show='msg.content.thumbnail_url' ng-style="{ 'height' : msg.content.thumbnail_info.h }">
<a href="{{ msg.content.url}}" target="_blank">
<img class="image mouse-pointer" ng-src="{{ msg.content.thumbnail_url }}"/>
</a>
</div>
</span>
<span ng-switch-default
ng-class="containsBingWord(msg) && msg.user_id != state.user_id ? msg.echo_msg_state + ' messageBing' : msg.echo_msg_state"
ng-bind-html="msg.content.body | linky:'_blank'"
/>
</span>
<span ng-show='msg.type === "m.call.invite" && msg.user_id == state.user_id'>Outgoing Call{{ isWebRTCSupported() ? '' : ' (But your browser does not support VoIP)' }}</span> <span ng-show='msg.type === "m.call.invite" && msg.user_id == state.user_id'>Outgoing Call{{ isWebRTCSupported() ? '' : ' (But your browser does not support VoIP)' }}</span>
<span ng-show='msg.type === "m.call.invite" && msg.user_id != state.user_id'>Incoming Call{{ isWebRTCSupported() ? '' : ' (But your browser does not support VoIP)' }}</span> <span ng-show='msg.type === "m.call.invite" && msg.user_id != state.user_id'>Incoming Call{{ isWebRTCSupported() ? '' : ' (But your browser does not support VoIP)' }}</span>
<div ng-show='msg.content.msgtype === "m.image"'>
<div ng-hide='msg.content.thumbnail_url' ng-style="msg.content.body.h && { 'height' : (msg.content.body.h < 320) ? msg.content.body.h : 320}">
<img class="image" ng-src="{{ msg.content.url }}"/>
</div>
<div ng-show='msg.content.thumbnail_url' ng-style="{ 'height' : msg.content.thumbnail_info.h }">
<img class="image mouse-pointer" ng-src="{{ msg.content.thumbnail_url }}"
ng-click="$parent.fullScreenImageURL = msg.content.url; $event.stopPropagation();"/>
</div>
</div>
<span ng-if="'m.room.topic' === msg.type"> <span ng-if="'m.room.topic' === msg.type">
{{ msg.__room_member.cnt.displayname || msg.user_id }} changed the topic to: {{ msg.content.topic }} {{ msg.__room_member.cnt.displayname || msg.user_id }} changed the topic to: {{ msg.content.topic }}
</span> </span>
@ -250,7 +264,7 @@
<div id="controlPanel"> <div id="controlPanel">
<div id="controls"> <div id="controls">
<button id="attachButton" m-file-input="imageFileToSend" class="extraControls" ng-disabled="state.permission_denied"></button> <button id="attachButton" m-file-input="fileToSend" class="extraControls" ng-disabled="state.permission_denied"></button>
<textarea id="mainInput" rows="1" ng-enter="send()" <textarea id="mainInput" rows="1" ng-enter="send()"
ng-disabled="state.permission_denied" ng-disabled="state.permission_denied"
ng-focus="true" autocomplete="off" tab-complete command-history="room_id"/> ng-focus="true" autocomplete="off" tab-complete command-history="room_id"/>

View File

@ -54,7 +54,7 @@
Notifications are enabled. Notifications are enabled.
<div class="section"> <div class="section">
<h4>Specific words to alert on:</h4> <h4>Specific words to alert on:</h4>
<p>Leave blank to alert on all messages. Your username & display name always alerts.</p> <p>If blank, all messages will trigger an alert. Your username & display name always alerts.</p>
<input size=40 name="bingWords" ng-model="settings.bingWords" ng-list placeholder="Enter words separated with , (supports regex)" <input size=40 name="bingWords" ng-model="settings.bingWords" ng-list placeholder="Enter words separated with , (supports regex)"
ng-blur="saveBingWords()"/> ng-blur="saveBingWords()"/>
<ul> <ul>

View File

@ -26,45 +26,5 @@ describe('EventHandlerService', function() {
scope = $rootScope; scope = $rootScope;
})); }));
it('should be able to get the number of joined users in a room', inject(
function(eventHandlerService) {
var roomId = "!foo:matrix.org";
// set mocked data
modelService.getRoom = function(roomId) {
return {
room_id: roomId,
current_room_state: {
members: {
"@adam:matrix.org": {
event: {
content: { membership: "join" },
user_id: "@adam:matrix.org"
}
},
"@beth:matrix.org": {
event: {
content: { membership: "invite" },
user_id: "@beth:matrix.org"
}
},
"@charlie:matrix.org": {
event: {
content: { membership: "join" },
user_id: "@charlie:matrix.org"
}
},
"@danice:matrix.org": {
event: {
content: { membership: "leave" },
user_id: "@danice:matrix.org"
}
}
}
}
};
}
var num = eventHandlerService.getUsersCountInRoom(roomId);
expect(num).toEqual(2);
}));
}); });

View File

@ -193,4 +193,38 @@ describe('ModelService', function() {
})); }));
it('should be able to get the number of joined users in a room', inject(
function(modelService) {
var roomId = "!foo:matrix.org";
// set mocked data
var room = modelService.getRoom(roomId);
room.current_room_state.storeStateEvent({
content: { membership: "join" },
user_id: "@adam:matrix.org",
state_key: "@adam:matrix.org",
type: "m.room.member"
});
room.current_room_state.storeStateEvent({
content: { membership: "invite" },
user_id: "@adam:matrix.org",
state_key: "@beth:matrix.org",
type: "m.room.member"
});
room.current_room_state.storeStateEvent({
content: { membership: "join" },
user_id: "@charlie:matrix.org",
state_key: "@charlie:matrix.org",
type: "m.room.member"
});
room.current_room_state.storeStateEvent({
content: { membership: "leave" },
user_id: "@danice:matrix.org",
state_key: "@danice:matrix.org",
type: "m.room.member"
});
var num = modelService.getUserCountInRoom(roomId);
expect(num).toEqual(2);
}));
}); });

View File

@ -5,7 +5,7 @@ describe("RegisterController ", function() {
var avatarUrl = "avatar.url"; var avatarUrl = "avatar.url";
window.webClientConfig = { window.webClientConfig = {
useCapatcha: false useCaptcha: false
}; };
// test vars // test vars