parent
67fc2cc75c
commit
89cdf1101a
|
@ -38,7 +38,7 @@ private
|
|||
:email_replies, :email_messages, :email_mentions,
|
||||
:pushover_replies, :pushover_messages, :pushover_mentions,
|
||||
:pushover_user_key, :pushover_device, :pushover_sound,
|
||||
:mailing_list_enabled,
|
||||
:mailing_list_mode,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -151,9 +151,10 @@
|
|||
</p>
|
||||
|
||||
<div class="boxline">
|
||||
<%= f.label :mailing_list_enabled, "Receive List E-mails:",
|
||||
<%= f.label :mailing_list_mode, "Receive List E-mails:",
|
||||
:class => "required" %>
|
||||
<%= f.check_box :mailing_list_enabled%>
|
||||
<%= f.select :mailing_list_mode, [ [ "No e-mails", 0 ],
|
||||
[ "All stories and comments", 1 ], [ "Only stories", 2 ] ] %>
|
||||
</div>
|
||||
|
||||
<div class="boxline">
|
||||
|
|
6
db/migrate/20140219183804_change_mailing_list_enabled.rb
Normal file
6
db/migrate/20140219183804_change_mailing_list_enabled.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class ChangeMailingListEnabled < ActiveRecord::Migration
|
||||
def change
|
||||
rename_column :users, :mailing_list_enabled, :mailing_list_mode
|
||||
change_column :users, :mailing_list_mode, :integer, :default => 0
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20140121063641) do
|
||||
ActiveRecord::Schema.define(version: 20140219183804) do
|
||||
|
||||
create_table "comments", force: true do |t|
|
||||
t.datetime "created_at", null: false
|
||||
|
@ -156,7 +156,7 @@ ActiveRecord::Schema.define(version: 20140121063641) do
|
|||
t.boolean "pushover_mentions", default: false
|
||||
t.string "rss_token", limit: 75
|
||||
t.string "mailing_list_token", limit: 75
|
||||
t.boolean "mailing_list_enabled", default: false
|
||||
t.integer "mailing_list_mode", default: 0
|
||||
t.integer "karma", default: 0, null: false
|
||||
t.datetime "banned_at"
|
||||
t.integer "banned_by_user_id"
|
||||
|
@ -165,7 +165,7 @@ ActiveRecord::Schema.define(version: 20140121063641) do
|
|||
t.string "pushover_sound"
|
||||
end
|
||||
|
||||
add_index "users", ["mailing_list_enabled"], name: "mailing_list_enabled", using: :btree
|
||||
add_index "users", ["mailing_list_mode"], name: "mailing_list_enabled", using: :btree
|
||||
add_index "users", ["mailing_list_token"], name: "mailing_list_token", unique: true, using: :btree
|
||||
add_index "users", ["password_reset_token"], name: "password_reset_token", unique: true, using: :btree
|
||||
add_index "users", ["rss_token"], name: "rss_token", unique: true, using: :btree
|
||||
|
|
|
@ -44,7 +44,7 @@ EMAIL_WIDTH = 72
|
|||
LAST_STORY_KEY = "mailing:last_story_id"
|
||||
LAST_COMMENT_KEY = "mailing:last_comment_id"
|
||||
|
||||
mailing_list_users = User.where(:mailing_list_enabled => true).select{|u|
|
||||
mailing_list_users = User.where("mailing_list_mode > 0").select{|u|
|
||||
u.is_active? }
|
||||
|
||||
last_story_id = (Keystore.value_for(LAST_STORY_KEY) || Story.last.id).to_i
|
||||
|
@ -127,6 +127,11 @@ last_comment_id, false, false).order(:id).each do |c|
|
|||
end
|
||||
|
||||
mailing_list_users.each do |u|
|
||||
if u.mailing_list_mode == 2
|
||||
# stories only
|
||||
next
|
||||
end
|
||||
|
||||
if (c.story.tags.map{|t| t.id } & u.tag_filters.map{|t| t.tag_id }).any?
|
||||
next
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue