Revision a7ffa4e3
Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt
SL/BackgroundJob/SyncEmailFolder.pm | ||
---|---|---|
17 | 17 |
my $email_import = $imap_client->update_emails_from_folder($folder); |
18 | 18 |
return unless $email_import; |
19 | 19 |
|
20 |
$self->{job_obj}->set_data(last_email_import_id => $email_import->id)->save;
|
|
20 |
return "Created email import: " . $email_import->id;
|
|
21 | 21 |
} |
22 | 22 |
|
23 | 23 |
sub delete_email_imports { |
... | ... | |
27 | 27 |
my $email_import_ids_to_delete = |
28 | 28 |
$job_obj->data_as_hash->{email_import_ids_to_delete} || []; |
29 | 29 |
|
30 |
my @deleted_email_imports_ids; |
|
30 | 31 |
foreach my $email_import_id (@$email_import_ids_to_delete) { |
31 | 32 |
my $email_import = SL::DB::Manager::EmailImport->find_by(id => $email_import_id); |
32 | 33 |
next unless $email_import; |
33 | 34 |
$email_import->delete(cascade => 1); |
35 |
push @deleted_email_imports_ids, $email_import_id; |
|
34 | 36 |
} |
37 |
return unless @deleted_email_imports_ids; |
|
35 | 38 |
|
36 |
$job_obj->set_data(email_import_ids_to_delete => [])->save;
|
|
39 |
return "Deleted email import(s): " . join(', ', @deleted_email_imports_ids);
|
|
37 | 40 |
} |
38 | 41 |
|
39 | 42 |
sub run { |
40 | 43 |
my ($self, $job_obj) = @_; |
41 | 44 |
$self->{job_obj} = $job_obj; |
42 | 45 |
|
43 |
$self->delete_email_imports(); |
|
46 |
my @results; |
|
47 |
push @results, $self->delete_email_imports(); |
|
48 |
push @results, $self->sync_email_folder(); |
|
44 | 49 |
|
45 |
$self->sync_email_folder(); |
|
46 |
|
|
47 |
return; |
|
50 |
return join(". ", grep { $_ ne ''} @results); |
|
48 | 51 |
} |
49 | 52 |
|
50 | 53 |
1; |
Auch abrufbar als: Unified diff
BJ: SyncEmailFolder: Data-Feld nicht ändern