Skip to content

Commit

Permalink
refactor: Remove deprecated "belongs_to" relationships in Message (#7434
Browse files Browse the repository at this point in the history
)

- Remove the deprecated columns in message model
  • Loading branch information
jordan-brough committed Jul 27, 2023
1 parent ff97536 commit a7bc855
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
4 changes: 0 additions & 4 deletions app/models/message.rb
Expand Up @@ -117,10 +117,6 @@ class Message < ApplicationRecord
belongs_to :account
belongs_to :inbox
belongs_to :conversation, touch: true

# FIXME: phase out user and contact after 1.4 since the info is there in sender
belongs_to :user, required: false
belongs_to :contact, required: false
belongs_to :sender, polymorphic: true, required: false

has_many :attachments, dependent: :destroy, autosave: true, before_add: :validate_attachments_limit
Expand Down
Expand Up @@ -22,7 +22,7 @@ if conversation.messages.first.blank?
elsif conversation.unread_incoming_messages.count.zero?
json.messages [conversation.messages.includes([{ attachments: [{ file_attachment: [:blob] }] }]).last.try(:push_event_data)]
else
json.messages conversation.unread_messages.includes([:user, { attachments: [{ file_attachment: [:blob] }] }]).last(10).map(&:push_event_data)
json.messages conversation.unread_messages.includes([{ attachments: [{ file_attachment: [:blob] }] }]).last(10).map(&:push_event_data)
end

json.account_id conversation.account_id
Expand Down

0 comments on commit a7bc855

Please sign in to comment.