mirror of https://github.com/mastodon/mastodon
Change delivery failure tracking to work with hostnames instead of URLs (#13437)
parent
5524258da9
commit
5edff32733
@ -0,0 +1,22 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: unavailable_domains
|
||||||
|
#
|
||||||
|
# id :bigint(8) not null, primary key
|
||||||
|
# domain :string default(""), not null
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
#
|
||||||
|
|
||||||
|
class UnavailableDomain < ApplicationRecord
|
||||||
|
include DomainNormalizable
|
||||||
|
|
||||||
|
after_commit :reset_cache!
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def reset_cache!
|
||||||
|
Rails.cache.delete('unavailable_domains')
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,9 @@
|
|||||||
|
class CreateUnavailableDomains < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
create_table :unavailable_domains do |t|
|
||||||
|
t.string :domain, default: '', null: false, index: { unique: true }
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,16 @@
|
|||||||
|
class MigrateUnavailableInboxes < ActiveRecord::Migration[5.2]
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
|
def up
|
||||||
|
urls = Redis.current.smembers('unavailable_inboxes')
|
||||||
|
|
||||||
|
urls.each do |url|
|
||||||
|
host = Addressable::URI.parse(url).normalized_host
|
||||||
|
UnavailableDomain.create(domain: host)
|
||||||
|
end
|
||||||
|
|
||||||
|
Redis.current.del(*(['unavailable_inboxes'] + Redis.current.keys('exhausted_deliveries:*')))
|
||||||
|
end
|
||||||
|
|
||||||
|
def down; end
|
||||||
|
end
|
@ -0,0 +1,3 @@
|
|||||||
|
Fabricator(:unavailable_domain) do
|
||||||
|
domain { Faker::Internet.domain }
|
||||||
|
end
|
@ -0,0 +1,4 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe UnavailableDomain, type: :model do
|
||||||
|
end
|
Loading…
Reference in New Issue