Added join requests to Groups

• Added:
- join requests to Groups
- redux actions, reducers
- controller and functionality for fetching join requests, accepting, rejecting join requests
This commit is contained in:
mgabdev
2020-09-10 17:07:00 -05:00
parent a8056f80a2
commit 217aab9faa
13 changed files with 456 additions and 6 deletions

View File

@@ -17,6 +17,10 @@ module GroupInteractions
follow_mapping(GroupAccount.where(group_id: target_group_ids, account_id: account_id, role: :moderator), :group_id)
end
def requested_map(target_group_ids, account_id)
follow_mapping(GroupJoinRequest.where(group_id: target_group_ids, account_id: account_id), :group_id)
end
def pinned?(status)
group_pinned_statuses.where(group_id: status.group_id, status: status).exists?
end

View File

@@ -35,6 +35,9 @@ class Group < ApplicationRecord
has_many :group_accounts, inverse_of: :group, dependent: :destroy
has_many :accounts, through: :group_accounts
has_many :group_join_requests, inverse_of: :group, dependent: :destroy
has_many :join_requests, source: :account, through: :group_join_requests
has_many :group_pinned_statuses, inverse_of: :group, dependent: :destroy
has_many :pinned_statuses, source: :status, through: :group_pinned_statuses

View File

@@ -0,0 +1,17 @@
# == Schema Information
#
# Table name: group_join_requests
#
# id :bigint(8) not null, primary key
# account_id :bigint(8) not null
# group_id :bigint(8) not null
# created_at :datetime not null
# updated_at :datetime not null
#
class GroupJoinRequest < ApplicationRecord
belongs_to :group
belongs_to :account
validates :account_id, uniqueness: { scope: :group_id }
end