Commit 16f495ff authored by Robbe Van Herck's avatar Robbe Van Herck

Add possibility to delete messages from non-bestuur

parent 450bcf20
......@@ -8,6 +8,7 @@ import config
import random
import re
import pdb
from mattermostdriver import Driver
app = Flask(__name__)
......@@ -21,6 +22,14 @@ response_setting = "in_channel"
from app import models
driver = Driver({
'scheme': 'http',
'url': config.server_url,
'token': config.personal_auth_token
})
driver.login()
def check_regular(username):
'''Check if a user has the permissions of a regular user.'''
return models.User.query.filter_by(username=username, authorized=True).first() is not None
......@@ -117,6 +126,17 @@ def slotmachien_request(username, command):
'username': username, 'token': config.slotmachien_token, 'text': command})
return r.text
def is_bestuur(username):
return username in config.bestuur
@app.route('/new_message', methods=['POST'])
def new_message():
if not is_bestuur(request.values.get("user_name")):
delete_message(request.values.get("post_id"))
return ""
def delete_message(message_id):
driver.posts.delete_post(message_id)
@app.route('/door', methods=['POST'])
@requires_token('door')
......
......@@ -8,3 +8,9 @@ tokens = {
}
slotmachien_url = 'https://kelder.zeus.ugent.be/slotmachien/slack/'
slotmachien_token = '123'
personal_auth_token='zeusbot-auth-token'
server_url='mattermost.myserver.com'
bestuur = [
"user1",
"user2"
]
......@@ -10,6 +10,7 @@ itsdangerous==0.24
Jinja2==2.10
Mako==1.0.7
MarkupSafe==1.0
mattermostdriver==6.1.3
PyBug==1.2.1
python-dateutil==2.8.0
python-editor==1.0.4
......@@ -17,4 +18,5 @@ requests==2.19.1
six==1.12.0
SQLAlchemy==1.2.12
urllib3==1.23
websockets==7.0
Werkzeug==0.14.1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment