You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
888 B

  1. # frozen_string_literal: true
  2. # == Schema Information
  3. #
  4. # Table name: follow_requests
  5. #
  6. # created_at :datetime not null
  7. # updated_at :datetime not null
  8. # account_id :bigint not null
  9. # id :bigint not null, primary key
  10. # target_account_id :bigint not null
  11. # show_reblogs :boolean default(TRUE), not null
  12. #
  13. class FollowRequest < ApplicationRecord
  14. include Paginable
  15. belongs_to :account, required: true
  16. belongs_to :target_account, class_name: 'Account', required: true
  17. has_one :notification, as: :activity, dependent: :destroy
  18. validates :account_id, uniqueness: { scope: :target_account_id }
  19. def authorize!
  20. account.follow!(target_account, reblogs: show_reblogs)
  21. MergeWorker.perform_async(target_account.id, account.id)
  22. destroy!
  23. end
  24. alias reject! destroy!
  25. end