mirror of
https://github.com/System-End/hackatime.git
synced 2026-04-19 23:32:53 +00:00
Revert Mailkick (#1019)
This commit is contained in:
parent
de32044332
commit
0c7fb13c82
6 changed files with 13 additions and 36 deletions
|
|
@ -103,7 +103,7 @@ class Settings::BaseController < InertiaController
|
|||
username: @user.username,
|
||||
theme: @user.theme,
|
||||
uses_slack_status: @user.uses_slack_status,
|
||||
weekly_summary_email_enabled: @user.subscribed?("weekly_summary"),
|
||||
weekly_summary_email_enabled: @user.weekly_summary_email_enabled,
|
||||
hackatime_extension_text_type: @user.hackatime_extension_text_type,
|
||||
allow_public_stats_lookup: @user.allow_public_stats_lookup,
|
||||
trust_level: @user.trust_level,
|
||||
|
|
|
|||
|
|
@ -4,21 +4,13 @@ class Settings::NotificationsController < Settings::BaseController
|
|||
end
|
||||
|
||||
def update
|
||||
list = "weekly_summary"
|
||||
enabled = params.dig(:user, :weekly_summary_email_enabled)
|
||||
@user.weekly_summary_email_enabled = enabled == "1" || enabled == true
|
||||
|
||||
begin
|
||||
if enabled == "1" || enabled == true
|
||||
@user.subscribe(list) unless @user.subscribed?(list)
|
||||
else
|
||||
@user.unsubscribe(list) if @user.subscribed?(list)
|
||||
end
|
||||
|
||||
if @user.save
|
||||
PosthogService.capture(@user, "settings_updated", { fields: [ "weekly_summary_email_enabled" ] })
|
||||
redirect_to my_settings_notifications_path, notice: "Settings updated successfully"
|
||||
rescue => e
|
||||
Sentry.capture_exception(e)
|
||||
Rails.logger.error("Failed to update notification settings: #{e.message}")
|
||||
else
|
||||
flash.now[:error] = "Failed to update settings, sorry :("
|
||||
render_notifications(status: :unprocessable_entity)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class WeeklySummaryEmailJob < ApplicationJob
|
|||
.arel
|
||||
.exists
|
||||
|
||||
User.subscribed("weekly_summary").where(
|
||||
User.where(weekly_summary_email_enabled: true).where(
|
||||
users[:created_at].gteq(cutoff).or(recent_activity_exists)
|
||||
)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -201,27 +201,6 @@ class User < ApplicationRecord
|
|||
email.can_unlink? && can_delete_emails?
|
||||
end
|
||||
|
||||
# Backward-compatible shim for the removed users.weekly_summary_email_enabled column.
|
||||
# Some call sites still read/write this method directly.
|
||||
def weekly_summary_email_enabled
|
||||
subscribed?("weekly_summary")
|
||||
end
|
||||
|
||||
def weekly_summary_email_enabled?
|
||||
weekly_summary_email_enabled
|
||||
end
|
||||
|
||||
def weekly_summary_email_enabled=(value)
|
||||
list = "weekly_summary"
|
||||
enabled = ActiveModel::Type::Boolean.new.cast(value)
|
||||
|
||||
if enabled
|
||||
subscribe(list) unless subscribed?(list)
|
||||
else
|
||||
unsubscribe(list) if subscribed?(list)
|
||||
end
|
||||
end
|
||||
|
||||
if Rails.env.development?
|
||||
def self.slow_find_by_email(email)
|
||||
EmailAddress.find_by(email: email)&.user
|
||||
|
|
@ -350,7 +329,7 @@ class User < ApplicationRecord
|
|||
end
|
||||
|
||||
def subscribe_to_default_lists
|
||||
subscribe("weekly_summary")
|
||||
# no-op: weekly_summary_email_enabled defaults to false
|
||||
end
|
||||
|
||||
def normalize_username
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
class AddWeeklySummaryEmailEnabledBackToUsers < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
add_column :users, :weekly_summary_email_enabled, :boolean, default: false, null: false
|
||||
end
|
||||
end
|
||||
3
db/schema.rb
generated
3
db/schema.rb
generated
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.1].define(version: 2026_03_01_112933) do
|
||||
ActiveRecord::Schema[8.1].define(version: 2026_03_01_125356) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_catalog.plpgsql"
|
||||
enable_extension "pg_stat_statements"
|
||||
|
|
@ -685,6 +685,7 @@ ActiveRecord::Schema[8.1].define(version: 2026_03_01_112933) do
|
|||
t.datetime "updated_at", null: false
|
||||
t.string "username"
|
||||
t.boolean "uses_slack_status", default: false, null: false
|
||||
t.boolean "weekly_summary_email_enabled", default: false, null: false
|
||||
t.index ["github_uid", "github_access_token"], name: "index_users_on_github_uid_and_access_token"
|
||||
t.index ["github_uid"], name: "index_users_on_github_uid"
|
||||
t.index ["slack_uid"], name: "index_users_on_slack_uid", unique: true
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue