summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2006-01-07 14:43:25 +0000
committerfukachan <fukachan>2006-01-07 14:43:25 +0000
commit25d1cf9ab50bc471d9950bf0c52d951606d63f43 (patch)
tree6f9461ae8e50f0caebf7cc6cffdc14c4421bbdc6
parentdfe9c96d982bd1742bb400c40f5f85fe2781d63e (diff)
downloadfml8-25d1cf9ab50bc471d9950bf0c52d951606d63f43.tar.gz
fml8-25d1cf9ab50bc471d9950bf0c52d951606d63f43.tar.bz2
fml8-25d1cf9ab50bc471d9950bf0c52d951606d63f43.zip
move location of reseting compare_level.
rewritten to call FML::Command::Message->send_notification() not direct reply_message() calls in Command::User:: class. send_notification() works differently according to the value of $XXX_command_auth_type variable.
-rw-r--r--fml/lib/FML/Command/Message.pm140
-rw-r--r--fml/lib/FML/Command/User/chaddr.pm17
-rw-r--r--fml/lib/FML/Command/User/subscribe.pm14
-rw-r--r--fml/lib/FML/Command/User/unsubscribe.pm14
4 files changed, 167 insertions, 18 deletions
diff --git a/fml/lib/FML/Command/Message.pm b/fml/lib/FML/Command/Message.pm
new file mode 100644
index 00000000..b4d7f946
--- /dev/null
+++ b/fml/lib/FML/Command/Message.pm
@@ -0,0 +1,140 @@
+#-*- perl -*-
+#
+# Copyright (C) 2006 Ken'ichi Fukamachi
+# All rights reserved. This program is free software; you can
+# redistribute it and/or modify it under the same terms as Perl itself.
+#
+# $FML$
+#
+
+package FML::Command::Message;
+use strict;
+use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
+use Carp;
+
+=head1 NAME
+
+FML::Command::Message - what is this
+
+=head1 SYNOPSIS
+
+=head1 DESCRIPTION
+
+=head1 METHODS
+
+=head2 C<new()>
+
+constructor.
+
+=cut
+
+
+# Descriptions: constructor.
+# Arguments: OBJ($self)
+# Side Effects: none
+# Return Value: OBJ
+sub new
+{
+ my ($self) = @_;
+ my ($type) = ref($self) || $self;
+ my $me = {};
+ return bless $me, $type;
+}
+
+
+=head2 send_confirmation($curproc, $command_args, $confirm, $sc_args)
+
+send back confirmation message.
+
+1. if $XXX_command_auth_type == confirmation,
+1.1 send back confirmation to address (From:).
+
+2. if $XXX_command_auth_type == manual,
+2.1 notify "forwarded request to maintainer(s)." to sender.
+2.2 notify request to maintainer(s).
+
+=cut
+
+
+# Descriptions: send back confirmation message.
+# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args)
+# OBJ($confirm) HASH_REF($sc_args)
+# Side Effects: messages sent.
+# Return Value: none
+sub send_confirmation
+{
+ my ($self, $curproc, $command_args, $confirm, $sc_args) = @_;
+ my $config = $curproc->config();
+ my $id = $confirm->assign_id;
+ my $command = $sc_args->{ command } || "";
+ my $rm_args = $sc_args->{ rm_args } || {};
+ my $varname = "${command}_command_auth_type";
+ my $mode = $config->{ $varname } || 'confirmation';
+
+ # 1. send back confirmation to address (From:) by default.
+ # if XXX_command_auth_type == confirmation
+ # send back confirmation to $sender.
+ # $sender send back again the confirmation to fml8.
+ # fml8 do actual subscription et.al. automatically.
+ # So, $maintainer do nothing.
+ if ($mode eq 'confirmation') {
+ $curproc->reply_message_nl('command.confirm', "", $rm_args);
+ $curproc->reply_message("\n$id\n", $rm_args);
+ }
+ # 2. forward request to maintainer(s) "without confirmation".
+ # if XXX_command_auth_type == manual
+ # forward the request to $maintainer.
+ # The maintainer do actual subscription et.al. automatically.
+ # So, fml8 do nothing.
+ elsif ($mode eq 'manual') {
+ my $msg = $curproc->incoming_message();
+ my $maintainer = $config->{ maintainer };
+ my $_rm_args = {
+ recipient => $maintainer,
+ _arg_command => $command,
+ };
+ my $default = "send back the following confirmation.";
+
+ # 2.1 notify "forwarded request to maintainer(s)." to sender.
+ $curproc->reply_message_nl('command.forward_request_to_admin',
+ "",
+ $rm_args);
+
+ # 2.2 notify request to maintainer(s).
+ $curproc->reply_message_nl('command.receive_request', "", $_rm_args);
+ $curproc->reply_message_nl('command.confirm', $default, $_rm_args);
+ $curproc->reply_message("\n$id\n", $_rm_args);
+ $curproc->reply_message($msg, $_rm_args);
+ }
+ # 3. fatal error if neither of automatic nor manual.
+ else {
+ $curproc->logerror("unknown operation mode");
+ croak("unknown operation mode");
+ }
+}
+
+
+=head1 CODING STYLE
+
+See C<http://www.fml.org/software/FNF/> on fml coding style guide.
+
+=head1 AUTHOR
+
+Ken'ichi Fukamachi
+
+=head1 COPYRIGHT
+
+Copyright (C) 2006 Ken'ichi Fukamachi
+
+All rights reserved. This program is free software; you can
+redistribute it and/or modify it under the same terms as Perl itself.
+
+=head1 HISTORY
+
+FML::Command::Message appeared in fml8 mailing list driver package.
+See C<http://www.fml.org/> for more details.
+
+=cut
+
+
+1;
diff --git a/fml/lib/FML/Command/User/chaddr.pm b/fml/lib/FML/Command/User/chaddr.pm
index d486ef88..1e737e1b 100644
--- a/fml/lib/FML/Command/User/chaddr.pm
+++ b/fml/lib/FML/Command/User/chaddr.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: chaddr.pm,v 1.33 2005/11/30 23:30:38 fukachan Exp $
+# $FML: chaddr.pm,v 1.34 2005/11/30 23:34:45 fukachan Exp $
#
package FML::Command::User::chaddr;
@@ -172,6 +172,8 @@ sub process
# 1. request from $old_addr : $old_addr (member now) -> $new_addr
# 2. request from $new_addr : $old_addr -> $new_addr (member now)
if ($cred->is_member($old_addr) || $cred->is_member($new_addr)) {
+ $cred->set_compare_level( $compare_level );
+
$curproc->log("chaddr request, try confirmation");
# XXX-TODO: no confirmation case ?
@@ -184,9 +186,14 @@ sub process
address => "$old_addr $new_addr",
buffer => $command,
};
- my $id = $confirm->assign_id;
- $curproc->reply_message_nl('command.confirm', '', $optargs);
- $curproc->reply_message("\n$id\n", $optargs);
+
+ use FML::Command::Message;
+ my $_msg = new FML::Command::Message;
+ my $sc_args = {
+ command => "chaddr",
+ rm_args => $optargs,
+ };
+ $_msg->send_confirmation($curproc, $command_args, $confirm, $sc_args);
}
# try confirmation before chaddr.
else {
@@ -194,8 +201,6 @@ sub process
$cred->set_compare_level( $compare_level );
croak("not member");
}
-
- $cred->set_compare_level( $compare_level );
}
diff --git a/fml/lib/FML/Command/User/subscribe.pm b/fml/lib/FML/Command/User/subscribe.pm
index 97921978..202b604e 100644
--- a/fml/lib/FML/Command/User/subscribe.pm
+++ b/fml/lib/FML/Command/User/subscribe.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: subscribe.pm,v 1.33 2005/08/11 04:07:33 fukachan Exp $
+# $FML: subscribe.pm,v 1.34 2005/11/30 23:30:38 fukachan Exp $
#
package FML::Command::User::subscribe;
@@ -116,6 +116,8 @@ sub process
}
# if not, try confirmation before subscribe
else {
+ $cred->set_compare_level( $compare_level );
+
$curproc->log("new subscriber, try confirmation");
use FML::Confirm;
my $confirm = new FML::Confirm $curproc, {
@@ -125,12 +127,12 @@ sub process
address => $address,
buffer => $command,
};
- my $id = $confirm->assign_id;
- $curproc->reply_message_nl('command.confirm');
- $curproc->reply_message("\n$id\n");
- }
- $cred->set_compare_level( $compare_level );
+ use FML::Command::Message;
+ my $_msg = new FML::Command::Message;
+ my $sc_args = { command => "subscribe" };
+ $_msg->send_confirmation($curproc, $command_args, $confirm, $sc_args);
+ }
}
diff --git a/fml/lib/FML/Command/User/unsubscribe.pm b/fml/lib/FML/Command/User/unsubscribe.pm
index 0d0ba6d7..d36662ab 100644
--- a/fml/lib/FML/Command/User/unsubscribe.pm
+++ b/fml/lib/FML/Command/User/unsubscribe.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: unsubscribe.pm,v 1.34 2005/08/11 04:07:33 fukachan Exp $
+# $FML: unsubscribe.pm,v 1.35 2005/11/30 23:30:38 fukachan Exp $
#
package FML::Command::User::unsubscribe;
@@ -112,6 +112,8 @@ sub process
}
# try confirmation before unsubscribe
else {
+ $cred->set_compare_level( $compare_level );
+
$curproc->log("unsubscribe request, try confirmation");
use FML::Confirm;
@@ -122,12 +124,12 @@ sub process
address => $address,
buffer => $command,
};
- my $id = $confirm->assign_id;
- $curproc->reply_message_nl('command.confirm');
- $curproc->reply_message("\n$id\n");
- }
- $cred->set_compare_level( $compare_level );
+ use FML::Command::Message;
+ my $_msg = new FML::Command::Message;
+ my $sc_args = { command => "unsubscribe" };
+ $_msg->send_confirmation($curproc, $command_args, $confirm, $sc_args);
+ }
}