diff --git a/app/models/person_notifier.rb b/app/models/person_notifier.rb index e6ec250..9cb0d53 100644 --- a/app/models/person_notifier.rb +++ b/app/models/person_notifier.rb @@ -22,12 +22,17 @@ class PersonNotifier schedule_next_notification_mail end + def notify_from + @person.last_notification || DateTime.now - @person.notification_time.hours + end + def notify if @person.notification_time && @person.notification_time > 0 - from = @person.last_notification || DateTime.now - @person.notification_time.hours - notifications = @person.tracked_notifications.find(:all, :conditions => ["created_at > ?", from]) + notifications = @person.tracked_notifications.find(:all, :conditions => ["created_at > ?", notify_from]) + tasks = Task.to(@person).without_spam.pending.where("created_at > ?", notify_from).order_by('created_at', 'asc') + Noosfero.with_locale @person.environment.default_language do - Mailer::content_summary(@person, notifications).deliver unless notifications.empty? + Mailer::content_summary(@person, notifications, tasks).deliver unless notifications.empty? && tasks.empty? end @person.settings[:last_notification] = DateTime.now @person.save! @@ -77,7 +82,7 @@ class PersonNotifier {:theme => nil} end - def content_summary(person, notifications) + def content_summary(person, notifications, tasks) if person.environment ActionMailer::Base.asset_host = person.environment.top_url ActionMailer::Base.default_url_options[:host] = person.environment.default_hostname @@ -87,13 +92,14 @@ class PersonNotifier @profile = person @recipient = @profile.nickname || @profile.name @notifications = notifications + @tasks = tasks @environment = @profile.environment.name @url = @profile.environment.top_url mail( content_type: "text/html", from: "#{@profile.environment.name} <#{@profile.environment.noreply_email}>", to: @profile.email, - subject: _("[%s] Network Activity") % [@profile.environment.name] + subject: _("[%s] Notifications") % [@profile.environment.name] ) end end diff --git a/app/views/person_notifier/mailer/_task.html.erb b/app/views/person_notifier/mailer/_task.html.erb new file mode 100644 index 0000000..b00d8e9 --- /dev/null +++ b/app/views/person_notifier/mailer/_task.html.erb @@ -0,0 +1,20 @@ +
+ <%= profile_image(task.requestor, :minor) %> + | +
+
+ <%= link_to task.title, url_for(:controller => 'tasks', :profile => @profile.identifier, :action => 'index', :only_path => false) %>
+
+
+
+ <%= task_information(task) %>
+
+ <%= time_ago_as_sentence(task.created_at) %>
+
+ |
+
<%= _("Greetings,") %>
+<%= _('%s team.') % @environment %>
+<%= link_to @url, url_for(@url) %>
<%= _("Greetings,") %>
-<%= _('%s team.') % @environment %>
-<%= link_to @url, url_for(@url) %>