2020-12-03 04:22:51 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: chat_messages
|
|
|
|
#
|
2020-12-03 22:13:11 +00:00
|
|
|
# id :bigint(8) not null, primary key
|
|
|
|
# text :text default(""), not null
|
|
|
|
# language :text default(""), not null
|
|
|
|
# from_account_id :integer not null
|
|
|
|
# chat_conversation_id :integer not null
|
|
|
|
# created_at :datetime not null
|
|
|
|
# updated_at :datetime not null
|
|
|
|
# expires_at :datetime
|
2020-12-03 04:22:51 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
class ChatMessage < ApplicationRecord
|
|
|
|
include Paginable
|
|
|
|
|
|
|
|
belongs_to :from_account, class_name: 'Account'
|
|
|
|
belongs_to :chat_conversation
|
|
|
|
|
|
|
|
validates_with ChatMessageLengthValidator
|
|
|
|
|
|
|
|
default_scope { recent }
|
|
|
|
|
|
|
|
scope :recent, -> { reorder(created_at: :desc) }
|
|
|
|
|
2020-12-04 03:27:09 +00:00
|
|
|
def emojis
|
|
|
|
return @emojis if defined?(@emojis)
|
|
|
|
|
|
|
|
@emojis = CustomEmoji.from_text(text)
|
|
|
|
end
|
2020-12-03 04:22:51 +00:00
|
|
|
end
|