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:
Pranav Raj S
2020-10-05 22:52:43 +05:30
committed by GitHub
parent ee119b2174
commit 399f9e004a
11 changed files with 56 additions and 7 deletions

View File

@@ -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