use case insensitive communication channel address queries

fixes CNVS-16978

test plan
- create a discussion topic
- cause a reply-to-able notification about the topic to be sent to
 a user
- lock the topic
- change the user's email address to some non-standard capitalization
 scheme (all uppercase works fine)
- reply to the notification
- ensure that the user receives a message indicating that the topic
 was locked

Change-Id: I78d53ce1f9affc76fd040c0e24e99bc1d4edb9e2
Reviewed-on: https://gerrit.instructure.com/54631
Tested-by: Jenkins
Reviewed-by: Andrew Butterfield <abutterfield@instructure.com>
QA-Review: Steven Shepherd <sshepherd@instructure.com>
Product-Review: Joel Hough <joel@instructure.com>
This commit is contained in:
Joel Hough 2015-05-19 17:10:11 -06:00
parent 625c1748e5
commit 9fee104a3b
3 changed files with 4 additions and 3 deletions

View File

@ -69,7 +69,7 @@ module IncomingMail
outgoing_message_delivered = false
original_message.shard.activate do
comch = CommunicationChannel.active.where(path: incoming_from, path_type: 'email').first
comch = CommunicationChannel.active.email.by_path(incoming_from).first
outgoing_message.communication_channel = comch
outgoing_message.user = comch.try(:user)
if outgoing_message.communication_channel

View File

@ -393,7 +393,7 @@ class Pseudonym < ActiveRecord::Base
end
self.save
if old_user_id
CommunicationChannel.where(:path => self.unique_id, :user_id => old_user_id).update_all(:user_id => user)
CommunicationChannel.by_path(self.unique_id).where(:user_id => old_user_id).update_all(:user_id => user)
User.where(:id => [old_user_id, user]).update_all(:update_at => Time.now.utc)
end
if User.find(old_user_id).pseudonyms.empty? && migrate

View File

@ -802,7 +802,8 @@ class User < ActiveRecord::Base
if e.is_a?(CommunicationChannel) and e.user_id == self.id
cc = e
else
cc = self.communication_channels.where(path: e, path_type: 'email').first_or_create
cc = self.communication_channels.email.by_path(e).first ||
self.communication_channels.email.create(path: e)
cc.user = self
end
cc.move_to_top