Go to file
Steve Howell c43a29ff54 invites: Fix bug with inviting cross realm bots.
Without the fix here, you will get an exception
similar to below if you try to invite one of the
cross realm bots.  (The actual exception is
a bit different due to some rebasing on my branch.)

	  File "/home/zulipdev/zulip/zerver/lib/request.py", line 368, in _wrapped_view_func
		return view_func(request, *args, **kwargs)
	  File "/home/zulipdev/zulip/zerver/views/invite.py", line 49, in invite_users_backend
		do_invite_users(user_profile, invitee_emails, streams, invite_as)
	  File "/home/zulipdev/zulip/zerver/lib/actions.py", line 5153, in do_invite_users
		email_error, email_skipped, deactivated = validate_email(user_profile, email)
	  File "/home/zulipdev/zulip/zerver/lib/actions.py", line 5069, in validate_email
		return None, (error.code), (error.params['deactivated'])
	TypeError: 'NoneType' object is not subscriptable

Obviously, you shouldn't try to invite a cross
realm bot to your realm, but we want a reasonable
error message.

RESOLUTION:

Populate the `code` parameter for `ValidationError`.

BACKGROUND:

Most callers to `validate_email_for_realm` simply catch
the `ValidationError` and then report a more generic error.

That's also what `do_invite_users` does, but it has the
somewhat convoluted codepath through `validate_email`
that triggers this code:

    try:
        validate_email_for_realm(user_profile.realm, email)
    except ValidationError as error:
        return None, (error.code), (error.params['deactivated'])

The way that we're using the `code` parameter for
`ValidationError` feels hacky to me.  The intention
behind `code` is to provide a descriptive error to
calling code, and it's not intended for humans, and
it feels strange that we actually translate this in
other places.  Here are the Django docs:

    https://docs.djangoproject.com/en/3.0/ref/forms/validation/

And then here's an example of us actually translating
a code (not part of this commit, just providing context):

    raise ValidationError(_('%s already has an account') %
                          (email,), code = _("Already has an account."),
                          params={'deactivated': False})

Those codes eventually get put into InvitationError, which
inherits from JsonableError, and we do actually display
these errors in the webapp:

    if skipped and len(skipped) == len(invitee_emails):
        # All e-mails were skipped, so we didn't actually invite anyone.
        raise InvitationError(_("We weren't able to invite anyone."),
                              skipped, sent_invitations=False)

I will try to untangle this somewhat in upcoming commits.
2020-03-06 11:53:22 -08:00
.circleci circleci: Store XUnit test results. 2019-07-07 22:31:11 -07:00
.github
.tx cleanup: Delete trailing newlines. 2019-08-06 23:29:11 -07:00
analytics analytics: Fix missing unique constraint when subgroup is null. 2020-03-06 11:10:04 -08:00
confirmation confirmation: Set confirmation object realm attribute in realm reactivation. 2019-10-21 16:52:46 -07:00
corporate corporate: Allow customer to go through /upgrade/ if their plan ended. 2020-02-13 17:40:04 -08:00
docs docs: Update a few GSoC project ideas. 2020-03-04 16:48:58 -08:00
frontend_tests i18n: Rename translations.js to i18n.js. 2020-02-29 12:19:51 -08:00
locale i18n: Update translation data from transifex. 2019-12-12 20:34:46 -08:00
pgroonga python: Sort migrations/management command imports with isort. 2020-01-14 13:07:47 -08:00
puppet setup_path_on_import: Replace with setup_path function. 2020-02-25 15:40:21 -08:00
requirements dependencies: Upgrade to Django 2.2.10. 2020-02-13 16:27:26 -08:00
scripts setup_path_on_import: Replace with setup_path function. 2020-02-25 15:40:21 -08:00
static protico: Fix alignment, appearance and link for Current plan button. 2020-03-05 14:07:34 -08:00
stubs mypy: Remove daemon mode. 2019-08-25 15:04:12 -07:00
templates docs: Recommend user_id instead of email in typing javascript example. 2020-03-06 11:39:43 -08:00
tools node tests: Actually test `translations.js`. 2020-02-29 12:19:51 -08:00
zerver invites: Fix bug with inviting cross realm bots. 2020-03-06 11:53:22 -08:00
zilencer presence: Add realm_id to UserPresence. 2020-02-10 17:21:45 -08:00
zproject auth: Monkey patch a fix for Github deprecation notice spam. 2020-03-03 15:51:40 -08:00
zthumbor zthumbor: Clean up type ignores. 2019-08-09 17:42:33 -07:00
.browserslistrc webpack: Transpile JS code with Babel. 2019-07-22 17:55:32 -07:00
.codecov.yml codecov: Change threshold to use percentage syntax. 2019-07-20 14:37:04 -07:00
.editorconfig editorconfig: Set JS max_line_length = 100, to match eslintrc. 2019-10-14 17:32:38 -07:00
.eslintignore blueslip: Apply ESLint. 2019-11-01 12:13:59 -07:00
.eslintrc.json dict: Replace with Map. 2020-02-25 15:37:37 -08:00
.gitattributes
.gitignore i18n: Move static/locale back to locale. 2019-07-02 14:57:55 -07:00
.gitlint
.isort.cfg
.npmignore
.stylelintrc
.travis.yml ci: Move backend and production tests to Ubuntu 16.04 (xenial). 2019-05-24 17:07:15 -07:00
.yarnrc .yarnrc: Set ignore-scripts true. 2019-08-28 16:15:54 -07:00
CODE_OF_CONDUCT.md
CONTRIBUTING.md docs: Change our security contact to security@. 2020-02-26 16:35:29 -08:00
Dockerfile-postgresql base Zulip PostgreSQL Docker container on PGroonga official one 2019-12-30 10:20:25 -08:00
LICENSE
NOTICE
README.md docs: Update discussion of outreach programs. 2020-02-25 11:47:09 -08:00
Vagrantfile Revert "vagrant: Add NFS backend for file synchronization for OSX." 2019-08-12 16:04:00 -07:00
babel.config.js babel: Enable loose mode. 2020-02-05 11:52:52 -08:00
manage.py setup_path_on_import: Replace with setup_path function. 2020-02-25 15:40:21 -08:00
mypy.ini tornado: Rewrite Django integration to duplicate less code. 2020-02-13 16:13:11 -08:00
package.json dependencies: Add source-map to top level devDependencies. 2020-02-19 14:39:26 -08:00
postcss.config.js webpack: Move CSS minification to optimization stage. 2019-09-02 21:58:13 -07:00
tsconfig.json tsconfig: Fix typescript-eslint memory usage disaster. 2019-11-22 11:38:25 -08:00
version.py emoji: Resolve emoji sprite sheets and stylesheets through Webpack. 2020-02-25 14:43:46 -08:00
yarn.lock upload: Replace jQuery filedrop with Uppy. 2020-02-13 16:43:19 -08:00

README.md

Zulip overview

Zulip is a powerful, open source group chat application that combines the immediacy of real-time chat with the productivity benefits of threaded conversations. Zulip is used by open source projects, Fortune 500 companies, large standards bodies, and others who need a real-time chat system that allows users to easily process hundreds or thousands of messages a day. With over 500 contributors merging over 500 commits a month, Zulip is also the largest and fastest growing open source group chat project.

CircleCI branch Coverage Status Mypy coverage GitHub release docs Zulip chat Twitter

Getting started

Click on the appropriate link below. If nothing seems to apply, join us on the Zulip community server and tell us what's up!

You might be interested in:

You may also be interested in reading our blog or following us on twitter. Zulip is distributed under the Apache 2.0 license.