zulip/zerver/views
Steve Howell 551fc7f165 bots: Prevent bots from having duplicate full names.
Bots are not allowed to use the same name as
other users in the realm (either bot or human).

This is kind of a big commit, but I wanted to
combine the post/patch (aka add/edit) checks
into one commit, since it's a change in policy
that affects both codepaths.

A lot of the noise is in tests.  We had good
coverage on the previous code, including some places
like event testing where we were expediently
not bothering to use different names for
different bots in some longer tests.  And then
of course I test some new scenarios that are relevant
with the new policy.

There are two new functions:

    check_bot_name_available:
        very simple Django query

    check_change_bot_full_name:
        this diverges from the 3-line
        check_change_full_name, where the latter
        is still used for the "humans" use case

And then we just call those in appropriate places.

Note that there is still a loophole here
where you can get two bots with the same
name if you reactivate a bot named Fred
that was inactive when the second bot named
Fred was created.  Also, we don't attempt
to fix historical data.  So this commit
shouldn't be considered any kind of lockdown,
it's just meant to help people from
inadvertently creating two bots of the same
name where they don't intend to.  For more
context, we are continuing to allow two
human users in the same realm to have the
same full name, and our code should generally
be tolerant of that possibility.  (A good
example is our new mention syntax, which disambiguates
same-named people using ids.)

It's also worth noting that our web app client
doesn't try to scrub full_name from its payload in
situations where the user has actually only modified other
fields in the "Edit bot" UI.  Starting here
we just handle this on the server, since it's
easy to fix there, and even if we fixed it in the web
app, there's no guarantee that other clients won't be
just as brute force.  It wasn't exactly broken before,
but we'd needlessly write rows to audit tables.

Fixes #10509
2018-10-24 16:59:57 -07:00
..
__init__.py views: Rename __init__.py to zerver.views.registration. 2017-01-08 16:21:15 -08:00
alert_words.py alert words: Return the updated list when adding/removing words. 2018-07-13 01:01:00 +05:30
archive.py archives: Add endpoint to fetch topic history of web public streams. 2018-07-14 09:51:37 +05:30
attachments.py attachments: Send events for attachment updates. 2018-05-04 16:22:27 -07:00
auth.py python: Avoid importing the mock module in production. 2018-10-17 15:28:48 -07:00
compatibility.py views: Change use of typing.Text to str. 2018-04-23 18:51:23 -07:00
custom_profile_fields.py events: Convert custom user field value to json object on update event. 2018-08-22 22:45:08 -07:00
email_log.py email_log: Only import Django test client when using it. 2018-08-08 14:19:42 -07:00
email_mirror.py mypy: Use Python 3 type syntax in zerver/views/email_mirror.py. 2017-12-28 07:26:44 -05:00
events_register.py views: Change use of typing.Text to str. 2018-04-23 18:51:23 -07:00
home.py portico: Redirect /plans to zulipchat.com/plans for self-hosted realms. 2018-10-23 14:47:00 -07:00
hotspots.py views: Fix imports of REQ/has_request_variables from the wrong place. 2017-10-27 15:07:31 -07:00
integrations.py templates: Merge Help and API doc main into documentation_main. 2018-08-27 20:19:24 -02:30
invite.py invite: Make inviting new users inaccessible for guest users. 2018-06-16 06:33:13 -07:00
messages.py narrow: Handle spurious emails in pm-with searches. 2018-10-12 10:18:30 -07:00
muting.py muting: Correct agrammatical error message. 2018-08-27 14:12:03 -07:00
pointer.py do_update_pointer: Pass client object from callers. 2018-08-01 16:40:15 -07:00
presence.py presence: Allow bots to fetch realm presence data. 2018-10-15 12:51:28 -07:00
push_notifications.py views: Change use of typing.Text to str. 2018-04-23 18:51:23 -07:00
reactions.py reactions: Allow using emoji_name for removing reactions. 2018-07-11 19:41:43 +05:30
realm.py models: Rename Realm.restricted_to_domain field. 2018-07-31 09:28:33 -07:00
realm_domains.py views: Change use of typing.Text to str. 2018-04-23 18:51:23 -07:00
realm_emoji.py emoji: Show emoji names with spaces on front-end. 2018-08-04 09:40:52 -07:00
realm_filters.py views: Change use of typing.Text to str. 2018-04-23 18:51:23 -07:00
realm_icon.py zerver/views: Use python 3 syntax for typing. 2017-10-26 21:58:22 -07:00
registration.py urls: Separate endpoint for signup and new realm email confirm. 2018-08-26 22:53:57 -07:00
report.py mypy: Set local_partial_types = True. 2018-05-21 22:41:00 -07:00
storage.py mypy: Migrate views/storage.py to python3.5 type annotations. 2018-03-12 11:23:30 -07:00
streams.py i18n: Fix hard-to-translate notification bot string. 2018-08-09 08:37:23 -07:00
submessage.py submessages: Just send content for submessage events. 2018-05-30 13:53:11 -07:00
thumbnail.py thumbnails: Change thumbnail size to be 300px. 2018-10-11 15:44:47 -07:00
tutorial.py mypy: Use Python 3 syntax for typing in views/tutorial.py. 2017-12-08 18:34:26 -08:00
typing.py views: Change use of typing.Text to str. 2018-04-23 18:51:23 -07:00
unsubscribe.py requirements: Upgrade pyflakes to 2.0.0. 2018-05-24 11:31:36 -07:00
upload.py upload: Remove unnecessary use of has_request_variables. 2018-07-01 01:47:03 -07:00
user_groups.py api: Add an endpoint for listing the user groups in realm. 2018-08-27 16:56:23 -07:00
user_settings.py user_settings: Compare new stripped email with old email. 2018-10-11 15:55:32 -07:00
users.py bots: Prevent bots from having duplicate full names. 2018-10-24 16:59:57 -07:00
zephyr.py users: Get all API keys via wrapper method. 2018-08-08 16:35:17 -07:00