diff --git a/appservice.py b/appservice.py index 76b99ab..feaa0eb 100644 --- a/appservice.py +++ b/appservice.py @@ -118,7 +118,7 @@ def on_receive_events(transaction): if event['content']['membership'] == 'invite' and 'is_direct' in event['content'] and event['content']['is_direct'] == True: - logging.info('>> GOT INVITE') + logging.info('>> GOT PRIVATE INVITE') txId += 1 url = app.config['MATRIX_HOST'] url += '/_matrix/client/r0/join/' + event['room_id'] @@ -130,6 +130,15 @@ def on_receive_events(transaction): db.session.add(addadminrm) db.session.commit() + elif event['content']['membership'] == '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['membership'] == 'leave': adminrm = MatrixAdminRooms.query.filter_by(room_id=event['room_id']).first() if adminrm: diff --git a/pnut-bridge.py b/pnut-bridge.py index 6821f39..5c4cda1 100644 --- a/pnut-bridge.py +++ b/pnut-bridge.py @@ -93,7 +93,7 @@ class ChannelMonitor(threading.Thread): db.session.commit() def poll_channel(self, room): - r = Pnut().get_channel_stream(room.pnut_chan, room.pnut_since) + r = Pnut(app.config['MATRIX_PNUT_TOKEN']).get_channel_stream(room.pnut_chan, room.pnut_since) if r is not None and r.status_code == 200: rdata = r.json() pqueue = [] diff --git a/pnutlib.py b/pnutlib.py index 25c5927..e9f5430 100644 --- a/pnutlib.py +++ b/pnutlib.py @@ -50,8 +50,7 @@ class Pnut: def get_channel_stream(self,chan_id,since_id=None): url = "https://api.pnut.io/v0/channels/" + str(chan_id) + "/messages?include_raw=1" - # headers = { "Authorization": "Bearer " + self.token } - headers = {} + headers = { "Authorization": "Bearer " + self.token } parameters = {} if since_id: parameters = { "since_id": since_id }