Turn 2-person huddles between the sender and other user into a personal on the backend

(imported from commit 959e7ea8101dc1d469d62ea2c7c7a65854679833)
This commit is contained in:
Zev Benjamin 2012-11-08 15:49:38 -05:00
parent 195bdb07c9
commit f851d9437d
1 changed files with 7 additions and 0 deletions

View File

@ -588,6 +588,13 @@ def send_message_backend(request, user_profile, sender, message_type_name = POST
recipient_profile_ids.add(UserProfile.objects.get(user__email=recipient).id)
except UserProfile.DoesNotExist:
return json_error("Invalid email '%s'" % (recipient,))
# If the private message is just between the sender and
# another person, force it to be a personal internally
if (len(recipient_profile_ids) == 2
and user_profile.id in recipient_profile_ids):
recipient_profile_ids.remove(user_profile.id)
if len(recipient_profile_ids) > 1:
# Make sure the sender is included in huddle messages
recipient_profile_ids.add(sender.id)