extract email assets

This commit is contained in:
Pete Matsyburka
2026-06-29 12:30:10 +03:00
parent 065dcf6f9f
commit 6ed5b5d35d
8 changed files with 127 additions and 6 deletions
+30
View File
@@ -0,0 +1,30 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: email_message_assets
#
# id :bigint not null, primary key
# data :text not null
# sha1 :string not null
# created_at :datetime not null
# updated_at :datetime not null
# account_id :bigint not null
#
# Indexes
#
# index_email_message_assets_on_account_id_and_sha1 (account_id,sha1) UNIQUE
#
# Foreign Keys
#
# fk_rails_... (account_id => accounts.id)
#
class EmailMessageAsset < ApplicationRecord
belongs_to :account
before_validation :set_sha1, on: :create
def set_sha1
self.sha1 = Digest::SHA1.hexdigest(data.to_s)
end
end