Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the issue with csv content_type and empty mail atttachment #29

Open
wants to merge 1 commit into
base: engine
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/models/light/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def self.add_users_from_worksheet(worksheet, column = 1)
end

def self.import(file, email='')
return {error: "Please select CSV file"} if (file.blank? or file.content_type != 'text/csv')
mime_types = ['application/vnd.ms-excel', 'text/csv']
return {error: "Please select CSV file"} unless (file.present? && mime_types.include?(file.content_type) )
file = CSV.open(file.path, :row_sep => :auto, :col_sep => ",")
rows = file.read
header = rows.delete_at(0)
Expand Down
2 changes: 1 addition & 1 deletion app/workers/light/import_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def perform(rows, email_id, source = "Business Card")
is_subscribed: false, sidekiq_status: Light::User::NEW_USER) if email.present? or name.present?
csv << [email, row[0], user.errors.messages] if user.present? and user.errors.present?
end
UserMailer.import_contacts_update(email_id, file_path).deliver
end
UserMailer.delay_for(30.seconds).import_contacts_update(email_id, file_path)
end
end
end