Commit Graph

19591 Commits

Author SHA1 Message Date
Greg Price 0d2f7e8bcd errors: Eliminate redundant `json_response_to_error` calls. 2017-07-25 15:33:11 -07:00
Greg Price 360c27dedd tests: Bring all the top-level test scripts into alignment on what to test.
Notably, this adds our checks on translated message strings to
`tools/test-all`, so that they don't cause surprise failures in
CI after a branch is pushed.  (Alternately they could have gone
in `tools/lint` to accomplish the same goal, but `makemessages`
which they depend on is quite slow -- on my machine it takes 7s,
compared to 10s for all of `tools/lint`.)
2017-07-25 15:31:32 -07:00
Greg Price cd7cd73538 tests: Reorder tests in top-level test scripts to agree with each other.
This will make it easier to get the scripts to contain the same set of
tests (with explicit, conscious exceptions), and to keep it that way.
2017-07-25 15:31:32 -07:00
Greg Price 192ec7c0f6 middleware: Use a proper error code on CSRF failure.
This allows us to reliably parse the error in code, rather than
attempt to parse the error text.  Because the error text gets
translated into the user's language, this error-handling path
wasn't functioning at all for users using Zulip in any of the
seven non-English languages for which we had a translation for
this string.

Together with 709c3b50f which fixed a similar issue in a
different error-handling path, this fixes #5598.
2017-07-25 14:02:12 -07:00
Vaida Plankyte 388acbbfcb frontend: Remove old required div & css from registration pages.
Removes class="required" divs that used to contain an asterisk
for valid/invalid input, and their associated css.
2017-07-25 13:39:34 -07:00
Robert Hönig 500ec48215 testing: Properly exclude files for linting in Windows.
For files to be excluded in Windows, their paths have to
be normalized, so that the string matching works.
2017-07-25 11:30:58 -07:00
Cynthia Lin 89abe5d398 user docs: Document Analytics feature.
Fixes #3648.
2017-07-25 11:18:44 -07:00
Cynthia Lin 83993aa388 docs: Update user docs guide with new sidebar index. 2017-07-24 22:59:55 -07:00
Sarah 31e47954f7 settings_org: Change update_realm_description to read from page_params.
Also refactor server_events_dispatch, move update_realm_description
into the realm_settings object.

Fixes #5696.
2017-07-24 17:36:50 -07:00
Sarah f132652717 server_events_dispatch: Deduplicate realm and user_display settings code.
Deduplicate code updating page_params for realm settings
and user display settings.

Addresses issue #5696.
2017-07-24 17:35:41 -07:00
Rishi Gupta ad47d3b651 settings: Update wording in organization-permissions-admin.handlebars. 2017-07-24 17:33:14 -07:00
Rishi Gupta f91098143b settings: Reorder options in organization-permissions-admin.handlebars.
Also adds <hr>'s to separate the options into sections.
2017-07-24 17:33:14 -07:00
Rishi Gupta ace67c6669 settings: Remove tooltip for user settings -> full name.
It's hinted in the registation process, and as long as one person in the
realm does it, everyone else will know. The tooltip also draws too much
visual attention.
2017-07-24 17:33:14 -07:00
Rishi Gupta 481c85fb48 settings: Update text in templates. 2017-07-24 17:33:14 -07:00
Harshit Bansal a03ce01688 bugdown: Fix the rendering of emojis in twitter link previews.
Process the unicode emojis in twitter link previews and render them
properly. Before this we were not processing the unicode emojis in
twitter link previews and hence on the systems which don't have
fonts for displaying them they were rendered as blank boxes.

Fixes: #5427.
2017-07-24 17:32:05 -07:00
Harshit Bansal 9256ff0f7d bugdown: Rename `to_linkify` to `to_process` and add `type` field.
This commit renames list named `to_linkify` in twitter link processor
to `to_process` and adds a `type` field to each entry in it to
indicate the type of data represented by that particular entry.
2017-07-24 17:31:56 -07:00
Harshit Bansal f7f4d1ca58 markdown: Fix the broken rendering of tables.
It was a regression introduced in the commit
`0d08acaa1b5713be464dfca4836e5b238f45621c`.
2017-07-24 17:31:08 -07:00
Harshit Bansal 127d1f995d test_bugdown.py: Add test for `url_to_a()`. 2017-07-24 17:31:08 -07:00
Harshit Bansal f2c04576bd models: Fix the URL validation code in `RealmFilter` model. 2017-07-24 17:31:08 -07:00
Shubham Gupta 205d0993ef docs: Updated troubleshooting guide for ssh connection errors.
Tweaked by tabbott to simplify the language a bit.

Fixes #5889.
2017-07-24 17:26:19 -07:00
Abhijeet Kaur 6f60c65a65 embedded bots: Add tests for verification of embedded bot services.
Add test to check if the embedded bot service being used is in the
registry or not.
Add test to check if the bot being added to the registry has a valid
bot corresponding to it.
Move 'get_bot_handler' to 'zerver/lib/bot_lib.py' as it is an independent
function, not related to the 'EmbeddedBotWorker' class that it was
previously a part of.
2017-07-24 17:14:14 -07:00
Abhijeet Kaur c13d466f68 embedded bots: Add registry class and list for embedded bots service. 2017-07-24 17:14:14 -07:00
Greg Price 709c3b50fc tornado: Use a machine-readable error code when an event queue is gone.
This fixes the original issue that #5598 was the root cause of; when
the user returns to a Zulip browser tab after they've been idle past
the timeout (10 min, per IDLE_EVENT_QUEUE_TIMEOUT_SECS), we now
correctly reload the page even if they're using Zulip in German or
another non-English language where we have a translation for the
relevant error message.
2017-07-24 16:41:22 -07:00
Greg Price 45b718a2a2 tornado: Use the new structured JsonableError API for /json/events errors. 2017-07-24 16:41:22 -07:00
Greg Price 124d623d05 tornado/socket: Replace an ad-hoc error class with JsonableError.
The one purpose this exception was serving was to carry a message
in `msg`.  We can do that with `JsonableError`, and as a bonus replace
a repetition of the familiar "'result': 'error', ..." JSON pattern
with a call to a common implementation.

Also wrap the error messages for translation -- we hadn't been doing
that, oops.  Our linter notices that issue now that it's the familiar
JsonableError class.

There's one other potential change in behavior here: this
except-clause might now catch a JsonableError raised from some other
code.  That seems like a bonus, if so; the handler isn't doing
anything actually specific to this code, and the more exceptions it
successfully turns into proper error responses to the client and lines
in the log, the better.
2017-07-24 16:41:22 -07:00
Greg Price 5de7c4f2af JsonErrorHandler: Take advantage of the new JsonableError structured data. 2017-07-24 16:41:22 -07:00
Greg Price 37dbcefa58 upload: Use the new ErrorCode system in our custom error classes.
All JsonableError subclasses now have corresponding ErrorCode values
of their own, reducing the number of different patterns for using
the new JsonableError API.
2017-07-24 16:41:22 -07:00
Greg Price 9faa44af60 JsonableError: Optionally carry error codes and structured data.
This provides the main infrastructure for fixing #5598.  From here,
it's a matter of on the one hand upgrading exception handlers -- the
many except-blocks in the codebase that look for JsonableError -- to
look beyond the string `msg` and pass on the machine-readable full
error information to their various downstream recipients, and on the
other hand adjusting places where we raise errors to take advantage
of this mechanism to give the errors structured details.

In an ideal future, I think all exception handlers that look (or
should look) for a JsonableError would use its contents in structured
form, never mentioning `msg`; but the majority of error sites might
continue to just instantiate JsonableError with a string message.  The
latter is the simplest thing to do, and probably most error types will
never have code looking for them specifically.

Because the new API refactors the `to_json_error_msg` method which was
designed for subclasses to override, update the 4 subclasses that did
so to take full advantage of the new API instead.
2017-07-24 16:41:22 -07:00
Greg Price 4837d4178d JsonableError: Make `http_status_code` a class attribute only.
This simplifies things for all codepaths not involving this feature.

Using this feature becomes slightly easier when you're already
defining a subclass, but now requires you to define a subclass.
Currently we use it just once out of >100 uses of JsonableError, and
that use already has a subclass, so this seems like a win.
2017-07-24 16:41:22 -07:00
Greg Price 7cd621bc9d webhooks/updown: Fix a JsonableError to provide a real error message. 2017-07-24 16:41:22 -07:00
Greg Price 6dfb46dc08 JsonableError: Rename `status_code` and rely more on its default.
With #5598 there will soon be an application-level error code
optionally associated with a `JsonableError`, so rename this
field to make clear that it specifically refers to an
HTTP status code.

Also take this opportunity to eliminate most of the places
that refer to it, which only do so to repeat the default value.
2017-07-24 16:41:22 -07:00
Greg Price 098b6fc53b JsonableError: Move into a normally-typed file.
The file `zerver/lib/request.py` doesn't have type annotations
of its own; if they did, they would duplicate the annotations that
exist in its stub file `zerver/lib/request.pyi`.  The latter exists
so that we can provide types for the highly dynamic `REQ` and
`has_request_variables`, which are beyond the type-checker's ken
to type-check, but we should minimize the scope of code that gets
that kind of treatment and `JsonableError` is not at all the sort of
code that needs it.

So move the definition of `JsonableError` into a file that does
get type-checked.

In doing so, the type-checker points out one issue already:
`__str__` should return a `str`, but we had it returning a `Text`,
which on Python 2 is not the same thing.  Indeed, because the
message we pass to the `JsonableError` constructor is generally
translated, it may well be a Unicode string stuffed full of
non-ASCII characters.  This is potentially a bit of a landmine.
But (a) it can only possibly matter in Python 2 which we intend to
be off before long, and (b) AFAIK it hasn't been biting us in
practice, so we've probably reasonably well worked around it where
it could matter.  Leave it as is.
2017-07-24 16:41:22 -07:00
Greg Price a5597e91a1 exceptions: Move zerver/exceptions.py under zerver/lib/.
Seems like a more appropriate place for it.  Preparation for
moving a bit more into that file.
2017-07-24 16:41:22 -07:00
Greg Price e18baff32c JsonableError: Rename message from `error` to `msg`.
The whole thing is an error, so "message" is a more apt word for the
error message specifically.  We abbreviate that as `msg` in the actual
HTTP responses and in the signatures of `json_error` and friends, so
do the same here.
2017-07-24 16:41:22 -07:00
Greg Price ff5013c619 JsonableError: Add types, and eliminate duck-typing.
In order to benefit from the modern conveniences of type-checking,
add concrete, non-Any types to the interface for JsonableError.

Relatedly, there's no need at this point to duck-type things at
the places where we receive a JsonableError and try to use it.
Simplify those by using straightforward standard typing.
2017-07-24 16:41:22 -07:00
Elliott Jin fcb889c5c0 outgoing webhooks: Remove process_failure interface method. 2017-07-24 14:10:14 -07:00
Elliott Jin fdc9294a6e outgoing webhooks: Don't call *_with_message if message is None. 2017-07-24 14:10:14 -07:00
Elliott Jin 3d815bcea9 outgoing webhooks: Return None instead of "" in process_success. 2017-07-24 14:10:14 -07:00
Elliott Jin a7713840d4 outgoing webhooks: Remove underscore from test class names. 2017-07-24 14:10:14 -07:00
Elliott Jin b53be0accc outgoing webhooks: Clean up interface comments. 2017-07-24 14:10:14 -07:00
Elliott Jin 6a61a8a431 outgoing webhooks: Consolidate interfaces into lib/outgoing_webhook.py 2017-07-24 14:10:14 -07:00
Elliott Jin e9e1842113 outgoing webhooks: Remove unused __init__ methods. 2017-07-24 14:10:14 -07:00
vaibhav 4c50c4fc76 Add outgoing webhook interface for Slack. 2017-07-24 14:10:14 -07:00
vaibhav e5be29bc3c Add tests for Generic Interface. 2017-07-24 14:10:14 -07:00
vaibhav d0ad91093f Add support to omit the response message in generic interface. 2017-07-24 14:10:14 -07:00
vaibhav d82373b76b Fix Service model and related helper function. 2017-07-24 14:10:14 -07:00
vaibhav 87dcd5442a outgoing webhook system: Minor fixes.
This fixes some error message strings and skips converting request_data
into json. From now, conversion would be the responsibility of interface.
Also, base_url is now not passed into event structure.
2017-07-24 14:10:14 -07:00
vaibhav ff63f0b1d3 Return response string instead of dict() from process_success, process_failure. 2017-07-24 14:10:14 -07:00
Tim Abbott 40c25e41f1 version: Update PROVISION_VERSION for jQuery upgrade. 2017-07-24 11:31:28 -07:00
Cory Lynch a01eb190d6 Update to jQuery version 3.
Fixes #5483.
2017-07-24 10:54:47 -07:00