fix: Use last_activity_at instead of updated_at for sorting (#1281)
Co-authored-by: Akash Srivastava <akash.srivastava.1911@gmail.com>
This commit is contained in:
@@ -129,6 +129,7 @@ class Message < ApplicationRecord
|
||||
def execute_after_create_commit_callbacks
|
||||
# rails issue with order of active record callbacks being executed
|
||||
# https://github.com/rails/rails/issues/20911
|
||||
set_conversation_activity
|
||||
dispatch_create_events
|
||||
send_reply
|
||||
execute_message_template_hooks
|
||||
@@ -191,4 +192,10 @@ class Message < ApplicationRecord
|
||||
def validate_attachments_limit(_attachment)
|
||||
errors.add(attachments: 'exceeded maximum allowed') if attachments.size >= NUMBER_OF_PERMITTED_ATTACHMENTS
|
||||
end
|
||||
|
||||
def set_conversation_activity
|
||||
# rubocop:disable Rails/SkipsModelValidations
|
||||
conversation.update_columns(last_activity_at: created_at)
|
||||
# rubocop:enable Rails/SkipsModelValidations
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user