From d61df21d69e5d8a4c9f10a98fbe35e4713024cfd Mon Sep 17 00:00:00 2001
From: Sam <sam.saffron@gmail.com>
Date: Mon, 4 Jul 2016 11:36:43 +1000
Subject: [PATCH] FEATURE: allow people to send messages to themselves (for
 notes etc)

---
 .../templates/components/composer-user-selector.hbs          | 1 -
 lib/guardian.rb                                              | 2 --
 spec/components/guardian_spec.rb                             | 5 +++--
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/app/assets/javascripts/discourse/templates/components/composer-user-selector.hbs b/app/assets/javascripts/discourse/templates/components/composer-user-selector.hbs
index 71b5e8176..3e5d25059 100644
--- a/app/assets/javascripts/discourse/templates/components/composer-user-selector.hbs
+++ b/app/assets/javascripts/discourse/templates/components/composer-user-selector.hbs
@@ -1,6 +1,5 @@
 {{#if showSelector}}
   {{user-selector topicId=topicId
-                  excludeCurrentUser='true'
                   onChangeCallback='triggerResize'
                   id="private-message-users"
                   includeMentionableGroups='true'
diff --git a/lib/guardian.rb b/lib/guardian.rb
index 28235ed80..c09e11ba9 100644
--- a/lib/guardian.rb
+++ b/lib/guardian.rb
@@ -267,8 +267,6 @@ class Guardian
     (target.is_a?(Group) || target.is_a?(User)) &&
     # User is authenticated
     authenticated? &&
-    # Can't send message to yourself
-    is_not_me?(target) &&
     # Have to be a basic level at least
     @user.has_trust_level?(SiteSetting.min_trust_to_send_messages) &&
     # PMs are enabled
diff --git a/spec/components/guardian_spec.rb b/spec/components/guardian_spec.rb
index 35f9108eb..28ba8468b 100644
--- a/spec/components/guardian_spec.rb
+++ b/spec/components/guardian_spec.rb
@@ -144,8 +144,9 @@ describe Guardian do
       expect(Guardian.new(user).can_send_private_message?(nil)).to be_falsey
     end
 
-    it "returns false when the target is the same as the user" do
-      expect(Guardian.new(user).can_send_private_message?(user)).to be_falsey
+    it "returns true when the target is the same as the user" do
+      # this is now allowed so yay
+      expect(Guardian.new(user).can_send_private_message?(user)).to be_truthy
     end
 
     it "returns false when you are untrusted" do