aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Fripost/Schema/List.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Fripost/Schema/List.pm')
-rw-r--r--lib/Fripost/Schema/List.pm92
1 files changed, 76 insertions, 16 deletions
diff --git a/lib/Fripost/Schema/List.pm b/lib/Fripost/Schema/List.pm
index c6fb4f2..69317b1 100644
--- a/lib/Fripost/Schema/List.pm
+++ b/lib/Fripost/Schema/List.pm
@@ -39,17 +39,21 @@ sub search {
my %options = @_;
my $concat = $options{'-concat'};
+ my $filter = 'objectClass=FripostVirtualList';
+ $filter = '(&('.$filter.')(!(fripostIsStatusPending=TRUE)))'
+ if (defined $options{'-is_pending'}) and !$options{'-is_pending'};
+
my $lists = $self->ldap->search(
base => "fvd=$domain,".$self->suffix,
scope => 'one',
deref => 'never',
- filter => 'objectClass=FripostVirtualList',
+ filter => $filter,
attrs => [ qw/fvl description fripostIsStatusActive
fripostListManager/ ]
);
if ($lists->code) {
die $options{'-die'}."\n" if defined $options{'-die'};
- die $lists->error;
+ die $lists->error."\n";
}
return map { { list => email_to_unicode($_->get_value('fvl'))
, isactive => $_->get_value('fripostIsStatusActive') eq 'TRUE'
@@ -117,19 +121,9 @@ sub add {
, fripostIsStatusActive => $l->{isactive} ? 'TRUE' : 'FALSE'
, fripostOwner => $self->whoami
, fripostListManager => $l->{transport}
+ , fripostIsStatusPending => 'TRUE'
+ , fripostLocalAlias => $l2.'#'.$d
);
- if ($l->{transport} eq 'mailman') {
- $attrs{fripostListCommand} =
- [ map { $l2.'-'.$_ }
- qw/admin bounces confirm join leave loop owner
- request subscribe unsubscribe/ ];
- }
- elsif ($l->{transport} eq 'schleuder') {
- $attrs{fripostListCommand} =
- [ map { $l2.'-'.$_ }
- # TODO: check that
- qw/request bounce sendkey owner/ ];
- }
$attrs{description} = $l->{description}
if defined $l->{description} and @{$l->{description}};
@@ -137,10 +131,76 @@ sub add {
attrs => [ %attrs ] );
if ($mesg->code) {
die $options{'-die'}."\n" if defined $options{'-die'};
- die $mesg->error;
+ die $mesg->error."\n";
}
};
return $@;
+ # TODO: send email to mklist-$transport to finalize
+}
+
+
+=item B<is_pending> (I<list>, I<OPTIONS>)
+
+Tells whether the given list's status is I<pending>, meaning an entry
+has been created in the LDAP directory (for instance by the domain owner
+from the Web Panel), but the local aliases have not yet been added by
+the ListCreator entity, and the list is not known by the list manager.
+
+=cut
+
+sub is_pending {
+ my $self = shift;
+ my ($l,$d) = split /\@/, email_to_ascii(shift), 2;
+ my %options = @_;
+
+ my $mesg = $self->ldap->search(
+ base => "fvl=$l,fvd=$d,".$self->suffix,
+ scope => 'base',
+ deref => 'never',
+ filter => 'objectClass=FripostVirtualList',
+ attrs => [ 'fvl', 'fripostIsStatusPending' ]
+ );
+ die "Error: ".$l.'@'.$d.": No such object in the LDAP directory\n"
+ if $mesg->code == 32; # No such object; a common error here.
+ die $mesg->error if $mesg->code;
+
+ die "Error: Multiple matching entries found." if $mesg->count > 1;
+ my $list = $mesg->pop_entry;
+
+ die "Error: No matching entry found." unless defined $list;
+ my $r = $list->get_value('fripostIsStatusPending');
+ return (defined $r and $r eq 'TRUE');
+}
+
+
+=item B<add_commands> (I<list>, I<transport>, I<OPTIONS>)
+
+Add the lists commands, and remove the pending status.
+
+=cut
+
+sub add_commands {
+ my $self = shift;
+ my ($l,$d) = split /\@/, email_to_ascii(shift), 2;
+ my $cmds = shift;
+ my %options = @_;
+
+ my $mesg;
+ foreach my $cmd (@$cmds) {
+ $mesg = $self->ldap->add( "fvlc=$l-$cmd,fvl=$l,fvd=$d,".$self->suffix,
+ attrs => [ objectClass => 'FripostVirtualListCommand',
+ FripostLocalAlias => $l.'-'.$cmd.'#'.$d ] );
+ last if $mesg->code;
+ }
+
+ $mesg = $self->ldap->modify( "fvl=$l,fvd=$d,".$self->suffix,
+ , delete => 'fripostIsStatusPending' )
+ unless $mesg->code;
+
+ if ($mesg->code) {
+ die $options{'-die'}."\n" if defined $options{'-die'};
+ die $mesg->error."\n";
+ }
}
@@ -162,7 +222,7 @@ sub delete {
return $mesg->error unless $options{'-die'};
die $options{'-die'}."\n";
}
- die $mesg->error;
+ die $mesg->error."\n";
}
}