respect allow_user_sms and user roles for SMS
This commit is contained in:
parent
b9c9cf8cc3
commit
ba3d4b35db
17
web/app.py
17
web/app.py
|
|
@ -7180,11 +7180,18 @@ Name: <strong>''' + p.name + '''</strong> - Port: <strong>''' + str(
|
||||||
u = User.query.filter(User.username == user).first()
|
u = User.query.filter(User.username == user).first()
|
||||||
if key in u.api_keys:
|
if key in u.api_keys:
|
||||||
if 'dmr_id' in api_data and 'sms' in api_data:
|
if 'dmr_id' in api_data and 'sms' in api_data:
|
||||||
# def sms_que_add(_snd_call, _rcv_call, _snd_id, _rcv_id, _msg_type, _call_type, _server, _system_name, _msg):
|
u_role = UserRoles.query.filter_by(user_id=u.id).first()
|
||||||
sms_que_add(user, '', 0, api_data['dmr_id'], 'motorola', 'unit', api_data['gateway'], '', 'From: ' + user + '. ' + api_data['sms'])
|
print(u_role.role_id)
|
||||||
msg = jsonify(status='Sucess',
|
if u_role.role_id == 1 or allow_user_sms == True:
|
||||||
reason='Added SMS to que')
|
# def sms_que_add(_snd_call, _rcv_call, _snd_id, _rcv_id, _msg_type, _call_type, _server, _system_name, _msg):
|
||||||
response = make_response(msg, 200)
|
sms_que_add(user, '', 0, api_data['dmr_id'], 'motorola', 'unit', api_data['gateway'], '', 'From: ' + user + '. ' + api_data['sms'])
|
||||||
|
msg = jsonify(status='Sucess',
|
||||||
|
reason='Added SMS to que')
|
||||||
|
response = make_response(msg, 200)
|
||||||
|
else:
|
||||||
|
msg = jsonify(status='SMS disabled',
|
||||||
|
reason='SMS via API disabled. Contact administrator.')
|
||||||
|
response = make_response(msg, 500)
|
||||||
if 'dmr_id' in api_data and 'sms' in api_data and 'gateway' not in api_data:
|
if 'dmr_id' in api_data and 'sms' in api_data and 'gateway' not in api_data:
|
||||||
msg = jsonify(status='Not added to que',
|
msg = jsonify(status='Not added to que',
|
||||||
reason='Gateway not specified')
|
reason='Gateway not specified')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue