properly handle unlinking rooms, issue #47

This commit is contained in:
Morgan McMillian 2020-03-22 22:00:53 -07:00
parent 327d8fad8c
commit 264dee0176

View file

@ -409,6 +409,7 @@ def cmd_admin_unlink(id):
else: else:
room = Rooms.query.filter(Rooms.pnut_chan == id).one_or_none() room = Rooms.query.filter(Rooms.pnut_chan == id).one_or_none()
if hasattr(room, 'portal'):
if room.portal: if room.portal:
alias = "#" + app.config['MATRIX_PNUT_PREFIX'] alias = "#" + app.config['MATRIX_PNUT_PREFIX']
alias += str(room.pnut_chan) + ":" alias += str(room.pnut_chan) + ":"
@ -419,7 +420,7 @@ def cmd_admin_unlink(id):
members = matrix_api.get_room_members(room.room_id) members = matrix_api.get_room_members(room.room_id)
reason = "Portal room has been unlinked by administrator" reason = "Portal room has been unlinked by administrator"
for m in members['chunk']: for m in members['chunk']:
if m['membership'] == 'join' and m['sender'] != app.config['MATRIX_AS_ID']: if m['content']['membership'] == 'join' and m['sender'] != app.config['MATRIX_AS_ID']:
if room.portal: if room.portal:
matrix_api.kick_user(room.room_id, m['sender'], reason=reason) matrix_api.kick_user(room.room_id, m['sender'], reason=reason)
else: else: