adjust leave action to match up with admin room rather than state_key

This commit is contained in:
Morgan McMillian 2017-05-04 17:17:45 -07:00
parent dfccd44b1d
commit 804af96194

View file

@ -110,9 +110,7 @@ def on_receive_events(transaction):
if event['state_key'] == app.config['MATRIX_AS_ID']:
if event['content']['membership'] == 'invite'
and 'is_direct' in event['content']
and event['content']['is_direct'] == True:
if event['content']['membership'] == 'invite' and 'is_direct' in event['content'] and event['content']['is_direct'] == True:
logging.info('>> GOT INVITE')
txId += 1
@ -127,6 +125,8 @@ def on_receive_events(transaction):
db.session.commit()
elif event['membership'] == 'leave':
adminrm = MatrixAdminRooms.query.filter_by(room_id=event['room_id']).first()
if adminrm:
logging.info('>> GOT LEAVE')
txId += 1
url = app.config['MATRIX_HOST']
@ -135,7 +135,6 @@ def on_receive_events(transaction):
r = requests.post(url, headers={"Content-Type": "application/json"},
data=json.dumps({}))
if r.status_code == 200:
adminrm = MatrixAdminRooms.query.filter_by(room_id=event['room_id']).first()
db.session.delete(adminrm)
db.session.commit()