Complete refactoring of messaging module. From now messages are saved only once and send afterwards via a the 'send_emails'-rake-task.
This commit is contained in:
parent
6ce6c2c75a
commit
e8d55e50c0
30 changed files with 220 additions and 349 deletions
|
|
@ -118,15 +118,13 @@ class Ordergroup < Group
|
|||
def notifyNegativeBalance(transaction)
|
||||
# Notify only when order group had a positive balance before the last transaction:
|
||||
if (transaction.amount < 0 && self.account_balance < 0 && self.account_balance - transaction.amount >= 0)
|
||||
users = self.users.reject{|u| u.settings["notify.negativeBalance"] != '1'}
|
||||
unless (users.empty?)
|
||||
recipients = users.collect{|u| u.nick}.join(', ')
|
||||
for user in users
|
||||
Message.from_template(
|
||||
'negative_balance',
|
||||
{:user => user, :group => self, :transaction => transaction},
|
||||
{:recipient_id => user.id, :recipients => recipients, :subject => "Gruppenkonto im Minus"}
|
||||
).save!
|
||||
users = self.users.reject { |u| u.settings["notify.negativeBalance"] != '1' }
|
||||
unless users.empty?
|
||||
Message.from_template(
|
||||
'negative_balance',
|
||||
{:group => self, :transaction => transaction},
|
||||
{:recipients_ids => users.collect(&:id), :subject => "Gruppenkonto im Minus"}
|
||||
).save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue