Project

General

Profile

Patch #38614 » email-handler-v2.patch

Aisha Tammy, 2023-05-26 17:02

View differences:

app/models/mail_handler.rb
46 46
    options[:no_account_notice] = (options[:no_account_notice].to_s == '1')
47 47
    options[:no_notification] = (options[:no_notification].to_s == '1')
48 48
    options[:no_permission_check] = (options[:no_permission_check].to_s == '1')
49
    options[:find_by_subject] = (options[:find_by_subject].to_s == '1')
49 50

  
50 51
    ActiveSupport::Notifications.instrument("receive.action_mailer") do |payload|
51 52
      mail = Mail.new(raw_mail.b)
......
69 70
    %w(project status tracker category priority assigned_to fixed_version).each do |option|
70 71
      options[:issue][option.to_sym] = env[option] if env[option]
71 72
    end
72
    %w(allow_override unknown_user no_permission_check no_account_notice no_notification default_group project_from_subaddress).each do |option|
73
    %w(allow_override unknown_user no_permission_check no_account_notice no_notification default_group project_from_subaddress find_by_subject).each do |option|
73 74
      options[option.to_sym] = env[option] if env[option]
74 75
    end
75 76
    if env['private']
......
147 148

  
148 149
  MESSAGE_ID_RE = %r{^<?redmine\.([a-z0-9_]+)\-(\d+)\.\d+(\.[a-f0-9]+)?@}
149 150
  ISSUE_REPLY_SUBJECT_RE = %r{\[(?:[^\]]*\s+)?#(\d+)\]}
151
  ISSUE_REPLY_SUBJECT_RE2 = %r{^(?:Re:\s*)*(.*)$}i
150 152
  MESSAGE_REPLY_SUBJECT_RE = %r{\[[^\]]*msg(\d+)\]}
151 153

  
152 154
  def dispatch
......
164 166
      receive_issue_reply(m[1].to_i)
165 167
    elsif m = subject.match(MESSAGE_REPLY_SUBJECT_RE)
166 168
      receive_message_reply(m[1].to_i)
169
    elsif handler_options[:find_by_subject]
170
      logger&.info("MailHandler: trying to find issue by subject")
171
      if issue = Issue.find_by(:subject => subject)
172
        logger&.info("MailHandler: found issue #{issue.id} using the full subject")
173
        receive_issue_reply(issue.id)
174
      elsif m = subject.match(ISSUE_REPLY_SUBJECT_RE2)
175
        if issue = Issue.find_by(:subject => m[1])
176
          logger&.info("MailHandler: found issue #{issue.id} using the subject regex")
177
          receive_issue_reply(issue.id)
178
        end
179
      else
180
        dispatch_to_default
181
      end
167 182
    else
168 183
      dispatch_to_default
169 184
    end
config/locales/bg.yml
821 821
  label_no_issues_in_project: никакви задачи в проект
822 822
  label_any_open_issues: отворени задачи
823 823
  label_no_open_issues: без отворени задачи
824
  label_has_been: някога е било
825
  label_has_never_been: никога не е било
826
  label_changed_from: променено от
824 827
  label_day_plural: дни
825 828
  label_repository: Хранилище
826 829
  label_repository_new: Ново хранилище
......
841 844
  label_latest_revision_plural: Последни ревизии
842 845
  label_view_revisions: Виж ревизиите
843 846
  label_view_all_revisions: Разглеждане на всички ревизии
847
  label_view_previous_annotation: Показване на анотацията преди промяната
844 848
  label_x_revisions: "%{count} ревизии"
845 849
  label_max_size: Максимална големина
846 850
  label_roadmap: Пътна карта
......
1201 1205
  button_edit_object: Редактиране %{object_name}
1202 1206
  button_delete_object: Изтриване %{object_name}
1203 1207
  button_create_and_follow: Създаване и продължаване
1208
  button_apply_issues_filter: Прилагане на филтъра
1204 1209

  
1205 1210
  status_active: активен
1206 1211
  status_registered: регистриран
......
1422 1427
    Това действие не може да бъде отменено. Често заключването на потребителя е по-добро решение от изтриването му.
1423 1428
    За да потвърдите, въведете името (%{login}) по-долу.
1424 1429
  text_project_destroy_enter_identifier: За да потвърдите действието, въведете идентификатора на проекта (%{identifier}) по-долу.
1425
  button_apply_issues_filter: Apply issues filter
1426
  label_view_previous_annotation: View annotation prior to this change
1427
  label_has_been: has been
1428
  label_has_never_been: has never been
1429
  label_changed_from: changed from
(2-2/3)