mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 22:52:10 +08:00
FIX: Send request membership PM to last 5 active group owner.
This commit is contained in:
parent
84d46bceb9
commit
0fc10161a5
|
@ -238,14 +238,19 @@ class GroupsController < ApplicationController
|
||||||
|
|
||||||
group = find_group(:id)
|
group = find_group(:id)
|
||||||
group_name = group.name
|
group_name = group.name
|
||||||
username = current_user.username
|
|
||||||
|
usernames = [current_user.username].concat(
|
||||||
|
group.users.where('group_users.owner')
|
||||||
|
.order("users.last_seen_at DESC")
|
||||||
|
.limit(5)
|
||||||
|
.pluck("users.username")
|
||||||
|
)
|
||||||
|
|
||||||
post = PostCreator.new(current_user,
|
post = PostCreator.new(current_user,
|
||||||
title: I18n.t('groups.request_membership_pm.title', group_name: group_name),
|
title: I18n.t('groups.request_membership_pm.title', group_name: group_name),
|
||||||
raw: I18n.t('groups.request_membership_pm.body', group_name: group_name),
|
raw: I18n.t('groups.request_membership_pm.body', group_name: group_name),
|
||||||
archetype: Archetype.private_message,
|
archetype: Archetype.private_message,
|
||||||
target_usernames: username,
|
target_usernames: usernames.join(','),
|
||||||
target_group_names: group_name,
|
|
||||||
skip_validations: true
|
skip_validations: true
|
||||||
).create!
|
).create!
|
||||||
|
|
||||||
|
|
|
@ -546,6 +546,10 @@ describe "Groups" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should create the right PM' do
|
it 'should create the right PM' do
|
||||||
|
owner1 = Fabricate(:user, last_seen_at: Time.zone.now)
|
||||||
|
owner2 = Fabricate(:user, last_seen_at: Time.zone.now - 1 .day)
|
||||||
|
[owner1, owner2].each { |owner| group.add_owner(owner) }
|
||||||
|
|
||||||
sign_in(user)
|
sign_in(user)
|
||||||
|
|
||||||
xhr :post, "/groups/#{group.name}/request_membership"
|
xhr :post, "/groups/#{group.name}/request_membership"
|
||||||
|
@ -568,8 +572,8 @@ describe "Groups" do
|
||||||
))
|
))
|
||||||
|
|
||||||
expect(topic.archetype).to eq(Archetype.private_message)
|
expect(topic.archetype).to eq(Archetype.private_message)
|
||||||
expect(topic.allowed_users).to eq([user])
|
expect(topic.allowed_users).to contain_exactly(user, owner1, owner2)
|
||||||
expect(topic.allowed_groups).to eq([group])
|
expect(topic.allowed_groups).to eq([])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user