]> dxcluster.net Git - spider.git/commitdiff
added email forwarding
authorminima <minima>
Thu, 25 Oct 2001 15:40:18 +0000 (15:40 +0000)
committerminima <minima>
Thu, 25 Oct 2001 15:40:18 +0000 (15:40 +0000)
make read increment read

Changes
cmd/Commands_en.hlp
cmd/read.pl
cmd/set/email.pl
cmd/unset/email.pl [new file with mode: 0644]
perl/DXMsg.pm
perl/DXUser.pm

diff --git a/Changes b/Changes
index 01ce2a564972f3da1f5c4db8af1b41cbe5c8246e..caf0ae37a177a16e081f301663c3b62780e137c3 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,14 @@
 25Oct01=======================================================================
 1. added unset/password command to allow sysops (only) to completely delete
 and remove a user's password.
+2. make 'read' increment the 'no of times read' for all messages.
+3. give a read receipt for everybody that reads a message so marked.
+4. enhance set/email so that if you set email address(es) with this command
+it will send any messages to your callsign as they come in. unset/email
+will disable forwarding. This probably only works for unix systems. To enable
+this feature you need to download Mail::Send from CPAN and install it.
+(http://www.cpan.org/modules/by-module/Mail/Mail-Tools-1.40.tar.gz). If you
+don't want this then it should work without.
 24Oct01=======================================================================
 1. added (un)set/register, show/registered commands which when a 'set/var
 $main::reqreg = 1' is done in the startup script will require users to 
index 09c69df3fe17889de282443e2aefd635c0bf8926..93a1da07f36b062b1f59ff793a3ffbd52cae6f9e 100644 (file)
@@ -1213,6 +1213,21 @@ The setting is stored in your user profile.
 
 YOU DO NOT NEED TO USE THIS COMMAND IF YOU ARE CONNECTED VIA AX25.
 
+=== 0^SET/EMAIL <email> ...^Set email address(es) and forward your personals
+=== 0^UNSET/EMAIL^Stop personal msgs being forwarded by email
+If any personal messages come in for your callsign then you can use
+these commands to control whether they are forwarded onto your email
+address. To enable the forwarding do something like:-
+
+  SET/EMAIL mike.tubby@somewhere.com
+
+You can have more than one email address (each one separated by a space).
+Emails are forwarded to all the email addresses you specify.
+
+You can disable forwarding by:-
+
+  UNSET/EMAIL
+
 === 0^SET/HERE^Tell the system you are present at your terminal
 === 0^UNSET/HERE^Tell the system you are absent from your terminal
 
index 21b20e0699459e407b784a6be8b24e7afafea947..1845b4d1516720ddf97951871791aa216dcd49de 100644 (file)
@@ -41,33 +41,29 @@ for $msgno (@f) {
        @body = $ref->read_msg_body;
        push @out, @body;
        
-       # mark my privates as read
-       if ($ref->private && $self->call eq $ref->to && $ref->read == 0) {
-               $ref->read(1);
-               $ref->store(\@body);    # note call by reference!
+       # mark it as read
+       $ref->read($ref->read() + 1);
+       $ref->store(\@body);    # note call by reference!
 
-               # if it had a read receipt on it generate a new message to send back to
-        # the sender.
-               if ($ref->rrreq) {
-                       my $sub = $ref->subject;
-                       $sub = "Re: $sub" unless $sub =~ /^\s*re:/i;
-                       my $to = $ref->to;
-                       my $from = $ref->from;
-                       my $rref = DXMsg->alloc(1, $from, $main::mycall, time, 
-                                                                       1, $sub, $main::mycall, 0, 0 );
-                       my $msgno = DXMsg::next_transno("Msgno");
-                       $rref->msgno($msgno);
-                       $rref->gotit( [ "$main::mycall" ] );
-                       $rref->store( [ "Return receipt from delivering node. Message read by $to." ] );
-                       DXMsg::add_dir($rref);
-                       DXMsg::queue_msg(0);
-               }
+       # if it had a read receipt on it generate a new message to send back to
+       # the sender.
+       if ($ref->rrreq) {
+               my $sub = $ref->subject;
+               $sub = "Re: $sub" unless $sub =~ /^\s*re:/i;
+               my $to = $ref->to;
+               my $from = $ref->from;
+               my $rref = DXMsg->alloc(1, $from, $main::mycall, time, 
+                                                               1, $sub, $main::mycall, 0, 0 );
+               my $msgno = DXMsg::next_transno("Msgno");
+               $rref->msgno($msgno);
+               $rref->gotit( [ "$main::mycall" ] );
+               $rref->store( [ "Return receipt from delivering node. Message read by $to." ] );
+               DXMsg::add_dir($rref);
+               DXMsg::queue_msg(0);
        }
        
        # remember this one as the last one read
        $self->lastread($msgno);
-
-
 }
 
 return (1, @out);
index ed68420eaed123b858d7075416c5c32571275d68..01c29caa03d4ec11d0bdd58e1ebe91968868e387 100644 (file)
@@ -10,16 +10,15 @@ my ($self, $line) = @_;
 my $call = $self->call;
 my $user;
 
-# remove leading and trailing spaces
-$line =~ s/^\s+//;
-$line =~ s/\s+$//;
-$line =~ s/[{}]//g;  # remove any braces
+$line =~ s/[<>()\[\]{}]//g;  # remove any braces
+my @f = split /\s+/, $line;
 
 return (1, $self->msg('emaile1')) if !$line;
 
 $user = DXUser->get_current($call);
 if ($user) {
-       $user->email($line);
+       $user->email(\@f);
+       $user->wantemail(1);
        $user->put();
        return (1, $self->msg('emaila', $line));
 } else {
diff --git a/cmd/unset/email.pl b/cmd/unset/email.pl
new file mode 100644 (file)
index 0000000..2829a19
--- /dev/null
@@ -0,0 +1,21 @@
+#
+# unset the email address  of the user
+#
+# Copyright (c) 2001 - Dirk Koopman G1TLH
+#
+# $Id$
+#
+
+my ($self, $line) = @_;
+my $call = $self->call;
+my $user;
+
+$user = DXUser->get_current($call);
+if ($user) {
+       $user->wantemail(0);
+       $user->put();
+       return (1, $self->msg('emaila', $line));
+} else {
+       return (1, $self->msg('namee2', $call));
+}
+
index 04239f16b6777581ade86c2cb0f036f087d1f42b..f60b59038e274f77b6468b85886ab1c998c9a8c0 100644 (file)
@@ -26,6 +26,10 @@ use DXLog;
 use IO::File;
 use Fcntl;
 
+eval {
+       require Mail::Send;
+};
+
 use strict;
 
 use vars qw($VERSION $BRANCH);
@@ -322,9 +326,8 @@ sub process
                                                $ref->{msgno} = next_transno("Msgno");
                                                push @{$ref->{gotit}}, $fromnode; # mark this up as being received
                                                $ref->store($ref->{lines});
+                                               $ref->notify;
                                                add_dir($ref);
-                                               my $dxchan = DXChannel->get($ref->{to});
-                                               $dxchan->send($dxchan->msg('m9')) if $dxchan && $dxchan->is_user;
                                                Log('msg', "Message $ref->{msgno} from $ref->{from} received from $fromnode for $ref->{to}");
                                        }
                                }
@@ -418,6 +421,30 @@ sub process
 }
 
 
+sub notify
+{
+       my $ref = shift;
+       my $to = $ref->{to};
+       my $uref = DXUser->get($to);
+       my $dxchan = DXChannel->get($to);
+       if (*Mail::Send && $uref && $uref->wantemail) {
+               my $email = $uref->email;
+               if ($email) {
+                       my @list = ref $email ? @{$email} : $email;
+                       my $msg = new Mail::Send Subject=>"[DXSpider: $ref->{from}] $ref->{subject}";
+                       $msg->to(@list);
+                       my $fh = $msg->open;
+                       print $fh "From: $ref->{from} To: $to On Node: $main::mycall Origin: $ref->{origin} Msgno: $ref->{msgno}\r\n\r\n";
+                       print $fh map {"$_\r\n"} $ref->read_msg_body;
+                       $fh->close;
+                       for (@list) {
+                               Log('msg', "Msgno $ref->{msgno} from $ref->{from} emailed to $_");
+                       }
+               }
+       }
+       $dxchan->send($dxchan->msg('m9')) if $dxchan && $dxchan->is_user;
+}
+
 # store a message away on disc or whatever
 #
 # NOTE the second arg is a REFERENCE not a list
@@ -990,12 +1017,7 @@ sub do_send_stuff
                                        $ref->add_dir();
                                        push @out, $self->msg('m11', $ref->{msgno}, $to);
                                        #push @out, "msgno $ref->{msgno} sent to $to";
-                                       my $dxchan = DXChannel->get(uc $to);
-                                       if ($dxchan) {
-                                               if ($dxchan->is_user()) {
-                                                       $dxchan->send($dxchan->msg('m9'));
-                                               }
-                                       }
+                                       $ref->notify;
                                }
                        } else {
                                Log('msg', $self->call . " swore to @{$loc->{to}} subject: '$loc->{subject}' in msg, REJECTED");
@@ -1366,12 +1388,7 @@ sub import_one
                        $mref->add_dir();
                        push @out, $dxchan->msg('m11', $mref->{msgno}, $to);
                        #push @out, "msgno $ref->{msgno} sent to $to";
-                       my $todxchan = DXChannel->get(uc $to);
-                       if ($todxchan) {
-                               if ($todxchan->is_user()) {
-                                       $todxchan->send($todxchan->msg('m9'));
-                               }
-                       }
+                       $mref->notify;
                }
        }
        return @out;
index c9725f271e5b804cb6581e02a859e8e2e335fbae..26c3f5db3cbc57cbcbd0fc7cf3a718e567af4162 100644 (file)
@@ -65,6 +65,7 @@ $lasttime = 0;
                  wanttalk => '0,Rec Talk,yesno',
                  wantwx => '0,Rec WX,yesno',
                  wantdx => '0,Rec DX Spots,yesno',
+                 wantemail => '0,Rec Msgs as Email,yesno',
                  pagelth => '0,Current Pagelth',
                  pingint => '9,Node Ping interval',
                  nopings => '9,Ping Obs Count',
@@ -520,6 +521,11 @@ sub wantgrid
        return _want('grid', @_);
 }
 
+sub wantemail
+{
+       return _want('email', @_);
+}
+
 sub wantann_talk
 {
        return _want('ann_talk', @_);