From: minima Date: Thu, 25 Oct 2001 15:40:18 +0000 (+0000) Subject: added email forwarding X-Git-Tag: R_1_49~34 X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=commitdiff_plain;h=47bc13ac2b52dd67972c24017d7f6a41ac601611;p=spider.git added email forwarding make read increment read --- diff --git a/Changes b/Changes index 01ce2a56..caf0ae37 100644 --- 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 diff --git a/cmd/Commands_en.hlp b/cmd/Commands_en.hlp index 09c69df3..93a1da07 100644 --- a/cmd/Commands_en.hlp +++ b/cmd/Commands_en.hlp @@ -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 ...^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 diff --git a/cmd/read.pl b/cmd/read.pl index 21b20e06..1845b4d1 100644 --- a/cmd/read.pl +++ b/cmd/read.pl @@ -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); diff --git a/cmd/set/email.pl b/cmd/set/email.pl index ed68420e..01c29caa 100644 --- a/cmd/set/email.pl +++ b/cmd/set/email.pl @@ -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 index 00000000..2829a194 --- /dev/null +++ b/cmd/unset/email.pl @@ -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)); +} + diff --git a/perl/DXMsg.pm b/perl/DXMsg.pm index 04239f16..f60b5903 100644 --- a/perl/DXMsg.pm +++ b/perl/DXMsg.pm @@ -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; diff --git a/perl/DXUser.pm b/perl/DXUser.pm index c9725f27..26c3f5db 100644 --- a/perl/DXUser.pm +++ b/perl/DXUser.pm @@ -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', @_);