🐜 Prevent to store a invitation file twice in DB / have it twice in mail

This commit is contained in:
Luc Didry 2019-07-30 08:04:03 +02:00
parent a36ad49133
commit 2f8758c865
No known key found for this signature in database
GPG Key ID: EA868E12D0257E3C
2 changed files with 10 additions and 4 deletions

View File

@ -228,8 +228,12 @@ sub send_mail_to_ldap_user {
my @files = (); my @files = ();
if ($c->config('invitations')->{'save_files_url_in_db'} && $urls->size) { if ($c->config('invitations')->{'save_files_url_in_db'} && $urls->size) {
my $guest_files = $invitation->files; my $guest_files = $invitation->files;
my %list_token;
if ($guest_files) { if ($guest_files) {
$guest_files = decode_json($guest_files); $guest_files = decode_json($guest_files);
for my $file (@{$guest_files}) {
$list_token{$file->{token}} = 1;
}
} else { } else {
$guest_files = []; $guest_files = [];
} }
@ -237,8 +241,10 @@ sub send_mail_to_ldap_user {
$urls->each(sub { $urls->each(sub {
my ($e, $num) = @_; my ($e, $num) = @_;
$e = decode_json($e); $e = decode_json($e);
push @{$guest_files}, $e; if (!defined($list_token{$e->{token}})) {
push @files, $e; push @{$guest_files}, $e;
push @files, $e;
}
}); });
$invitation->files(encode_json($guest_files)); $invitation->files(encode_json($guest_files));
$invitation->write; $invitation->write;

View File

@ -512,7 +512,7 @@ msgstr ""
msgid "Signin" msgid "Signin"
msgstr "" msgstr ""
#: lib/Lufi/Controller/Invitation.pm:277 themes/default/templates/invitations/exception.html.ep:16 #: lib/Lufi/Controller/Invitation.pm:283 themes/default/templates/invitations/exception.html.ep:16
msgid "Sorry, the invitation doesnt exist. Are you sure you are on the right URL?" msgid "Sorry, the invitation doesnt exist. Are you sure you are on the right URL?"
msgstr "" msgstr ""
@ -534,7 +534,7 @@ msgid "Sorry, your invitation has expired or has been deleted. Please contact %1
msgstr "" msgstr ""
#. ($invitation->ldap_user_mail) #. ($invitation->ldap_user_mail)
#: lib/Lufi/Controller/Invitation.pm:270 #: lib/Lufi/Controller/Invitation.pm:276
msgid "The URLs of your files have been sent by email to %1." msgid "The URLs of your files have been sent by email to %1."
msgstr "" msgstr ""