Skip to content
Extraits de code Groupes Projets
Valider 6b81d100 rédigé par Eugen Rochko's avatar Eugen Rochko
Parcourir les fichiers

Add digest e-mails

parent f5457cc3
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -11,6 +11,7 @@ defaults: &defaults ...@@ -11,6 +11,7 @@ defaults: &defaults
favourite: false favourite: false
mention: false mention: false
follow_request: true follow_request: true
digest: true
interactions: interactions:
must_be_follower: false must_be_follower: false
must_be_following: false must_be_following: false
......
class AddLastEmailedAtToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :last_emailed_at, :datetime, null: true, default: nil
end
end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170301222600) do ActiveRecord::Schema.define(version: 20170303212857) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
...@@ -283,6 +283,7 @@ ActiveRecord::Schema.define(version: 20170301222600) do ...@@ -283,6 +283,7 @@ ActiveRecord::Schema.define(version: 20170301222600) do
t.string "encrypted_otp_secret_salt" t.string "encrypted_otp_secret_salt"
t.integer "consumed_timestep" t.integer "consumed_timestep"
t.boolean "otp_required_for_login" t.boolean "otp_required_for_login"
t.datetime "last_emailed_at"
t.index ["account_id"], name: "index_users_on_account_id", using: :btree t.index ["account_id"], name: "index_users_on_account_id", using: :btree
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
t.index ["email"], name: "index_users_on_email", unique: true, using: :btree t.index ["email"], name: "index_users_on_email", unique: true, using: :btree
......
...@@ -43,7 +43,7 @@ namespace :mastodon do ...@@ -43,7 +43,7 @@ namespace :mastodon do
namespace :feeds do namespace :feeds do
desc 'Clear timelines of inactive users' desc 'Clear timelines of inactive users'
task clear: :environment do task clear: :environment do
User.where('current_sign_in_at < ?', 14.days.ago).find_each do |user| User.confirmed.where('current_sign_in_at < ?', 14.days.ago).find_each do |user|
Redis.current.del(FeedManager.instance.key(:home, user.account_id)) Redis.current.del(FeedManager.instance.key(:home, user.account_id))
end end
end end
...@@ -53,4 +53,13 @@ namespace :mastodon do ...@@ -53,4 +53,13 @@ namespace :mastodon do
Redis.current.keys('feed:*').each { |key| Redis.current.del(key) } Redis.current.keys('feed:*').each { |key| Redis.current.del(key) }
end end
end end
namespace :emails do
desc 'Send out digest e-mails'
task digest: :environment do
User.confirmed.joins(:account).where(accounts: { silenced: false, suspended: false }).where('current_sign_in_at < ?', 20.days.ago).find_each do |user|
DigestMailerWorker.perform_async(user.id)
end
end
end
end end
# Preview all emails at http://localhost:3000/rails/mailers/notification_mailer # Preview all emails at http://localhost:3000/rails/mailers/notification_mailer
class NotificationMailerPreview < ActionMailer::Preview class NotificationMailerPreview < ActionMailer::Preview
# Preview this email at http://localhost:3000/rails/mailers/notification_mailer/mention # Preview this email at http://localhost:3000/rails/mailers/notification_mailer/mention
def mention def mention
# NotificationMailer.mention m = Mention.last
NotificationMailer.mention(m.account, Notification.find_by(activity: m))
end end
# Preview this email at http://localhost:3000/rails/mailers/notification_mailer/follow # Preview this email at http://localhost:3000/rails/mailers/notification_mailer/follow
def follow def follow
# NotificationMailer.follow f = Follow.last
NotificationMailer.follow(f.target_account, Notification.find_by(activity: f))
end end
# Preview this email at http://localhost:3000/rails/mailers/notification_mailer/favourite # Preview this email at http://localhost:3000/rails/mailers/notification_mailer/favourite
def favourite def favourite
# NotificationMailer.favourite f = Favourite.last
NotificationMailer.favourite(f.status.account, Notification.find_by(activity: f))
end end
# Preview this email at http://localhost:3000/rails/mailers/notification_mailer/reblog # Preview this email at http://localhost:3000/rails/mailers/notification_mailer/reblog
def reblog def reblog
# NotificationMailer.reblog r = Status.where.not(reblog_of_id: nil).first
NotificationMailer.reblog(r.reblog.account, Notification.find_by(activity: r))
end end
# Preview this email at http://localhost:3000/rails/mailers/notification_mailer/digest
def digest
NotificationMailer.digest(Account.first, since: 90.days.ago)
end
end end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter