remove broken invite code issue #31
This commit is contained in:
parent
e88404bbc9
commit
f4855adce8
1 changed files with 3 additions and 21 deletions
|
@ -166,33 +166,15 @@ def on_receive_events(transaction):
|
||||||
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 PRIVATE INVITE')
|
logging.info('>> GOT PRIVATE INVITE')
|
||||||
# cmdbot.on_invite(event)
|
|
||||||
# addadminrm = MatrixAdminRooms(matrix_id=event['sender'], room_id=event['room_id'])
|
|
||||||
# db.session.add(addadminrm)
|
|
||||||
# db.session.commit()
|
|
||||||
|
|
||||||
elif event['content']['membership'] == 'invite':
|
elif event['content']['membership'] == 'invite':
|
||||||
logging.info('>> GOT ROOM INVITE')
|
logging.info('>> GOT ROOM INVITE')
|
||||||
txId += 1
|
|
||||||
url = app.config['MATRIX_HOST']
|
|
||||||
url += '/_matrix/client/r0/join/' + event['room_id']
|
|
||||||
url += "?access_token=" + app.config['MATRIX_AS_TOKEN']
|
|
||||||
r = requests.post(url, headers={"Content-Type": "application/json"},
|
|
||||||
data=json.dumps({}))
|
|
||||||
|
|
||||||
elif event['content']['membership'] == 'leave':
|
elif event['content']['membership'] == 'leave':
|
||||||
adminrm = MatrixAdminRooms.query.filter_by(room_id=event['room_id']).first()
|
adminrm = MatrixAdminRooms.query.filter_by(room_id=event['room_id']).first()
|
||||||
if adminrm:
|
|
||||||
logging.info('>> GOT LEAVE')
|
|
||||||
txId += 1
|
|
||||||
url = app.config['MATRIX_HOST']
|
|
||||||
url += '/_matrix/client/r0/rooms/' + event['room_id'] + "/leave"
|
|
||||||
url += "?access_token=" + app.config['MATRIX_AS_TOKEN']
|
|
||||||
r = requests.post(url, headers={"Content-Type": "application/json"},
|
|
||||||
data=json.dumps({}))
|
|
||||||
if r.status_code == 200:
|
|
||||||
db.session.delete(adminrm)
|
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
|
|
||||||
return jsonify({})
|
return jsonify({})
|
||||||
|
|
Loading…
Reference in a new issue