Эх сурвалжийг харах

Add HTML output to local driver

Andy Baugh 7 жил өмнө
parent
commit
9426a4f356

+ 2 - 0
lib/Cpanel/iContact/Provider.pm

@@ -9,6 +9,7 @@ use warnings;
 sub new {
     my $class = shift;
     my $text_body = 'HOLY CRAP THE AUTO-LAYOFF THING TRIGGERED';
+    my $html_body = "<p>$text_body</p>";
     my $self = {
         'contact' => {
             'XMPPUSERNAME'      => 'mr_t@a-team.gov',
@@ -23,6 +24,7 @@ sub new {
         'args' => {
             'subject'   => 'cPanel on Drugs',
             'text_body' => \$text_body, #nutty, I know
+            'html_body' => \$html_body,
             'to'        => [ 'cronspam@dev.null' ],
         }
     };

+ 2 - 2
lib/Cpanel/iContact/Provider/Local.pm

@@ -65,7 +65,7 @@ sub send {
 
     my $subject = $args_hr->{'subject'};
     my $text    = ${ $args_hr->{'text_body'} };
-    # my $html    = ${ $args_hr->{'html_body'} };
+    my $html    = ${ $args_hr->{'html_body'} };
 
     # Send it
     my $time = time;
@@ -86,7 +86,7 @@ sub send {
         }
 	    require Cpanel::AdminBin::Serializer;
         open( my $fh, ">", $file ) || die "Couldn't open '$file': $!";
-        print $fh Cpanel::AdminBin::Serializer::Dump( { 'subject' => $subject, 'text' => $text } );
+        print $fh Cpanel::AdminBin::Serializer::Dump( { 'subject' => $subject, 'text' => $text, 'html' => $html } );
         close $fh;
     }
     catch {

+ 1 - 1
t/Cpanel-iContact-Provider-Local.t

@@ -35,5 +35,5 @@ subtest "Provider bits work as expected ('unit' test)" => sub {
     my %notifications = Cpanel::iContact::Provider::Local::Getter::get_all_notices( 'user' => $user );
     ok( scalar(keys(%notifications)), "Got the expected notifications from hash..." ) || diag explain \%notifications;
     like( (keys(%notifications))[0], qr/\d+/, "..and the hash key looks like we'd expect it to" ) || diag explain \%notifications;
-    is_deeply( [ sort keys(%{ $notifications{(keys(%notifications))[0]} }) ], [ 'subject', 'text' ], "%notifications{time} hashref has has the right keys" );
+    is_deeply( [ sort keys(%{ $notifications{(keys(%notifications))[0]} }) ], [ 'html', 'subject', 'text' ], "%notifications{time} hashref has has the right keys" );
 };