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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
17
app/models/group_join_request.rb
Normal file
17
app/models/group_join_request.rb
Normal 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
|
||||
Reference in New Issue
Block a user