mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Filter room where the user has been banned
This commit is contained in:
parent
8aa4b7bf7f
commit
b0483cd47d
@ -398,6 +398,22 @@ angular.module('eventHandlerService', [])
|
||||
}
|
||||
|
||||
return memberCount;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the member object of a room member
|
||||
* @param {String} room_id the room id
|
||||
* @param {String} user_id the id of the user
|
||||
* @returns {undefined | Object} the member object of this user in this room if he is part of the room
|
||||
*/
|
||||
getMember: function(room_id, user_id) {
|
||||
var member;
|
||||
|
||||
var room = $rootScope.events.rooms[room_id];
|
||||
if (room) {
|
||||
member = room.members[user_id];
|
||||
}
|
||||
return member;
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
@ -17,19 +17,27 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('RecentsController')
|
||||
.filter('orderRecents', ["eventHandlerService", function(eventHandlerService) {
|
||||
.filter('orderRecents', ["matrixService", "eventHandlerService", function(matrixService, eventHandlerService) {
|
||||
return function(rooms) {
|
||||
|
||||
var user_id = matrixService.config().user_id;
|
||||
|
||||
// Transform the dict into an array
|
||||
// The key, room_id, is already in value objects
|
||||
var filtered = [];
|
||||
angular.forEach(rooms, function(room, room_id) {
|
||||
|
||||
// Count users here
|
||||
// TODO: Compute it directly in eventHandlerService
|
||||
room.numUsersInRoom = eventHandlerService.getUsersCountInRoom(room_id);
|
||||
// Show the room only if the user has joined it or has been invited
|
||||
// (ie, do not show it if he has been banned)
|
||||
var member = eventHandlerService.getMember(room_id, user_id);
|
||||
if (member && ("invite" === member.membership || "join" === member.membership)) {
|
||||
|
||||
// Count users here
|
||||
// TODO: Compute it directly in eventHandlerService
|
||||
room.numUsersInRoom = eventHandlerService.getUsersCountInRoom(room_id);
|
||||
|
||||
filtered.push(room);
|
||||
filtered.push(room);
|
||||
}
|
||||
});
|
||||
|
||||
// And time sort them
|
||||
|
Loading…
Reference in New Issue
Block a user