fix: Update account data seeder to avoid invalid information (#7673)
- The message sender was incorrect. Incoming messages were created under the contact's name, and outgoing messages were created under the user's name instead of the reverse. - The seed user's email address was incorrect in the message data. - The Sendmail configuration overrode the Letter Opener config which made it difficult to test the email. - This PR also fixes an ESLint lint issue on develop.
This commit is contained in:
@@ -96,16 +96,19 @@ class Seeders::AccountSeeder
|
||||
def create_messages(conversation:, messages:)
|
||||
messages.each do |message_data|
|
||||
sender = find_message_sender(conversation, message_data)
|
||||
conversation.messages.create!(message_data.slice('content', 'message_type').merge(account: conversation.inbox.account, sender: sender,
|
||||
inbox: conversation.inbox))
|
||||
conversation.messages.create!(
|
||||
message_data.slice('content', 'message_type').merge(
|
||||
account: conversation.inbox.account, sender: sender, inbox: conversation.inbox
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def find_message_sender(conversation, message_data)
|
||||
if message_data['message_type'] == 'incoming'
|
||||
User.find_by(email: message_data['sender']) if message_data['sender'].present?
|
||||
else
|
||||
conversation.contact
|
||||
elsif message_data['sender'].present?
|
||||
User.find_by(email: message_data['sender'])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user