Don't allow sending messages to deactivated users or realms

We still don't show this in the frontend, aside from our usual "Not
delivered" message that we also show when you send to a non-existent
user.

Addresses #2349

(imported from commit 2f348b15a4d539987ddbcccbbf40e2be87c1f92d)
This commit is contained in:
Luke Faraone 2014-03-05 14:14:50 -05:00
parent 9ea3198ddf
commit f4196ed6ef
1 changed files with 3 additions and 0 deletions

View File

@ -547,6 +547,9 @@ def recipient_for_emails(emails, not_forged_mirror_message,
user_profile = get_user_profile_by_email(email)
except UserProfile.DoesNotExist:
raise ValidationError("Invalid email '%s'" % (email,))
if (not user_profile.is_active and not user_profile.is_mirror_dummy) or \
user_profile.realm.deactivated:
raise ValidationError("'%s' is no longer using Zulip." % (email,))
recipient_profile_ids.add(user_profile.id)
realm_domains.add(user_profile.realm.domain)