properly handle unlinking rooms, issue #47
This commit is contained in:
parent
327d8fad8c
commit
264dee0176
1 changed files with 15 additions and 14 deletions
|
@ -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:
|
||||||
|
|
Loading…
Reference in a new issue