Commit Graph

7965 Commits

Author SHA1 Message Date
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
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
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
6a61a8a431 outgoing webhooks: Consolidate interfaces into lib/outgoing_webhook.py 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
ff63f0b1d3 Return response string instead of dict() from process_success, process_failure. 2017-07-24 14:10:14 -07:00
James Rowan
bba90c5096 emails: Make missed message email come from 'Zulip Missed Messages.' 2017-07-21 14:24:03 -07:00
Jack Zhang
e915321f89 registration: Remove organization type selection in realm creation. 2017-07-21 13:09:06 -07:00
Eeshan Garg
6fe3748826 decorator: Remove redundant tests for api_key_only_webhook_view.
We do not need to test the exception message being logged in every
test case where an exception is raised by a webhook function.
Testing it once should be enough; this makes the tests less
verbose.
2017-07-20 10:30:03 -07:00
Rishi Gupta
9782911aca portico: Add initial why zulip page. 2017-07-19 11:53:06 -07:00
Eeshan Garg
a24ea56c53 decorator: Handle invalid JSON in api_key_only_webhook_view.
Exception logging within api_key_only_webhook_view fails when
ValueError is raised if the request.body passed to ujson.loads
isn't valid JSON. In this case, we now just convert the payload
to a string and log that. This allows us to inspect JSON payloads
that aren't being decoded properly.
2017-07-19 10:42:35 -07:00
Sarah
eef9f15910 test_settings: Refactor to use UserProfile property_types framework. 2017-07-18 15:49:20 -07:00
Rishi Gupta
394f85eb76 confirmation: Change confirmation keys to have length 24. 2017-07-17 23:18:47 -07:00
Rishi Gupta
5d168c90f9 confirmation: Remove ConfirmationManager.
Also adds Confirmation.type, and cleans up the rest of Confirmation to look
more like the model definitions in zerver.

In the migration, all existing confirmations adopt the type
USER_REGISTRATION, to be conservative. In a few commits, different
confirmation types will have different validity periods, and
USER_REGISTRATION will have the shortest default.
2017-07-17 23:18:47 -07:00
Rishi Gupta
0f4b71b766 confirmation: Liberate get_link_for_object from ConfirmationManager. 2017-07-17 23:18:47 -07:00
Aditya Bansal
f2d6194ae1 actions: Start logging subscription activities in RealmAuditLog. 2017-07-17 17:23:41 -07:00
Brock Whittaker
38440d6ba4 Change product page nav and hero styling. 2017-07-17 16:12:36 -07:00
Rishi Gupta
ea8c1c3cad emails: Use ScheduledEmail.user in send_future_email. 2017-07-17 16:05:38 -07:00
Rishi Gupta
aa845e7f60 models: Replace ScheduledJob with ScheduledEmail.
ScheduledJob was written for much more generality than it ended up being
used for. Currently it is used by send_future_email, and nothing
else. Tailoring the model to emails in particular will make it easier to do
things like selectively clear emails when people unsubscribe from particular
email types, or seamlessly handle using the same email on multiple realms.
2017-07-17 16:05:38 -07:00
Vishnu Ks
f9245e26d9 Make user_id, realm_id mandatory in _get_unversioned_avatar_url. 2017-07-17 21:01:30 +00:00
Rishi Gupta
898269bbac email: Change send_email to raise exception on failure.
More in line with how we do error handling in the rest of Zulip.
2017-07-16 16:56:39 -07:00
Rishi Gupta
f1aaf4cc33 emails: Remove the display_email function.
No longer needed, since this now only appears in build_email.
2017-07-16 16:56:39 -07:00
Rishi Gupta
eacdb0b302 emails: Change welcome emails to use to_user_id. 2017-07-16 16:56:39 -07:00
Rishi Gupta
b0d325b8c5 emails: Change send_future_email to accept a to_user_id.
Also changes digest emails to use a to_user_id instead of a to_email.
2017-07-16 16:56:39 -07:00
neiljp (Neil Pilgrim)
8611a2cafa tidying: Combine multiple 'import typing' lines onto one line. 2017-07-16 16:43:21 -07:00
Harshit Bansal
45bc220796 notifications: Fix relative stream links in missed message emails.
Fixes: #5310.
2017-07-16 20:51:08 +00:00
Durga Akhil Mundroy
146dfa6f0b org-permissions: Add allow_edit_history organiztion setting.
This new setting controls whether or not users are allowed to see the
edit history in a Zulip organization.  It controls access through 2
key mechanisms:

* For long-ago edited messages, get_messages removes the edit history
  content from messages it sends to clients.

* For newly edited messages, clients are responsible for checking the
  setting and not saving the edit history data.  Since the webapp was
  the only client displaying it before this change, this just required
  some changes in message_events.js.

Significantly modified by tabbott to fix some logic bugs and add a
test.
2017-07-16 10:10:06 -07:00
James Rowan
21b5536353 emails: Update subject lines of emails. 2017-07-14 15:20:04 -07:00
Vaida Plankyte
28ea174ed9 backend: Implement high contrast mode display setting. 2017-07-14 14:53:24 -07:00
Steve Howell
475eb21a5e Revert commits related to client_message_id.
I pushed a bunch of commits that attempted to introduce
the concept of `client_message_id` into our server, as
part of cleaning up our codepaths related to messages you
sent (both for the locally echoed case and for the host
case).

When we deployed this, we had some strange failures involving
double-echoed messages and issues advancing the pointer that appeared
related to #5779.  We didn't get to the bottom of exactly why the PR
caused havoc, but I decided there was a cleaner approach, anyway.
2017-07-14 12:13:35 -07:00
Steve Howell
8fbb55df85 Introduce client_message_id on the server.
We are deprecating local_id/local_message_id on the Python server.
Instead of the server knowing about the client's implementation of
local id, with the message id = 9999.01 scheme, we just send the
server an opaque id to send back to us.

This commit changes the name from local_id -> client_message_id,
but it doesn't change the actual values passed yet.

The goal for client_key in future commits will be to:
    * Have it for all messages, not just locally rendered messages
    * Not have it overlap with server-side message ids.

The history behind local_id having numbers like 9999.01 is that
they are actually interim message ids and the numerical value is
used for rendering the message list when we do client-side rendering.
2017-07-13 23:42:27 -04:00
Jack Zhang
6e2f90c8c9 Improve /integrations page load time.
Prior to this commit, 7 megabytes of images (through 253 individual requests)
were heavily slowing down the initial load. With this commit, we load only the
logos (60 or so images).

Documentation and images for the individual integration sub-pages is requested
separately using the /integrations/doc/ endpoint, which returns HTML.
2017-07-13 20:37:09 -07:00
James Rowan
71bc40d829 emails: Update subject for invitation emails. 2017-07-13 18:47:21 -07:00
James Rowan
88b8d98d34 emails: Update subject for missed message emails. 2017-07-13 18:47:17 -07:00
James Rowan
92c2d93ea3 tests: Enforce new custom sender names and addresses. 2017-07-13 14:50:36 -07:00
Vishnu Ks
098569ccb4 test_classes: Use get_user in unsubscribe_from_stream. 2017-07-13 14:13:03 -07:00
Vishnu Ks
99e78cbead test_classes: Use get_user in get_streams function. 2017-07-13 14:13:03 -07:00
Vishnu Ks
466c3f92f9 test_subs: Replace iago@zulip.com with self.example_email('iago'). 2017-07-13 14:13:03 -07:00
Sarah
db3539438c test_events: Simplify testing code for bool user settings.
Use bool_change if the user_display setting property_type is bool, so that no additional code needs to be added to test_events for new boolean user display settings.
2017-07-13 14:07:54 -07:00
Cory Lynch
8afdb06e2a search: Add test case for searching for a link.
Fixes #2038
2017-07-13 09:23:34 -07:00
Tim Abbott
6a914c83ef docs: Fix indentation of DocPageTest. 2017-07-12 16:28:38 -07:00
Aditya Bansal
6100d43339 test_subs/test_users: Fix breaking tests due to regressions. 2017-07-13 01:56:26 +05:30
Tim Abbott
5acc7506ac test_users: Fix GetProfileTest to test its original purpose.
This test accidentally got refactored to use some test suite library
functions that ended up somewhat defeating its purpose.
2017-07-12 13:03:38 -07:00
Vishnu Ks
63586480a5 test_subs: Replace hamlet@zulip.com with self.example_email('hamlet'). 2017-07-12 12:49:12 -07:00
Vishnu Ks
6e133cc77a test_subs: Eliminate redundant class variable realm.
The SubscriptionAPITest class variables `realm` and `test_realm` stores
the same information and are redundant. I have eliminated all occurances
of self.realm and replaced with self.test_realm.
2017-07-13 00:45:24 +05:30
Vishnu Ks
ed0423784d test_realm_emoji: Replace get_user_profile_by_email.
Replace with get_user.
2017-07-13 00:45:24 +05:30