# frozen_string_literal: true

# == Schema Information
#
# Table name: inboxes
#
#  id           :bigint           not null, primary key
#  box_type     :string(191)      default("Review")
#  done         :boolean          default(FALSE)
#  message      :text(65535)
#  created_at   :datetime         not null
#  updated_at   :datetime         not null
#  article_id   :bigint
#  from_user_id :bigint
#  to_user_id   :bigint
#
class Inbox < ApplicationRecord
  belongs_to :from_user, class_name: "User"
  belongs_to :article, optional: true
  belongs_to :to_user, class_name: "User"

  def title
    if box_type == "Review"
      "你有新的待审核文章"
    elsif box_type == "Approve"
      "你的文章已审核通过"
    elsif box_type == "Disapprove"
      "你的文章被拒绝"
    elsif box_type == "Comment"
      "你的文章有新的评论"
    elsif box_type == "Admin"
      "你有新的权限变更"
    elsif box_type == "Useful"
      "你的文章被点赞"
    else
      "你有新的消息"
    end
  end
end
