Sha256: 626bf3c356f758f89e5ec716cace06377b848b74da8964f3be5ceb9841843c63

Contents?: true

Size: 526 Bytes

Versions: 8

Compression:

Stored size: 526 Bytes

Contents

module Storytime
  class PostNotifier
    def self.send_notifications_for(post_id)
      post = Storytime::Post.find_by(id: post_id)

      return if post.nil?

      unless post.notifications_sent_at
        post.update_attributes(notifications_sent_at: Time.now)

        post.site.active_email_subscriptions.each do |subscription|
          mail = Storytime::SubscriptionMailer.new_post_email(post, subscription)

          Rails::VERSION::MINOR < 2 ? mail.deliver : mail.deliver_now
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
storytime-2.1.6 lib/storytime/post_notifier.rb
storytime-2.1.5 lib/storytime/post_notifier.rb
storytime-2.1.4 lib/storytime/post_notifier.rb
storytime-2.1.3 lib/storytime/post_notifier.rb
storytime-2.1.2 lib/storytime/post_notifier.rb
storytime-2.1.1 lib/storytime/post_notifier.rb
storytime-2.1.0 lib/storytime/post_notifier.rb
storytime-2.0.0 lib/storytime/post_notifier.rb