Skip to content

Commit

Permalink
feat: allow admin to set default channel
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
hickey committed Nov 21, 2023
1 parent 326ddba commit acd2e7c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion meshchat
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,14 @@ function config()

local settings = {
version = app_version,
protocol_verison = protocol_version,
node = node_name(),
zone = zone_name(),
default_channel = default_channel,
debug = debug,
}

print(json.encode(settings))
print(luci.jsonc.stringify(settings))
end

function send_message()
Expand Down
3 changes: 2 additions & 1 deletion meshchatconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ platform = "node"
debug = 0
extra_nodes = {}
protocol_version = "1.02"
app_version = "2.8"
app_version = "master"
default_channel = "chat"
3 changes: 3 additions & 0 deletions www/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var alert = new Audio('alert.mp3');
var message_db_version = 0;
var pending_message_db_version = 0;
var search_filter = '';
var default_channel = '';

$(function() {
meshchat_init();
Expand Down Expand Up @@ -331,11 +332,13 @@ function process_messages() {
$('#send-channel')
.append($("<option></option>")
.attr("value", property)
.attr("selected", property == default_channel ? '' : null)
.text(property));

$('#channels')
.append($("<option></option>")
.attr("value", property)
.attr("selected", property == default_channel ? '' : null)
.text(property));
}
}
Expand Down
6 changes: 5 additions & 1 deletion www/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ $(function() {
$('#zone').html('<strong>Zone:</strong> ' + data.zone);
$('#callsign').html('<strong>Call Sign:</strong> ' + Cookies.get('meshchat_call_sign'));
$('#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>');

if (data.default_channel) {
default_channel = data.default_channel;
}
});
});

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

function format_date(date) {
var string;

var year = String(date.getFullYear());

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

0 comments on commit acd2e7c

Please sign in to comment.