logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

follow_request.rb (891B)


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