Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b05c071a

Von Tamino Steinert vor etwa 1 Jahr hinzugefügt

  • ID b05c071a6a59d43961a9f424c200131ffeb73abf
  • Vorgänger aa38f2e3

S:B:ImportRecordEmails: Nötige Daten beim Validieren einfordern

'enabled' als Parameter entfernt

Unterschiede anzeigen:

SL/BackgroundJob/ImportRecordEmails.pm
113 113
  my ($self, $job_obj) = @_;
114 114
  $self->{job_obj} = $job_obj;
115 115

  
116
  my %spec = (
116
  my $data = $job_obj->data_as_hash;
117

  
118
  my $record_type = $data->{record_type};
119
  my $loaded_config = $::lx_office_conf{"record_emails_imap/record_type/$record_type"}
120
    || $::lx_office_conf{record_emails_imap}
121
    || {};
122

  
123
  # overwrite with background job data
124
  $loaded_config->{$_} = $data->{$_} for keys %{$data};
125
  my @config_params = %{$loaded_config};
126

  
127
  my %config = validate_with(
128
    params => \@config_params,
129
    spec   => {
117 130
      folder => {
118
        type => SCALAR,
131
        type     => SCALAR,
119 132
        optional => 1,
120 133
      },
121 134
      record_type => {
122
        optional => 1,
123
        default  => 'catch_all',
135
        optional  => 1,
136
        default   => 'catch_all',
124 137
        callbacks => {
125 138
          'valid record type' => sub {
126 139
            my $valid_record_types = SL::DB::EmailJournal->meta->{columns}->{record_type}->{check_in};
......
131 144
        },
132 145
      },
133 146
      process_imported_emails => {
134
        type => SCALAR | ARRAYREF,
135
        optional => 1,
147
        type      => SCALAR | ARRAYREF,
148
        optional  => 1,
136 149
        callbacks => {
137 150
          'function is implemented' => sub {
138 151
            foreach my $function_name (ref $_[0] eq 'ARRAY' ? @{$_[0]} : ($_[0])) {
......
143 156
          }
144 157
        }
145 158
      },
146
      processed_imap_flag => {
147
        type => SCALAR,
148
        optional => 1,
149
      },
150
      not_processed_imap_flag => {
151
        type => SCALAR,
152
        optional => 1,
153
      },
154
      email_import_ids_to_delete => {
155
        type => ARRAYREF,
156
        optional => 1,
157
      },
159
      processed_imap_flag        => { type => SCALAR,   optional => 1, },
160
      not_processed_imap_flag    => { type => SCALAR,   optional => 1, },
161
      email_import_ids_to_delete => { type => ARRAYREF, optional => 1, },
158 162
      # email config
159
      enabled     => { type => BOOLEAN, optional => 1, },
160
      hostname    => { type => SCALAR,  optional => 1, },
161
      port        => { type => SCALAR,  optional => 1, },
162
      ssl         => { type => BOOLEAN, optional => 1, },
163
      username    => { type => SCALAR,  optional => 1, },
164
      password    => { type => SCALAR,  optional => 1, },
165
      base_folder => { type => SCALAR,  optional => 1, },
163
      hostname    => { type => SCALAR,  },
164
      port        => { type => SCALAR,  optional => 1},
165
      ssl         => { type => BOOLEAN, },
166
      username    => { type => SCALAR,  },
167
      password    => { type => SCALAR,  },
168
      base_folder => { type => SCALAR,  optional => 1},
169
    },
170
    called => "data filed in Background Job or kivitendo.conf in [record_emails_imap] with type $record_type",
166 171
  );
167 172

  
168
  my @bj_data = $job_obj->data_as_hash;
169
  my %data = validate_with(
170
    params => \@bj_data,
171
    spec   => \%spec,
172
    called => "data filed in Background Job",
173
  );
174

  
175
  my $record_type = $data{record_type};
176
  my $loaded_config = $::lx_office_conf{"record_emails_imap/record_type/$record_type"}
177
    || $::lx_office_conf{record_emails_imap}
178
    || {};
179

  
180
  my @loaded_config = %$loaded_config;
181
  my %config = validate_with(
182
    params => \@loaded_config,
183
    spec   => \%spec,
184
    called => "kivitendo.conf in [record_emails_imap] with type $record_type",
185
  );
186
  # overwrite with background job data
187
  $config{$_} = $data{$_} for keys %data;
188

  
189 173
  my @results;
190 174
  if (scalar $config{email_import_ids_to_delete}) {
191 175
    push @results, $self->delete_email_imports($config{email_import_ids_to_delete});
SL/IMAPClient.pm
29 29
  my $class = shift;
30 30
  my %params = validate(@_, {
31 31
    enabled     => {
32
      type => BOOLEAN,
33
      callbacks => {'is enabled' => sub { !!shift }}
32
      type      => BOOLEAN,
33
      callbacks => {'is enabled' => sub { !!shift }},
34
      optional  => 1,
34 35
    },
35 36
    hostname    => { type => SCALAR,  },
36 37
    port        => { type => SCALAR,  optional => 1, },

Auch abrufbar als: Unified diff