Commit 1c1f438c authored by IKEDA Soji's avatar IKEDA Soji
Browse files

Refactoring (#1070)

parent d75a3e5d
......@@ -14896,12 +14896,7 @@ sub do_send_mail {
# - Add footer / header.
$u_message->prepare_message_according_to_mode('mail', $list);
# - Shelve personalization.
if ( 'on' eq ($list->{'admin'}{'personalization_feature'} || 'off')
and 'none' ne
($list->{'admin'}{'personalization'}{'web_apply_on'} || 'none')) {
$u_message->{shelved}{merge} =
$list->{'admin'}{'personalization'}{'web_apply_on'};
}
$u_message->shelve_personalization(type => 'web');
 
$u_message->{envelope_sender} = Sympa::get_address($robot, 'owner');
$u_message->{priority} =
......@@ -14984,12 +14979,7 @@ sub do_send_mail {
my $l_message = $message->dup;
 
# - Shelve personalization.
if ( 'on' eq ($list->{'admin'}{'personalization_feature'} || 'off')
and 'none' ne
($list->{'admin'}{'personalization'}{'web_apply_on'} || 'none')) {
$l_message->{shelved}{merge} =
$list->{'admin'}{'personalization'}{'web_apply_on'};
}
$l_message->shelve_personalization(type => 'web');
 
$l_message->{envelope_sender} = $param->{'user'}{'email'};
$l_message->{sender} = $param->{'user'}{'email'};
......
......@@ -2480,6 +2480,24 @@ sub _fix_utf8_parts {
return $entity;
}
sub shelve_personalization {
my $self = shift;
my %options = @_;
my $list = $self->{context};
die 'bug in logic. Ask developer' unless ref $list eq 'Sympa::List';
my $apply_on =
('web' eq ($options{type} // ''))
? $list->{'admin'}{'personalization'}{'web_apply_on'}
: $list->{'admin'}{'personalization'}{'mail_apply_on'};
if ( 'on' eq ($list->{'admin'}{'personalization_feature'} || 'off')
and 'none' ne ($apply_on || 'none')) {
$self->{shelved}{merge} = $apply_on;
}
}
sub get_plain_body {
$log->syslog('debug2', '(%s)', @_);
my $self = shift;
......@@ -4102,6 +4120,14 @@ Returns:
string
=item shelve_personalization ( type =E<gt> $type )
I<Instance method>.
Shelve personalization ("merge feature") if necessary.
$type is either C<'web'> or C<'mail'>.
Dies if the context of the message was not List.
=item get_plain_body ( )
I<Instance method>.
......
......@@ -408,13 +408,8 @@ sub _mail_message {
# Shelve personalization if not yet shelved.
# Note that only 'footer' mode will be allowed unless otherwise requested.
if ( not $message->{shelved}{merge}
and 'on' eq ($list->{'admin'}{'personalization_feature'} || 'off')
and 'none' ne
($list->{'admin'}{'personalization'}{'mail_apply_on'} || 'none')) {
$message->{shelved}{merge} =
$list->{'admin'}{'personalization'}{'mail_apply_on'};
}
$message->shelve_personalization(type => 'mail')
unless $message->{shelved}{merge};
# Shelve re-encryption with S/MIME.
$message->{shelved}{smime_encrypt} = 1
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment