RM_mail_handler_bug_fix.diff

Jérôme BATAILLE, 2013-08-01 15:33

Download (2.95 KB)

View differences:

mail_handler.rb (revision 1741)
47 47
    sender_email = email.from.to_a.first.to_s.strip
48 48
    # Ignore emails received from the application emission address to avoid hell cycles
49 49
    if sender_email.downcase == Setting.mail_from.to_s.strip.downcase
50
      logger.info  "MailHandler: ignoring email from Redmine emission address [#{sender_email}]" if logger && logger.info
50
      logger.info  "MailHandler: ignoring email from Redmine emission address [#{sender_email}]" if logger && logger.info?
51 51
      return false
52 52
    end
53 53
    @user = User.find_by_mail(sender_email) if sender_email.present?
54 54
    if @user && !@user.active?
55
      logger.info  "MailHandler: ignoring email from non-active user [#{@user.login}]" if logger && logger.info
55
      logger.info  "MailHandler: ignoring email from non-active user [#{@user.login}]" if logger && logger.info?
56 56
      return false
57 57
    end
58 58
    if @user.nil?
......
63 63
      when 'create'
64 64
        @user = MailHandler.create_user_from_email(email)
65 65
        if @user
66
          logger.info "MailHandler: [#{@user.login}] account created" if logger && logger.info
66
          logger.info "MailHandler: [#{@user.login}] account created" if logger && logger.info?
67 67
          Mailer.deliver_account_information(@user, @user.password)
68 68
        else
69
          logger.error "MailHandler: could not create account for [#{sender_email}]" if logger && logger.error
69
          logger.error "MailHandler: could not create account for [#{sender_email}]" if logger && logger.error?
70 70
          return false
71 71
        end
72 72
      else
73 73
        # Default behaviour, emails from unknown users are ignored
74
        logger.info  "MailHandler: ignoring email from unknown user [#{sender_email}]" if logger && logger.info
74
        logger.info  "MailHandler: ignoring email from unknown user [#{sender_email}]" if logger && logger.info?
75 75
        return false
76 76
      end
77 77
    end
......
139 139
    add_watchers(issue)
140 140
    issue.save!
141 141
    add_attachments(issue)
142
    logger.info "MailHandler: issue ##{issue.id} created by #{user}" if logger && logger.info
142
    logger.info "MailHandler: issue ##{issue.id} created by #{user}" if logger && logger.info?
143 143
    issue
144 144
  end
145 145

  
......
161 161
    journal.notes = cleaned_up_text_body
162 162
    add_attachments(issue)
163 163
    issue.save!
164
    logger.info "MailHandler: issue ##{issue.id} updated by #{user}" if logger && logger.info
164
    logger.info "MailHandler: issue ##{issue.id} updated by #{user}" if logger && logger.info?
165 165
    journal
166 166
  end
167 167

  
......
192 192
        add_attachments(reply)
193 193
        reply
194 194
      else
195
        logger.info "MailHandler: ignoring reply from [#{sender_email}] to a locked topic" if logger && logger.info
195
        logger.info "MailHandler: ignoring reply from [#{sender_email}] to a locked topic" if logger && logger.info?
196 196
      end
197 197
    end
198 198
  end