mirror of
https://github.com/internetee/registry.git
synced 2025-06-04 11:47:30 +02:00
Move emails & domains to citext, CC fixes
This commit is contained in:
parent
438a2e05ab
commit
f8eea08357
5 changed files with 34 additions and 12 deletions
|
@ -2,10 +2,7 @@ class VerifyEmailsJob < Que::Job
|
|||
def run(verification_id)
|
||||
email_address_verification = run_condition(EmailAddressVerification.find(verification_id))
|
||||
|
||||
if email_address_verification.recently_verified?
|
||||
destroy
|
||||
return
|
||||
end
|
||||
return if email_address_verification.recently_verified?
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
email_address_verification.verify
|
||||
|
|
|
@ -3,15 +3,15 @@ module Concerns
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
def email_verification
|
||||
EmailAddressVerification.find_or_create_by(email: email,
|
||||
domain: domain(email))
|
||||
EmailAddressVerification.find_or_create_by(email: email.downcase,
|
||||
domain: domain(email.downcase))
|
||||
end
|
||||
|
||||
def billing_email_verification
|
||||
return unless attribute_names.include?('billing_email')
|
||||
|
||||
EmailAddressVerification.find_or_create_by(email: billing_email,
|
||||
domain: domain(email))
|
||||
EmailAddressVerification.find_or_create_by(email: billing_email.downcase,
|
||||
domain: domain(email.downcase))
|
||||
end
|
||||
|
||||
def domain(email)
|
||||
|
|
|
@ -62,6 +62,10 @@ if @cron_group == 'registry'
|
|||
rake 'domain:discard'
|
||||
end
|
||||
|
||||
every 10.minutes do
|
||||
rake 'verify_email:all_domains'
|
||||
end
|
||||
|
||||
# Should be at least once every 4 days, since according to LHV specs:
|
||||
# "Unread messages older than 5 days are automatically scheduled for deletion"
|
||||
# https://partners.lhv.ee/en/connect/#messaging
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
class ChangeEmailVerificationFieldsToCitext < ActiveRecord::Migration[6.0]
|
||||
def up
|
||||
enable_extension 'citext'
|
||||
change_column :email_address_verifications, :email, :citext
|
||||
change_column :email_address_verifications, :domain, :citext
|
||||
end
|
||||
|
||||
def down
|
||||
change_column :email_address_verifications, :email, :string
|
||||
change_column :email_address_verifications, :domain, :string
|
||||
disable_extension 'citext'
|
||||
end
|
||||
end
|
|
@ -33,10 +33,17 @@ CREATE EXTENSION IF NOT EXISTS btree_gist WITH SCHEMA public;
|
|||
|
||||
|
||||
--
|
||||
-- Name: EXTENSION btree_gist; Type: COMMENT; Schema: -; Owner: -
|
||||
-- Name: citext; Type: EXTENSION; Schema: -; Owner: -
|
||||
--
|
||||
|
||||
COMMENT ON EXTENSION btree_gist IS 'support for indexing common datatypes in GiST';
|
||||
CREATE EXTENSION IF NOT EXISTS citext WITH SCHEMA public;
|
||||
|
||||
|
||||
--
|
||||
-- Name: EXTENSION citext; Type: COMMENT; Schema: -; Owner: -
|
||||
--
|
||||
|
||||
COMMENT ON EXTENSION citext IS 'data type for case-insensitive character strings';
|
||||
|
||||
|
||||
--
|
||||
|
@ -822,10 +829,10 @@ ALTER SEQUENCE public.domains_id_seq OWNED BY public.domains.id;
|
|||
|
||||
CREATE TABLE public.email_address_verifications (
|
||||
id bigint NOT NULL,
|
||||
email character varying NOT NULL,
|
||||
email public.citext NOT NULL,
|
||||
verified_at timestamp without time zone,
|
||||
success boolean DEFAULT false NOT NULL,
|
||||
domain character varying NOT NULL
|
||||
domain public.citext NOT NULL
|
||||
);
|
||||
|
||||
|
||||
|
@ -4700,5 +4707,6 @@ INSERT INTO "schema_migrations" (version) VALUES
|
|||
('20200518104105'),
|
||||
('20200529115011'),
|
||||
('20200605100827'),
|
||||
('20200610090110'),
|
||||
('20200630081231');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue