improvements
This commit is contained in:
parent
0719db4e77
commit
1ce6c26d84
@ -2280,4 +2280,6 @@ if __name__ == '__main__':
|
|||||||
else:
|
else:
|
||||||
threading.Thread(target=aprs_rx, args=(aprs_callsign, aprs_passcode, aprs_server, aprs_port, aprs_filter, user_ssid,)).start()
|
threading.Thread(target=aprs_rx, args=(aprs_callsign, aprs_passcode, aprs_server, aprs_port, aprs_filter, user_ssid,)).start()
|
||||||
#logger.info(UNIT_MAP)
|
#logger.info(UNIT_MAP)
|
||||||
|
#global authorized_users, other_systems
|
||||||
|
#from .scripts.dashboard.authorized_apps import authorized_users, other_systems
|
||||||
reactor.run()
|
reactor.run()
|
||||||
|
@ -721,59 +721,63 @@ def mail_rss():
|
|||||||
"""
|
"""
|
||||||
return Response(rss_header + post_data + "\n</channel>\n</rss>", mimetype='text/xml')
|
return Response(rss_header + post_data + "\n</channel>\n</rss>", mimetype='text/xml')
|
||||||
|
|
||||||
@app.route('/api/<api_mode>', methods=['POST'])
|
@app.route('/api/<api_mode>', methods=['POST', 'GET'])
|
||||||
def api(api_mode=None):
|
def api(api_mode=None):
|
||||||
api_data = request.json
|
if request.method == 'GET':
|
||||||
# Find out type of JSON
|
print('get')
|
||||||
#print(api_data)
|
return render_template('generic.html', title = dashboard_title, content = Markup(api_content))
|
||||||
#print(authorized_users)
|
else:
|
||||||
## try:
|
api_data = request.json
|
||||||
# Filter msg_xfer
|
# Find out type of JSON
|
||||||
if api_data['mode'] == 'msg_xfer':
|
#print(api_data)
|
||||||
# Handle authorization
|
#print(authorized_users)
|
||||||
if api_data['auth_type'] == 'private':
|
## try:
|
||||||
#Authenticate
|
# Filter msg_xfer
|
||||||
if api_data['system_name'] in authorized_users and api_data['credentials']['user'] == authorized_users[api_data['system_name']]['user'] and api_data['credentials']['password'] == authorized_users[api_data['system_name']]['password']:
|
if api_data['mode'] == 'msg_xfer':
|
||||||
print(api_data['credentials']['user'])
|
# Handle authorization
|
||||||
print(api_data['credentials']['password'])
|
if api_data['auth_type'] == 'private':
|
||||||
for sms in api_data['data'].items():
|
#Authenticate
|
||||||
sms_data = sms[1]
|
if api_data['system_name'] in authorized_users and api_data['credentials']['user'] == authorized_users[api_data['system_name']]['user'] and api_data['credentials']['password'] == authorized_users[api_data['system_name']]['password']:
|
||||||
print((sms_data['destination_id']))
|
print(api_data['credentials']['user'])
|
||||||
print((sms_data['source_id']))
|
print(api_data['credentials']['password'])
|
||||||
print((sms_data['message']))
|
for sms in api_data['data'].items():
|
||||||
print((sms_data['slot']))
|
sms_data = sms[1]
|
||||||
if sms_data['slot'] == 0:
|
print((sms_data['destination_id']))
|
||||||
send_slot = int(unit_sms_ts) - 1
|
print((sms_data['source_id']))
|
||||||
if sms_data['slot'] == 1:
|
print((sms_data['message']))
|
||||||
send_slot = 0
|
print((sms_data['slot']))
|
||||||
if sms_data['slot'] == 2:
|
if sms_data['slot'] == 0:
|
||||||
send_slot = 1
|
send_slot = int(unit_sms_ts) - 1
|
||||||
send_sms(False, sms_data['destination_id'], sms_data['source_id'], 0000, 'unit', send_slot, sms_data['message'])
|
if sms_data['slot'] == 1:
|
||||||
|
send_slot = 0
|
||||||
|
if sms_data['slot'] == 2:
|
||||||
|
send_slot = 1
|
||||||
|
send_sms(False, sms_data['destination_id'], sms_data['source_id'], 0000, 'unit', send_slot, sms_data['message'])
|
||||||
|
return jsonify(
|
||||||
|
mode=api_data['mode'],
|
||||||
|
status='Generated SMS',
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return jsonify(
|
||||||
|
mode=api_data['mode'],
|
||||||
|
status='Authentication error',
|
||||||
|
)
|
||||||
|
if api_data['auth_type'] == 'public':
|
||||||
return jsonify(
|
return jsonify(
|
||||||
mode=api_data['mode'],
|
mode=api_data['mode'],
|
||||||
status='Generated SMS',
|
status='Not implemented at this time',
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return jsonify(
|
return jsonify(
|
||||||
mode=api_data['mode'],
|
mode=api_data['mode'],
|
||||||
status='Authentication error',
|
status='Not an authorization method',
|
||||||
)
|
)
|
||||||
if api_data['auth_type'] == 'public':
|
|
||||||
return jsonify(
|
|
||||||
mode=api_data['mode'],
|
|
||||||
status='Not implemented at this time',
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
return jsonify(
|
message = jsonify(message='Mode not found')
|
||||||
mode=api_data['mode'],
|
return make_response(message, 400)
|
||||||
status='Not an authorization method',
|
## except Exception as e:
|
||||||
)
|
## message = jsonify(message='Error:' + str(e))
|
||||||
else:
|
## return make_response(message, 400)
|
||||||
message = jsonify(message='Mode not found')
|
|
||||||
return make_response(message, 400)
|
|
||||||
## except Exception as e:
|
|
||||||
## message = jsonify(message='Error:' + str(e))
|
|
||||||
## return make_response(message, 400)
|
|
||||||
|
|
||||||
#################### Run App ############################
|
#################### Run App ############################
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user