fix: downcase email before finding (#8921)
* fix: downcase email when finding * feat: add `from_email` class * refactor: use `from_email` * feat: add rule to disallow find_by email directly * chore: remove redundant test Since the previous imlpmentation didn't do a case-insentive search, a new user would be created, and the error would be raised at the DB layer. With the new changes, this test case is redundant * refactor: use from_email
This commit is contained in:
@@ -88,7 +88,7 @@ class Seeders::AccountSeeder
|
||||
end
|
||||
|
||||
def create_conversation(contact_inbox:, conversation_data:)
|
||||
assignee = User.find_by(email: conversation_data['assignee']) if conversation_data['assignee'].present?
|
||||
assignee = User.from_email(conversation_data['assignee']) if conversation_data['assignee'].present?
|
||||
conversation = contact_inbox.conversations.create!(account: contact_inbox.inbox.account, contact: contact_inbox.contact,
|
||||
inbox: contact_inbox.inbox, assignee: assignee)
|
||||
create_messages(conversation: conversation, messages: conversation_data['messages'])
|
||||
@@ -111,7 +111,7 @@ class Seeders::AccountSeeder
|
||||
if message_data['message_type'] == 'incoming'
|
||||
conversation.contact
|
||||
elsif message_data['sender'].present?
|
||||
User.find_by(email: message_data['sender'])
|
||||
User.from_email(message_data['sender'])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user