snnrk / redmine_mailwrapper

Plugin for Redmine to rewrite mail according to rules for each projects.
12 stars 1 forks source link

tracker and category mismatch #6

Closed diegoforrini closed 11 years ago

diegoforrini commented 11 years ago

Hi

I've tried to install the plugin following the standard of redmine (rake redmine:plugins:migrate RAILS_ENV=..., restarting the server...). I've enabled the module for one project and gone to the settings tab.

I have no problems creating sender, recipient and rule, but when I create a new Issue that follow the rule the mail is not sent. I obtain always the same errors coming from `util.rb' (tracker and category mismatch). This is the log:

redmine_mailwrapper: call rewrite_issue()
  EnabledModule Load (0.5ms)  SELECT `enabled_modules`.* FROM `enabled_modules` WHERE `enabled_modules`.`project_id` = 1
redmine_mailwrapper: get_sender().
  MailwrapperSender Load (0.5ms)  SELECT `mailwrapper_senders`.* FROM `mailwrapper_senders` WHERE `mailwrapper_senders`.`project_id` = 1 LIMIT 1
redmine_mailwrapper: get_issue_recipient().
  Project Load (0.0ms)  SELECT `projects`.* FROM `projects` WHERE `projects`.`id` = 1 LIMIT 1
   (0.5ms)  SELECT COUNT(*) FROM `mailwrapper_issue_rules` WHERE `mailwrapper_issue_rules`.`project_id` = 1
  MailwrapperIssueRule Load (0.0ms)  SELECT `mailwrapper_issue_rules`.* FROM `mailwrapper_issue_rules` WHERE `mailwrapper_issue_rules`.`project_id` = 1 ORDER BY priority
redmine_mailwrapper: rule_id=1
  Tracker Load (0.0ms)  SELECT `trackers`.* FROM `trackers` INNER JOIN `mailwrapper_issue_rules_trackers` ON `trackers`.`id` = `mailwrapper_issue_rules_trackers`.`tracker_id` WHERE `mailwrapper_issue_rules_trackers`.`mailwrapper_issue_rule_id` = 1 ORDER BY trackers.position
redmine_mailwrapper: tracker mismatch
  IssueCategory Load (0.0ms)  SELECT `issue_categories`.* FROM `issue_categories` INNER JOIN `issue_categories_mailwrapper_issue_rules` ON `issue_categories`.`id` = `issue_categories_mailwrapper_issue_rules`.`issue_category_id` WHERE `issue_categories_mailwrapper_issue_rules`.`mailwrapper_issue_rule_id` = 1
redmine_mailwrapper: category mismatch
  IssueStatus Load (0.0ms)  SELECT `issue_statuses`.* FROM `issue_statuses` INNER JOIN `issue_statuses_mailwrapper_issue_rules` ON `issue_statuses`.`id` = `issue_statuses_mailwrapper_issue_rules`.`issue_status_id` WHERE `issue_statuses_mailwrapper_issue_rules`.`mailwrapper_issue_rule_id` = 1
redmine_mailwrapper: unknown route.
redmine_mailwrapper: call rewrite()
  SQL (13.5ms)  SELECT `custom_values`.`id` AS t0_r0, `custom_values`.`customized_type` AS t0_r1, `custom_values`.`customized_id` AS t0_r2, `custom_values`.`custom_field_id` AS t0_r3, `custom_values`.`value` AS t0_r4, `custom_fields`.`id` AS t1_r0, `custom_fields`.`type` AS t1_r1, `custom_fields`.`name` AS t1_r2, `custom_fields`.`field_format` AS t1_r3, `custom_fields`.`possible_values` AS t1_r4, `custom_fields`.`regexp` AS t1_r5, `custom_fields`.`min_length` AS t1_r6, `custom_fields`.`max_length` AS t1_r7, `custom_fields`.`is_required` AS t1_r8, `custom_fields`.`is_for_all` AS t1_r9, `custom_fields`.`is_filter` AS t1_r10, `custom_fields`.`position` AS t1_r11, `custom_fields`.`searchable` AS t1_r12, `custom_fields`.`default_value` AS t1_r13, `custom_fields`.`editable` AS t1_r14, `custom_fields`.`visible` AS t1_r15, `custom_fields`.`multiple` AS t1_r16 FROM `custom_values` LEFT OUTER JOIN `custom_fields` ON `custom_fields`.`id` = `custom_values`.`custom_field_id` WHERE `custom_values`.`customized_id` = 8 AND `custom_values`.`customized_type` = 'Issue' ORDER BY custom_fields.position
  IssueRelation Load (0.5ms)  SELECT `issue_relations`.* FROM `issue_relations` WHERE `issue_relations`.`issue_from_id` = 8
  Issue Load (1.0ms)  SELECT `issues`.* FROM `issues` WHERE `issues`.`root_id` = 8 ORDER BY `rgt` desc LIMIT 1 FOR UPDATE
  SQL (0.5ms)  UPDATE `issues` SET root_id = 8, lft = 1, rgt = 2 WHERE (id = 8)
  Issue Load (1.0ms)  SELECT `issues`.* FROM `issues` WHERE `issues`.`id` = 8 LIMIT 1
   (2.5ms)  COMMIT

I'm using Redmine on Windows provided by Bitnami (http://bitnami.com/stack/redmine/installer)

Environment: Redmine version 2.3.0.stable Ruby version 1.9.3 (i386-mingw32) Rails version 3.2.13 Environment production Database adapter Mysql2 Redmine plugins: redmine_mailwrapper 0.1.2

Thanks for the plugin.

snnrk commented 11 years ago

Hi diegoforrini,

"XXX mismatch" is not error message. This message outputs when value is matched for rule. ; So, "mismatch" is wrong ... I will fix it.

On your log, it seems that no mail has sent because no rules has matched I think, [User] has mismatched. You should specify login name of author for [User]. Reconfirm the rules for issues.

diegoforrini commented 11 years ago

Thank you for the answer. Maybe I didn't understand the plugin usage. I try to explain what I need with an example: I have a little project with three users (login, role):

I want that the manager receive a notification when a Bug is in a New state. Then I create a Recipient with only the address of the Manager (diego) and I call it MyRecipient. I create a rule with: Tracker - Bug Issue status - New User - luca Recipient - MyRecipient

Then, when luca open a Bug in a New state on the project a mail should be sent to diego, but the mail is only sent to luca (if he didn't selected "I don't want to be notified of changes that I make myself" from its account settings).

snnrk commented 11 years ago

That setting is correct for your purpose. If mail address of diego were not wrong, the mail is expected to be sent to diego.

Incidentally, it is normal that luca has received mail. Because redmine make notify to author of issues, and rewriting by mailwrapper includes the original recipients (but ignore duplicates).

Try followings:

  1. Without Bcc settings of redmine, create a issue again as luca.
  2. Check the recipients in the mail (it should be diego, luca and watchers).

Regards,

diegoforrini commented 11 years ago

I had already tried with that settings and but the recipient is only luca. Maybe the problem is about the notification option, in fact diego has: "Only for things I watch or I'm involved in". In the example is not directly involved, because he is only a member of the project, but I think that the plugin should be independent on the user settings (maybe I'm wrong).

Thank you again.

diegoforrini commented 11 years ago

I think that I found the solution. I've changed the line 18 of "lib/mailwrapper/util.rb" from next if (! r.issue_statuses.empty? and r.issue_statuses.select {|s| s.id == flag[:statuses]}.empty?) to next if (! r.issue_statuses.empty? and r.issue_statuses.select {|s| s.id == flag[:status]}.empty?)

because in the rewrite_issue function there is a reference to status and not statuses (line 61 of the util.rb file -> :status => issue.status_id,)

It's the first time that i see an rb file so maybe I made a mistake, but now everything works fine for me.

Best regards

snnrk commented 11 years ago

Thanks for your report. Since it's just a typo, I've fixed it like yours.

Regards