Defect #4513

MessageObserver: wrong use of compact.uniq??

Added by Anh Kỳ Huỳnh almost 10 years ago. Updated almost 10 years ago.

Status:ClosedStart date:2010-01-02
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-
Resolution:No feedback Affected version:

Description

In the class MessageObserver, there is a line to compact the list of recipients

recipients = recipients.compact.uniq

The purpose of this line is to make recipients array contains each item once. But I found I still have duplicate items in message_posted (class Mailer). I don't know why so I have to change it:

    parsed = Array.new
    recipients = recipients.select do |m|
      next if parsed.include?(m.user.id)
      send_mail = check_if_user_want_to_receive_mail(m)
      parsed << m.user.id
      send_mail
    end.collect{|m| m.user.mail}

and then I don't have any duplicated items anymore in recipients. I amnot sure but I think this problem is due to Rails/Ruby.

Hope this helps.

My environment: (Redmine 0.8.5)

About your application's environment 

Ruby version              1.8.7 (i686-linux)
RubyGems version          1.3.5
Rails version             2.1.2
Active Record version     2.1.2
Action Pack version       2.1.2
Active Resource version   2.1.2
Action Mailer version     2.1.2
Active Support version    2.1.2
Edge Rails revision       unknown
Application root          /path/to/viettug.org
Environment               development
Database adapter          mysql
Database schema version   101

About your Redmine plugins
Redmine Vote plugin   0.0.2
Blog Plugin           1.1.0

History

#1 Updated by Jean-Philippe Lang almost 10 years ago

Please provide a failing test. Also, this code calls an undefined #check_if_user_want_to_receive_mail.

#2 Updated by g b almost 10 years ago

  • Status changed from New to Resolved

#3 Updated by Jean-Philippe Lang almost 10 years ago

  • Status changed from Resolved to New

#4 Updated by Jean-Philippe Lang almost 10 years ago

  • Status changed from New to Closed
  • Resolution set to No feedback

Also available in: Atom PDF