FIX: sending messages to groups with non-lowercase names

Fixes a regression in

e8fb9d406667c758cba0f7b1cc779e1ceb352c4c

which caused a bug where you couldn't send a message to a group that
contained an Uppercase letter. Added a test case for this.

Bug report: https://meta.discourse.org/t/-/152999
This commit is contained in:
Blake Erickson
2020-05-27 14:49:00 -06:00
parent 75f46ca632
commit 6548cd1a96
3 changed files with 27 additions and 3 deletions

View File

@ -246,10 +246,10 @@ class TopicCreator
def add_groups(topic, groups)
return unless groups
names = groups.split(',').flatten
names = groups.split(',').flatten.map(&:downcase)
len = 0
Group.where(name: names).each do |group|
Group.where('lower(name) in (?)', names).each do |group|
check_can_send_permission!(topic, group)
topic.topic_allowed_groups.build(group_id: group.id)
len += 1