Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate one time ticket (1) (#156) #853

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions default/mail_tt2/listmaster_notification.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Subject: [%"List \"%1@%2\" creation request from %3"|loc(list.name,domain,email)
[% 'info' | url_abs([list.name]) %]

[%|loc%]To activate/delete this mailing list:[%END%]
[% 'ticket' | url_abs([one_time_ticket]) %]
[% 'get_pending_lists' | url_abs %]

[%- ELSIF type == 'list_created' -%]
[% PROCESS 'list_created.tt2' -%]
Expand All @@ -30,7 +30,7 @@ Subject: [%"List \"%1\" renaming"|loc(list.name)|qencode%]
[% END %]

[%|loc%]To activate/delete this mailing list:[%END%]
[% 'ticket' | url_abs([one_time_ticket]) %]
[% 'get_pending_lists' | url_abs %]

[% ELSIF type == 'no_db' -%]
Subject: [%"No database"|loc|qencode%]
Expand Down
2 changes: 1 addition & 1 deletion default/mail_tt2/listowner_notification.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Subject: [%"FYI: %1 List \"%2\" from %3 %4"|loc(type,list.name,who,gecos)|qencod
[%|loc(who,gecos,list.name)%]WARNING: %1 %2 failed to unsubscribe from %3 because their address was not found in the list.
You may help this person looking for similar email in subscriber list using the following link :[%END%]

[% 'ticket' | url_abs([one_time_ticket]) %]
[% 'search' | url_abs([list.name,who]) %]

[% ELSIF type == 'erase_customizing' -%]
Subject: [%"List \"%1\" customizations have been removed"|loc(list.name)|qencode%]
Expand Down
2 changes: 1 addition & 1 deletion default/mail_tt2/moderate.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Content-Disposition: inline

[% IF method == 'md5' -%]
[%|loc(mod_spool_size)%]%1 messages are awaiting moderation.[%END%]
[%|loc%]To view the messages, please click on the following URL:[%END%] <[% 'ticket' | url_abs([one_time_ticket]) %]>
[%|loc%]To view the messages, please click on the following URL:[%END%] <[% 'modindex' | url_abs([list.name]) %]>

[% IF request_topic -%][%|loc()%]This mailing list is configured to require topics; that's probably why this message went through the moderation process.[%END%]

Expand Down
74 changes: 21 additions & 53 deletions src/lib/Sympa.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
# Copyright 2017, 2018, 2019 The Sympa Community. See the AUTHORS.md file at
# the top-level directory of this distribution and at
# Copyright 2017, 2018, 2019, 2020 The Sympa Community. See the AUTHORS.md
# file at the top-level directory of this distribution and at
# <https://github.com/sympa-community/sympa.git>.
#
# This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -46,7 +46,6 @@ use Sympa::Log;
use Sympa::Regexps;
use Sympa::Spindle::ProcessTemplate;
use Sympa::Ticket;
use Sympa::Tools::Data;
use Sympa::Tools::Text;

my $log = Sympa::Log->instance;
Expand Down Expand Up @@ -436,61 +435,30 @@ sub send_notify_to_listmaster {
$data->{'type'} = $operation;
$data->{'auto_submitted'} = 'auto-generated';

my @tosend;

if ($operation eq 'no_db' or $operation eq 'db_restored') {
$data->{'db_name'} = Conf::get_robot_conf($robot_id, 'db_name');
}

if ( $operation eq 'request_list_creation'
or $operation eq 'request_list_renaming') {
foreach my $email (@listmasters) {
my $cdata = Sympa::Tools::Data::dup_var($data);
$cdata->{'one_time_ticket'} =
Sympa::Ticket::create($email, $robot_id, 'get_pending_lists',
$cdata->{'ip'});
push @tosend,
{
email => $email,
data => $cdata
};
}
} else {
push @tosend,
{
email => [@listmasters],
data => $data
};
}
# When operation is either missing_dbd, no_db or db_restored,
# skip DB access because DB is not accessible.
my $spindle = Sympa::Spindle::ProcessTemplate->new(
context => $that,
template => 'listmaster_notification',
rcpt => [@listmasters],
data => $data,

foreach my $ts (@tosend) {
my $email = $ts->{'email'};
# Skip DB access because DB is not accessible
$email = [$email]
if not ref $email
and ($operation eq 'missing_dbd'
or $operation eq 'no_db'
or $operation eq 'db_restored');

my $spindle = Sympa::Spindle::ProcessTemplate->new(
context => $that,
template => 'listmaster_notification',
rcpt => $email,
data => $ts->{'data'},

splicing_to => ['Sympa::Spindle::ToListmaster'],
);
unless ($spindle
and $spindle->spin
and $spindle->{finish} eq 'success') {
$log->syslog(
'notice',
'Unable to send template "listmaster_notification" to %s listmaster %s',
$robot_id,
$ts->{'email'}
) unless $operation eq 'logs_failed';
return undef;
}
splicing_to => ['Sympa::Spindle::ToListmaster'],
);
unless ($spindle
and $spindle->spin
and $spindle->{finish} eq 'success') {
$log->syslog(
'notice',
'Unable to send template "listmaster_notification" to %s listmaster %s',
$robot_id,
join(', ', @listmasters),
) unless $operation eq 'logs_failed';
return undef;
}

return 1;
Expand Down
50 changes: 11 additions & 39 deletions src/lib/Sympa/List.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
# Copyright 2017, 2018, 2019 The Sympa Community. See the AUTHORS.md file at
# the top-level directory of this distribution and at
# Copyright 2017, 2018, 2019, 2020 The Sympa Community. See the AUTHORS.md
# file at the top-level directory of this distribution and at
# <https://github.com/sympa-community/sympa.git>.
#
# This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -54,7 +54,6 @@ use Sympa::Spindle::ProcessRequest;
use Sympa::Spindle::ProcessTemplate;
use Sympa::Spool::Auth;
use Sympa::Template;
use Sympa::Ticket;
use Sympa::Tools::Data;
use Sympa::Tools::Domains;
use Sympa::Tools::File;
Expand Down Expand Up @@ -1731,11 +1730,13 @@ The key for naming message waiting for confirmation (or tagging) in auth spool,
######################################################
sub send_notify_to_owner {
$log->syslog('debug2', '(%s, %s, %s)', @_);
my ($self, $operation, $param) = @_;
my $self = shift;
my $operation = shift;
my $param = shift;

my @rcpt = $self->get_admins_email('receptive_owner');
my $robot = $self->{'domain'};
die 'bug in logic. Ask developer' unless defined $operation;

my @rcpt = $self->get_admins_email('receptive_owner');
unless (@rcpt) {
$log->syslog(
'notice',
Expand All @@ -1744,41 +1745,13 @@ sub send_notify_to_owner {
);
@rcpt = Sympa::get_listmasters_email($self);
}
unless (defined $operation) {
die 'missing incoming parameter "$operation"';
}

if (ref($param) eq 'HASH') {

if (ref $param eq 'HASH') {
$param->{'auto_submitted'} = 'auto-generated';
$param->{'to'} = join(',', @rcpt);
$param->{'type'} = $operation;

if ($operation eq 'warn-signoff') {
foreach my $owner (@rcpt) {
$param->{'one_time_ticket'} = Sympa::Ticket::create(
$owner,
$robot,
'search/'
. Sympa::Tools::Text::encode_uri($self->{'name'})
. '/'
. Sympa::Tools::Text::encode_uri($param->{'who'}),
$param->{'ip'}
);
unless (
Sympa::send_file(
$self, 'listowner_notification', [$owner], $param
)
) {
$log->syslog(
'notice',
'Unable to send template "listowner_notification" to %s list owner %s',
$self,
$owner
);
}
}
} elsif ($operation eq 'sigrequest' or $operation eq 'subrequest') {
if ($operation eq 'sigrequest' or $operation eq 'subrequest') {
# Sends notifications by each so that auth links with owners'
# addresses will be included.
foreach my $owner (@rcpt) {
Expand All @@ -1801,7 +1774,7 @@ sub send_notify_to_owner {
}
unless (
Sympa::send_file(
$self, 'listowner_notification', \@rcpt, $param
$self, 'listowner_notification', [@rcpt], $param
)
) {
$log->syslog(
Expand All @@ -1812,8 +1785,7 @@ sub send_notify_to_owner {
return undef;
}
}

} elsif (ref($param) eq 'ARRAY') {
} elsif (ref $param eq 'ARRAY') {

my $data = {
'to' => join(',', @rcpt),
Expand Down
25 changes: 3 additions & 22 deletions src/lib/Sympa/Spindle/ToModeration.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
# Copyright 2020 The Sympa Community. See the AUTHORS.md
# file at the top-level directory of this distribution and at
# <https://github.com/sympa-community/sympa.git>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -32,7 +35,6 @@ use Sympa;
use Sympa::Log;
use Sympa::Message::Template;
use Sympa::Spool::Moderation;
use Sympa::Ticket;

use base qw(Sympa::Spindle);

Expand Down Expand Up @@ -185,27 +187,6 @@ sub _send_confirm_to_editor {
}
$param->{'msg'} = $new_message;

# create a one time ticket that will be used as un md5 URL credential
unless (
$param->{'one_time_ticket'} = Sympa::Ticket::create(
$recipient, $list->{'domain'},
'modindex/' . $list->{'name'}, 'mail'
)
) {
$log->syslog(
'notice',
'Unable to create one_time_ticket for %s, service modindex/%s',
$recipient,
$list->{'name'}
);
} else {
$log->syslog(
'debug',
'Ticket %s created',
$param->{'one_time_ticket'}
);
}

# Ensure 1 second elapsed since last message.
unless (
Sympa::send_file(
Expand Down