package Promulger::Dispatch;
use Moo;
-use Method::Signatures::Simple;
use autodie ':all';
use Scalar::Util 'blessed';
);
# XXX no bounce parsing yet -- apeiron, 2010-03-13
-method dispatch ($message) {
+sub dispatch {
+ my ($self, $message) = @_;
my $config = Promulger::Config->config;
my $email = Email::MIME->new($message);
return;
}
-method handle_request ($list, $sender, $recipient, $subject) {
+sub handle_request {
+ my ($self, $list, $sender, $recipient, $subject) = @_;
my $sender_address = $self->bare_address($sender);
if($subject =~ /^\s*subscribe/i) {
$list->subscribe($sender_address)
}
}
-method post_message ($list, $email, $config) {
+sub post_message {
+ my ($self, $list, $email, $config) = @_;
my $sender = $email->header('From');
my $sender_address = $self->bare_address($sender);
my $recipient = $email->header('To');
}
}
-method send_message ($message) {
+sub send_message {
+ my ($self, $message) = @_;
Email::Sender::Simple::sendmail(
$message,
{
}
# XXX make this actually not suck -- apeiron, 2010-03-13
-method reject ($recipient, $sender) {
+sub reject {
+ my ($self, $recipient, $sender) = @_;
my $email = Email::MIME->create(
header => [
From => $recipient,
$self->send_message($email);
}
-method not_subscribed ($list, $recipient, $sender) {
+sub not_subscribed {
+ my ($self, $list, $recipient, $sender) = @_;
my $email = Email::MIME->create(
# XXX need admin address
header => [
$self->send_message($email);
}
-method already_subscribed ($list, $recipient, $sender) {
+sub already_subscribed {
+ my ($self, $list, $recipient, $sender) = @_;
my $email = Email::MIME->create(
header => [
From => $recipient,
$self->send_message($email);
}
-method bare_address ($full_addr) {
+sub bare_address {
+ my ($self, $full_addr) = @_;
my ($addr_obj) = Email::Address->parse($full_addr);
return $addr_obj->address;
}
-method user_for_address ($full_addr) {
+sub user_for_address {
+ my ($self, $full_addr) = @_;
my ($addr_obj) = Email::Address->parse($full_addr);
return $addr_obj->user;
}
use Promulger::List;
-use Method::Signatures::Simple;
-
has list_home => (
is => 'ro',
default => sub { 'etc/lists' },
}
}
-method render_index {
+sub render_index {
my ($self) = @_;
my @lists = Promulger::List->get_lists;
my $html = <<HTML;
return $html;
}
-method show_list($list_name) {
+sub show_list {
+ my ($self, $list_name) = @_;
my $list = Promulger::List->resolve($list_name);
my $name = $list->listname;
my $active = $list->active;
return $html;
}
-method subscribe($list_name, $email) {
+sub subscribe {
+ my ($self, $list_name, $email) = @_;
my $list = Promulger::List->resolve($list_name);
$list->subscribe($email);
return "<p>Subscribed ${email} to ${list_name}.</p>";
}
-method unsubscribe($list_name, $email) {
+sub unsubscribe {
+ my ($self, $list_name, $email) = @_;
my $list = Promulger::List->resolve($list_name);
$list->unsubscribe($email);
return "<p>Unsubscribed ${email} from ${list_name}.</p>";
}
-method show_subscriber($list_name, $subscriber, $extension) {
+sub show_subscriber {
+ my ($self, $list_name, $subscriber, $extension) = @_;
my $address = "${subscriber}.${extension}";
my $html = <<"HTML";
<p>Subscriber ${address}</p>