add Bulletin Board, add server and system name to SMS Log and BB
This commit is contained in:
parent
857c397693
commit
9dc5693dd6
@ -149,7 +149,7 @@ def send_dash_loc(CONFIG, call, lat, lon, time, comment, dmr_id):
|
||||
except requests.ConnectionError:
|
||||
logger.error('Config server unreachable')
|
||||
|
||||
def send_sms_log(CONFIG, snd_call, rcv_call, msg, rcv_id, snd_id):
|
||||
def send_sms_log(CONFIG, snd_call, rcv_call, msg, rcv_id, snd_id, system_name):
|
||||
user_man_url = CONFIG['WEB_SERVICE']['URL']
|
||||
shared_secret = str(sha256(CONFIG['WEB_SERVICE']['SHARED_SECRET'].encode()).hexdigest())
|
||||
sms_data = {
|
||||
@ -159,7 +159,29 @@ def send_sms_log(CONFIG, snd_call, rcv_call, msg, rcv_id, snd_id):
|
||||
'rcv_call': rcv_call,
|
||||
'message' : msg,
|
||||
'snd_id' : snd_id,
|
||||
'rcv_id' : rcv_id
|
||||
'rcv_id' : rcv_id,
|
||||
'system_name': system_name
|
||||
}
|
||||
json_object = json.dumps(sms_data, indent = 4)
|
||||
|
||||
try:
|
||||
req = requests.post(user_man_url, data=json_object, headers={'Content-Type': 'application/json'})
|
||||
## resp = json.loads(req.text)
|
||||
## print(resp)
|
||||
## return resp['rules']
|
||||
except requests.ConnectionError:
|
||||
logger.error('Config server unreachable')
|
||||
|
||||
def send_bb(CONFIG, callsign, dmr_id, bulletin, system_name):
|
||||
user_man_url = CONFIG['WEB_SERVICE']['URL']
|
||||
shared_secret = str(sha256(CONFIG['WEB_SERVICE']['SHARED_SECRET'].encode()).hexdigest())
|
||||
sms_data = {
|
||||
'bb_send': CONFIG['WEB_SERVICE']['THIS_SERVER_NAME'],
|
||||
'secret':shared_secret,
|
||||
'callsign': callsign,
|
||||
'dmr_id': dmr_id,
|
||||
'bulletin': bulletin,
|
||||
'system_name' : system_name
|
||||
}
|
||||
json_object = json.dumps(sms_data, indent = 4)
|
||||
|
||||
@ -170,7 +192,6 @@ def send_sms_log(CONFIG, snd_call, rcv_call, msg, rcv_id, snd_id):
|
||||
## return resp['rules']
|
||||
except requests.ConnectionError:
|
||||
logger.error('Config server unreachable')
|
||||
## return config.build_config(cli_file)
|
||||
|
||||
|
||||
|
||||
@ -257,7 +278,10 @@ def dashboard_loc_write(call, lat, lon, time, comment, dmr_id):
|
||||
logger.info('User location saved for dashboard')
|
||||
#logger.info(dash_entries)
|
||||
|
||||
def dashboard_bb_write(call, dmr_id, time, bulletin):
|
||||
def dashboard_bb_write(call, dmr_id, time, bulletin, system_name):
|
||||
if CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == True:
|
||||
send_bb(CONFIG, call, dmr_id, bulletin, system_name)
|
||||
else:
|
||||
#try:
|
||||
dash_bb = ast.literal_eval(os.popen('cat ' + bb_file).read())
|
||||
# except:
|
||||
@ -269,9 +293,9 @@ def dashboard_bb_write(call, dmr_id, time, bulletin):
|
||||
logger.info('User bulletin entry saved.')
|
||||
#logger.info(dash_bb)
|
||||
|
||||
def dashboard_sms_write(snd_call, rcv_call, rcv_dmr_id, snd_dmr_id, sms, time):
|
||||
def dashboard_sms_write(snd_call, rcv_call, rcv_dmr_id, snd_dmr_id, sms, time, system_name):
|
||||
if CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == True:
|
||||
send_sms_log(CONFIG, snd_call, rcv_call, sms, rcv_dmr_id, snd_dmr_id)
|
||||
send_sms_log(CONFIG, snd_call, rcv_call, sms, rcv_dmr_id, snd_dmr_id, system_name)
|
||||
else:
|
||||
#try:
|
||||
dash_sms = ast.literal_eval(os.popen('cat ' + sms_file).read())
|
||||
@ -467,7 +491,7 @@ def user_setting_write(dmr_id, setting, value, call_type):
|
||||
|
||||
# Process SMS, do something bases on message
|
||||
|
||||
def process_sms(_rf_src, sms, call_type):
|
||||
def process_sms(_rf_src, sms, call_type, system_name):
|
||||
logger.info(call_type)
|
||||
parse_sms = sms.split(' ')
|
||||
logger.info(parse_sms)
|
||||
@ -497,7 +521,7 @@ def process_sms(_rf_src, sms, call_type):
|
||||
elif '@APRS OFF' in sms or '@APRS off' in sms:
|
||||
user_setting_write(int_id(_rf_src), 'APRS OFF', False, call_type)
|
||||
elif '@BB' in sms:
|
||||
dashboard_bb_write(get_alias(int_id(_rf_src), subscriber_ids), int_id(_rf_src), time(), re.sub('@BB|@BB ','',sms))
|
||||
dashboard_bb_write(get_alias(int_id(_rf_src), subscriber_ids), int_id(_rf_src), time(), re.sub('@BB|@BB ','',sms), system_name)
|
||||
elif '@' in parse_sms[0][1:] and '.' in parse_sms[0]: # and ' E-' in sms:
|
||||
s = ' '
|
||||
email_message = s.join(parse_sms[1:])#str(re.sub('.*@|.* E-', '', sms))
|
||||
@ -1226,9 +1250,10 @@ def data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _fr
|
||||
sms = codecs.decode(bytes.fromhex(''.join(sms_hex_string[:-8].split('00'))), 'utf-8', 'ignore')
|
||||
msg_found = re.sub('.*\n', '', sms)
|
||||
logger.info('\n\n' + 'Received SMS from ' + str(get_alias(int_id(_rf_src), subscriber_ids)) + ', DMR ID: ' + str(int_id(_rf_src)) + ': ' + str(msg_found) + '\n')
|
||||
|
||||
if int_id(_dst_id) == data_id:
|
||||
process_sms(_rf_src, msg_found, _call_type)
|
||||
dashboard_sms_write(str(get_alias(int_id(_rf_src), subscriber_ids)), str(get_alias(int_id(_dst_id), subscriber_ids)), int_id(_dst_id), int_id(_rf_src), msg_found, time())
|
||||
process_sms(_rf_src, msg_found, _call_type, UNIT_MAP[_rf_src][0])
|
||||
dashboard_sms_write(str(get_alias(int_id(_rf_src), subscriber_ids)), str(get_alias(int_id(_dst_id), subscriber_ids)), int_id(_dst_id), int_id(_rf_src), msg_found, time(), UNIT_MAP[_rf_src][0])
|
||||
#packet_assembly = ''
|
||||
pass
|
||||
#logger.info(bitarray(re.sub("\)|\(|bitarray|'", '', str(bptc_decode(_data)).tobytes().decode('utf-8', 'ignore'))))
|
||||
|
49
web/app.py
49
web/app.py
@ -782,7 +782,7 @@ def hbnet_web_service():
|
||||
return render_template('single_map_peer.html', markup_content = Markup(content))
|
||||
|
||||
@app.route('/map')
|
||||
@login_required
|
||||
## @login_required
|
||||
def map_page():
|
||||
dev_loc = GPS_LocLog.query.order_by(GPS_LocLog.time.desc()).limit(300).all()
|
||||
dev_list = []
|
||||
@ -2351,9 +2351,26 @@ TG #: <strong> ''' + str(tg_d.tg) + '''</strong>
|
||||
<td>''' + i.snd_callsign + ''' \n ''' + str(i.snd_id) + '''</td>
|
||||
<td>''' + i.rcv_callsign + ''' \n ''' + str(i.rcv_id) + '''</td>
|
||||
<td>''' + i.message + '''</td>
|
||||
<td>''' + i.server + ' - ' + i.system_name + '''</td>
|
||||
|
||||
</tr>'''
|
||||
return render_template('sms.html', markup_content = Markup(content))
|
||||
|
||||
@app.route('/bb')
|
||||
def all_bb():
|
||||
bbl = BulletinBoard.query.order_by(BulletinBoard.time.desc()).all()
|
||||
content = ''' '''
|
||||
for i in bbl:
|
||||
content = content + '''
|
||||
<tr>
|
||||
<td>''' + i.callsign + ''' \n ''' + str(i.dmr_id) + '''</td>
|
||||
<td>''' + i.bulletin + '''</td>
|
||||
<td>''' + str(i.time.strftime(time_format)) + '''</td>
|
||||
<td>''' + i.server + ' - ' + i.system_name + '''</td>
|
||||
|
||||
</tr>'''
|
||||
return render_template('bb.html', markup_content = Markup(content))
|
||||
|
||||
@app.route('/talkgroups/<server>') #, methods=['POST', 'GET'])
|
||||
@login_required
|
||||
def tg_list_server(server):
|
||||
@ -2589,6 +2606,18 @@ TG #: <strong> ''' + str(tg_d.tg) + '''</strong>
|
||||
db.session.add(add_loc)
|
||||
db.session.commit()
|
||||
|
||||
def bb_add(_callsign, _bulletin, _dmr_id, _server, _system_name):
|
||||
add_bb = BulletinBoard(
|
||||
callsign = _callsign,
|
||||
bulletin = _bulletin,
|
||||
time = datetime.datetime.utcnow(),
|
||||
dmr_id = _dmr_id,
|
||||
server = _server,
|
||||
system_name = _system_name
|
||||
)
|
||||
db.session.add(add_bb)
|
||||
db.session.commit()
|
||||
|
||||
def sms_log_add(_snd_call, _rcv_call, _msg, _snd_id, _rcv_id, _server, _system_name):
|
||||
add_sms = SMSLog(
|
||||
snd_callsign = _snd_call,
|
||||
@ -2598,11 +2627,20 @@ TG #: <strong> ''' + str(tg_d.tg) + '''</strong>
|
||||
snd_id = _snd_id,
|
||||
rcv_id = _rcv_id,
|
||||
server = _server,
|
||||
system_name = ''
|
||||
system_name = _system_name
|
||||
)
|
||||
db.session.add(add_sms)
|
||||
db.session.commit()
|
||||
|
||||
def trim_bb():
|
||||
trim_bb = BulletinBoard.query.all()
|
||||
|
||||
for i in trim_bb:
|
||||
elap_time = int(datetime.datetime.utcnow().strftime('%s')) - int(i.time.strftime('%s'))
|
||||
# Remove entries more than 1 month old
|
||||
if elap_time > 2678400:
|
||||
db.session.delete(i)
|
||||
|
||||
def trim_sms_log():
|
||||
trim_sms = SMSLog.query.all()
|
||||
|
||||
@ -6095,10 +6133,13 @@ TG #: <strong> ''' + str(tg_d.tg) + '''</strong>
|
||||
trim_dash_loc()
|
||||
response = 'yes'
|
||||
elif 'log_sms' in hblink_req:
|
||||
sms_log_add(hblink_req['snd_call'], hblink_req['rcv_call'], hblink_req['message'], hblink_req['snd_id'], hblink_req['rcv_id'], '', '')
|
||||
sms_log_add(hblink_req['snd_call'], hblink_req['rcv_call'], hblink_req['message'], hblink_req['snd_id'], hblink_req['rcv_id'], hblink_req['log_sms'], hblink_req['system_name'])
|
||||
trim_sms_log()
|
||||
response = 'rcvd'
|
||||
elif 'bb_send' in hblink_req:
|
||||
bb_add(hblink_req['callsign'], hblink_req['bulletin'], hblink_req['dmr_id'], hblink_req['bb_send'], hblink_req['system_name'])
|
||||
trim_sms_log()
|
||||
response = 'rcvd'
|
||||
|
||||
|
||||
elif 'get_config' in hblink_req:
|
||||
if hblink_req['get_config']:
|
||||
|
29
web/templates/bb.html
Normal file
29
web/templates/bb.html
Normal file
@ -0,0 +1,29 @@
|
||||
{% extends 'flask_user/_public_base.html' %}
|
||||
{% block content %}
|
||||
|
||||
<h1 style="text-align: center;">Bulletin Board</h1>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<table data-toggle="table" data-pagination="true" data-search="true" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Callsign</th>
|
||||
<th>Bulltein</th>
|
||||
<th>Time</th>
|
||||
<th>Server</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{markup_content}}
|
||||
|
||||
</tbody></table>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p> </p>
|
||||
{% endblock %}
|
@ -9,6 +9,7 @@
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.15.5/dist/bootstrap-table.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css">
|
||||
|
||||
|
||||
<!-- In-lining styles to avoid needing a separate .css file -->
|
||||
@ -44,26 +45,30 @@
|
||||
<!-- Links -->
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{url}}/"> Home </a>
|
||||
<a class="nav-link" href="{{url}}/"><i class="bi bi-house-fill"></i> Home </a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{url}}/talkgroups"> Talkgroups </a>
|
||||
|
||||
<a class="nav-link" href="{{url}}/talkgroups"><i class="bi bi-card-list"></i> Talkgroups </a>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{url}}/map"><i class="bi bi-map"></i> Map </a>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="aprs_menu" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
APRS/SMS
|
||||
<i class="bi bi-hash"></i> APRS/SMS
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="aprs_menu">
|
||||
<li><a class="dropdown-item" href="{{url}}/aprs">APRS Dashboard</a></li>
|
||||
<li><a class="dropdown-item" href="{{url}}/sms">SMS Log</a></li>
|
||||
<li><a class="dropdown-item" href="{{url}}/aprs"><i class="bi bi-geo"></i> APRS Dashboard </a></li>
|
||||
<li><a class="dropdown-item" href="{{url}}/sms"><i class="bi bi-chat-right-text"></i> SMS Log </a></li>
|
||||
<li><a class="dropdown-item" href="{{url}}/bb"><i class="bi bi-clipboard"></i> Bulletin Board </a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{url}}/news"> News </a>
|
||||
<a class="nav-link" href="{{url}}/news"><i class="bi bi-newspaper"></i> News </a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{url}}/help"> Help </a>
|
||||
<a class="nav-link" href="{{url}}/help"><i class="bi bi-question-square"></i> Help </a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@ -74,7 +79,7 @@
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="aprs_menu" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Admin
|
||||
<i class="bi bi-tools"></i> Admin
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="mmdvm_admin">
|
||||
<li><a class="dropdown-item" href="{{url}}/manage_servers">Manage Servers</a></li>
|
||||
@ -101,24 +106,21 @@
|
||||
<ul class="navbar-nav">
|
||||
{% if not call_or_get(current_user.is_authenticated) %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('user.login') }}">Sign In</a>
|
||||
<a class="nav-link" href="{{ url_for('user.login') }}"><i class="bi bi-door-open"></i> Sign In </a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('user.register') }}">Register</a>
|
||||
<a class="nav-link" href="{{ url_for('user.register') }}"> Register </a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if call_or_get(current_user.is_authenticated) %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{url}}/map">Map</a>
|
||||
<a class="nav-link" href="{{url}}/generate_passphrase"><i class="bi bi-info-square"></i> Passphrase(s) </a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{url}}/generate_passphrase">Passphrase(s)</a>
|
||||
<a class="nav-link" href="{{ url_for('user.edit_user_profile') }}"><i class="bi bi-file-person"></i> Change {{ current_user.username or current_user.email }} </a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('user.edit_user_profile') }}">Change {{ current_user.username or current_user.email }}</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('user.logout') }}">Sign Out</a>
|
||||
<a class="nav-link" href="{{ url_for('user.logout') }}"><i class="bi bi-door-closed"></i> Sign Out </a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
|
@ -9,9 +9,10 @@
|
||||
<table data-toggle="table" data-pagination="true" data-search="true" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Senderl</th>
|
||||
<th>Sender</th>
|
||||
<th>Receiver</th>
|
||||
<th>Message</th>
|
||||
<th>Server</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
Loading…
Reference in New Issue
Block a user