Browse Source

Update readme about local driver, save notices per user

Andy Baugh 7 năm trước cách đây
mục cha
commit
a2ddc430d1
3 tập tin đã thay đổi với 16 bổ sung8 xóa
  1. 9 3
      README.md
  2. 4 3
      lib/Cpanel/iContact/Provider/Local.pm
  3. 3 2
      t/Cpanel-iContact-Provider-Local.t

+ 9 - 3
README.md

@@ -1,12 +1,18 @@
 # iContact-cPanel-Plugins
 Extra "Contact Manager" Providers for cPanel and WHM
 
-Current plugins:
-================
+Current iContact plugins:
+=========================
 * XMPP  -- Stable XMPP provider (well, as stable as Net::XMPP is, anyways). See issue #2
 * IRC   -- New provider, needs more testing by users out in the wild. "Works for Me"
 * Slack -- Works presuming you have an incoming WebHook URL, much like CpanelRicky's MatterMost plugin.
 * Discord -- Similar to Slack, use an incoming WebHook URL.
+* Local -- Writes the notifications to `/var/cpanel/iContact_notices/$USER` instead of sending them anywhere.
+
+Current WHM & cPanel Plugins:
+=============================
+* WHM >> Plugins >> Notification Center - Shows notifications the administrator or reseller has not reviewed yet, with options to silence these in the future.
+* cPanel >> Plugins >> Notification Center - Same thing, just for the cPanel user.
 
 Installation and Use:
 ---------------------
@@ -20,7 +26,7 @@ OR
 * Go to WHM >> Basic Setup and configure the provider options
 * Go to WHM >> Contact Manager and make sure it is set up to spam you mercilessly (and for the notifications you care about!).
 * Do something to trigger a notification that should fire notifications from cPanel & WHM per your preference in /etc/clevels.conf
-* If you tire of the modules and want to get rid of them, run `make uninstall`.
+* If you tire of this and want to get rid of them all, run `make uninstall`.
 
 KNOWN BUGS
 ----------

+ 4 - 3
lib/Cpanel/iContact/Provider/Local.pm

@@ -70,12 +70,13 @@ sub send {
     # Send it
     my $time = localtime;
     $time =~ tr/ /-/;
-    my $file = "$DIR/$time.txt";
+    my $user = getpwuid($<);
+    my $file = "$DIR/$user/$time.txt";
     try {
         # Make the dir if it doesn't exist
-        if( !-d $DIR ) {
+        if( !-d "$DIR/$user" ) {
             my $path = '/';
-            foreach my $component ( split( /\//, $DIR ) ) {
+            foreach my $component ( split( /\//, "$DIR/$user" ) ) {
                 local $!;
                 $path .= "$component/";
                 mkdir( $path ) || do {

+ 3 - 2
t/Cpanel-iContact-Provider-Local.t

@@ -25,8 +25,9 @@ subtest "Provider bits work as expected ('unit' test)" => sub {
     isa_ok( my $spammer = Cpanel::iContact::Provider::Local->new(), "Cpanel::iContact::Provider::Local" );
     my $ex = exception { $spammer->send() };
     is( $ex, undef, "send doesn't throw on GreatSuccess" ) || diag explain $ex;
-    my @files = glob( "$tmp_dir/iContact_notices/*.txt" );
-    ok( scalar(@files), "Looks like a file was written..." );
+    my $user = getpwuid($<);
+    my @files = glob( "$tmp_dir/iContact_notices/$user/*.txt" );
+    ok( scalar(@files), "Looks like a file was written..." ) || diag explain \@files;
 
     # Thu-Dec-20-13:46:46-2018 
     like( $files[0], qr/[A-Z][a-z]{2}-[A-Z][a-z]{2}-\d{2}-\d{2}:\d{2}:\d{2}-\d{4}\.txt/, "..and it looks like we'd expect it to" ) || diag explain \@files;