fix: Add Attachment endpoint to save file against automation rule (#4480)
Co-authored-by: fayazara <fayazara@gmail.com> Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
@@ -28,7 +28,6 @@ class Attachment < ApplicationRecord
|
||||
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
|
||||
application/vnd.openxmlformats-officedocument.wordprocessingml.document
|
||||
].freeze
|
||||
|
||||
belongs_to :account
|
||||
belongs_to :message
|
||||
has_one_attached :file
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
# index_automation_rules_on_account_id (account_id)
|
||||
#
|
||||
class AutomationRule < ApplicationRecord
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
belongs_to :account
|
||||
has_many_attached :files
|
||||
|
||||
@@ -28,7 +30,21 @@ class AutomationRule < ApplicationRecord
|
||||
scope :active, -> { where(active: true) }
|
||||
|
||||
CONDITIONS_ATTRS = %w[content email country_code status message_type browser_language assignee_id team_id referer city company inbox_id].freeze
|
||||
ACTIONS_ATTRS = %w[send_message add_label send_email_to_team assign_team assign_best_agents send_attachments].freeze
|
||||
ACTIONS_ATTRS = %w[send_message add_label send_email_to_team assign_team assign_best_agents send_attachment].freeze
|
||||
|
||||
def file_base_data
|
||||
files.map do |file|
|
||||
{
|
||||
id: file.id,
|
||||
automation_rule_id: id,
|
||||
file_type: file.content_type,
|
||||
account_id: account_id,
|
||||
file_url: url_for(file),
|
||||
blob_id: file.blob_id,
|
||||
filename: file.filename.to_s
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
||||
Reference in New Issue
Block a user