Skip to content

Commit acd2e7c

Browse files
committed
feat: allow admin to set default channel
A MeshChat administrator now has the ability to define the default channel that a newly logged in user is placed into. This requires that the administrator set the value `default_channel` in the configuration file. Setting `default_channel` to an empty string ('') will continue using the legacy setting of 'Everything'. Signed-off-by: Gerard Hickey <[email protected]>
1 parent 326ddba commit acd2e7c

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

meshchat

+4-1
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,14 @@ function config()
8888

8989
local settings = {
9090
version = app_version,
91+
protocol_verison = protocol_version,
9192
node = node_name(),
9293
zone = zone_name(),
94+
default_channel = default_channel,
95+
debug = debug,
9396
}
9497

95-
print(json.encode(settings))
98+
print(luci.jsonc.stringify(settings))
9699
end
97100

98101
function send_message()

meshchatconfig.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@ platform = "node"
5757
debug = 0
5858
extra_nodes = {}
5959
protocol_version = "1.02"
60-
app_version = "2.8"
60+
app_version = "master"
61+
default_channel = "chat"

www/chat.js

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var alert = new Audio('alert.mp3');
1313
var message_db_version = 0;
1414
var pending_message_db_version = 0;
1515
var search_filter = '';
16+
var default_channel = '';
1617

1718
$(function() {
1819
meshchat_init();
@@ -331,11 +332,13 @@ function process_messages() {
331332
$('#send-channel')
332333
.append($("<option></option>")
333334
.attr("value", property)
335+
.attr("selected", property == default_channel ? '' : null)
334336
.text(property));
335337

336338
$('#channels')
337339
.append($("<option></option>")
338340
.attr("value", property)
341+
.attr("selected", property == default_channel ? '' : null)
339342
.text(property));
340343
}
341344
}

www/shared.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ $(function() {
1212
$('#zone').html('<strong>Zone:</strong> ' + data.zone);
1313
$('#callsign').html('<strong>Call Sign:</strong> ' + Cookies.get('meshchat_call_sign'));
1414
$('#copyright').html('Mesh Chat v' + data.version + ' Copyright &copy; ' + new Date().getFullYear() + ' <a href="http://www.trevorsbench.com">Trevor Paskett - K7FPV</a> <small>(Lua by KN6PLV)</small>');
15+
16+
if (data.default_channel) {
17+
default_channel = data.default_channel;
18+
}
1519
});
1620
});
1721

@@ -21,7 +25,7 @@ function epoch() {
2125

2226
function format_date(date) {
2327
var string;
24-
28+
2529
var year = String(date.getFullYear());
2630

2731
string = (date.getMonth()+1) + '/' + date.getDate() + '/' + year.slice(-2);

0 commit comments

Comments
 (0)