Skip to content

Commit

Permalink
Finish implementation of get_wol_mac_addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
jfmartinezm authored and kylemhall committed Oct 26, 2023
1 parent ac3af34 commit a91f744
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions lib/Libki/Clients.pm
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ sub get_wol_mac_addresses {

my ($c) = @_;

my $mac_addresses_setting = $c->setting('ClientMACAddresses');
my @mac_addresses_from_setting = split(/[\r\n]+/, $mac_addresses_setting);
my @mac_addresses_from_setting = split(/[\r\n]+/, $c->setting('ClientMACAddresses'));
my @mac_addresses = (@mac_addresses_from_setting);

my @clients_with_mac_address = $c->model('DB::client')->search( { macaddress => { '!=', undef } } );
foreach my $client (@clients_with_mac_address) {
push(@mac_addresses, $client->macaddress);
}

my @all_mac_addresses = (@mac_addresses_from_setting, @clients_with_mac_address);

return @all_mac_addresses;
return @mac_addresses;
}

=head1 AUTHOR
Expand Down
3 changes: 2 additions & 1 deletion lib/Libki/Controller/API/Client/v1_0.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use Libki::LDAP qw( authenticate_via_ldap );
use Libki::Hours qw( minutes_until_closing );
use Libki::Utils::Printing qw( create_print_job_and_file );
use Libki::Utils::User qw( create_guest );
use Libki::Clients qw( get_wol_mac_addresses );

use DateTime::Format::MySQL;
use DateTime;
Expand Down Expand Up @@ -100,7 +101,7 @@ sub index : Path : Args(0) {
} elsif ($client_status eq "wakeup") {
my $host = $c->setting('WOLHost') || '255.255.255.255';
my $port = $c->setting('WOLPort') || 9;
my @mac_addresses = split(/[\r\n]+/, $c->setting('ClientMACAddresses'));
my @mac_addresses = Libki::Clients::get_wol_mac_addresses($c);

$c->stash(
wakeup => 1,
Expand Down

0 comments on commit a91f744

Please sign in to comment.