FEATURE: allow for notification of up to 20 group owners (#13081)

The 5 limit appears to be too low. Limiting to 20 group owners, though high
seems like a fairer limit.

Also... spec cleanup
This commit is contained in:
Sam
2021-05-20 15:28:36 +10:00
committed by GitHub
parent 130160537c
commit 1a620cb01f
2 changed files with 5 additions and 8 deletions

View File

@ -480,6 +480,8 @@ class GroupsController < ApplicationController
)
end
MAX_NOTIFIED_OWNERS ||= 20
def request_membership
params.require(:reason)
@ -487,14 +489,14 @@ class GroupsController < ApplicationController
begin
GroupRequest.create!(group: group, user: current_user, reason: params[:reason])
rescue ActiveRecord::RecordNotUnique => e
rescue ActiveRecord::RecordNotUnique
return render json: failed_json.merge(error: I18n.t("groups.errors.already_requested_membership")), status: 409
end
usernames = [current_user.username].concat(
group.users.where('group_users.owner')
.order("users.last_seen_at DESC")
.limit(5)
.limit(MAX_NOTIFIED_OWNERS)
.pluck("users.username")
)