Project

General

Profile

Feature #19289 » 0001-Filter-email-attachments-based-on-content-ignore-fil.patch

Mikhail Voronyuk, 2015-03-08 09:09

View differences:

app/models/mail_handler.rb
287 287
        return false
288 288
      end
289 289
    end
290
    # check if the attachment is match some ignored file
291
    Dir::Tmpname.create('tmpattach') do |tmpfilename|
292
      tmpfilenameextended = "#{tmpfilename}#{attachment.filename}"
293
      File.open(tmpfilenameextended, 'wb') do |file|
294
        file.write(attachment.body.decoded)
295
      end
296
      Dir['/home/redmine/redmine-ignored-attachments/*'].each do |ignoredf|
297
        if FileUtils.cmp(ignoredf, tmpfilenameextended)
298
          logger.info "MailHandler: ignoring attachment #{attachment.filename} matching #{ignoredf}"
299
          FileUtils.rm(tmpfilenameextended)
300
          return false
301
        end
302
      end
303
      FileUtils.rm(tmpfilenameextended)
304
    end
290 305
    true
291 306
  end
292 307

  
(3-3/3)