fix permission on room
This commit is contained in:
Binary file not shown.
@@ -13,7 +13,13 @@ def rooms():
|
||||
if current_user.is_admin:
|
||||
query = Room.query
|
||||
else:
|
||||
query = Room.query.filter(Room.members.any(id=current_user.id))
|
||||
# Get rooms where user is a member and has view permissions
|
||||
query = Room.query.join(
|
||||
RoomMemberPermission,
|
||||
(Room.id == RoomMemberPermission.room_id) &
|
||||
(RoomMemberPermission.user_id == current_user.id) &
|
||||
(RoomMemberPermission.can_view == True)
|
||||
)
|
||||
if search:
|
||||
query = query.filter(Room.name.ilike(f'%{search}%'))
|
||||
rooms = query.order_by(Room.created_at.desc()).all()
|
||||
|
||||
Reference in New Issue
Block a user