Commit Graph

5681 Commits

Author SHA1 Message Date
Preston Hansen e8a608f733 management: Move enqueue_digest_email handler to digest. 2017-08-27 10:13:11 -07:00
Preston Hansen 9a4b17cf9b management: Move queue_digest_recipient to digest. 2017-08-27 10:13:11 -07:00
Preston Hansen 2aabf4fc67 management: Move should_process_digest to digest. 2017-08-27 10:13:11 -07:00
Preston Hansen 25a40806df management: Move inactive_since to digest. 2017-08-27 10:13:11 -07:00
Tim Abbott f1648af607 migrations: Update UserMessage model for is_me_message removal.
And while we're at it, document the related migration we need to do.
2017-08-27 10:11:43 -07:00
Tim Abbott 1c8c5cc36f test_messages: Fix deactivation tests for new /me behavior. 2017-08-27 09:58:02 -07:00
Tim Abbott 133f005530 markdown: Remove is_me_message UserMessage flags.
This never made sense to be a flag on the UserMessage table, since
it's not per-user state.  And in fact it doesn't need to be in a
database at all, since it's easily computed from content anyway.

Fixes #1099.
2017-08-27 09:34:24 -07:00
Tim Abbott e5da9966c2 bugdown: Remove now-unnecessary short_names.
This field hasn't been used since we removed the related mention
syntax.
2017-08-27 08:45:02 -07:00
Tim Abbott 92efe94a27 tests: Remove unnecessary apns mock. 2017-08-26 15:00:08 -07:00
Tim Abbott f0637cb01a push_notifications: Fix one last lint error. 2017-08-26 14:34:17 -07:00
Tim Abbott 00036ac8db push_notifications: Fix mypy error. 2017-08-26 14:33:43 -07:00
Rishi Gupta 1215757217 send_email: Remove confusing comment. 2017-08-26 14:24:32 -07:00
Rishi Gupta 1a43ef40cf emails: Add email_images_base_uri to context in build_email. 2017-08-26 14:24:32 -07:00
Greg Price 613d093d7d push notifs: Implement APNs with new API.
And it works!

A couple of things still to do:

 * When a device token is no longer active, we'll get HTTP status 410.
   We should then remove the token from the database so we don't keep
   trying to push to it.  This is fairly urgent.

 * The library we're using has a nice asynchronous API, but this
   version doesn't use it.  This is OK now, but async will be
   essential at scale.
2017-08-26 14:16:05 -07:00
Greg Price 35db1b2f11 push notifs: Organize imports. 2017-08-26 14:16:05 -07:00
Greg Price ba673526ab push notifs: Organize the code a bit.
This commit only reorders the code in the file, without touching the
insides of any function, and adds some heading comments.
2017-08-26 14:16:05 -07:00
Greg Price d02101a401 APNs: Rip out the existing, broken implementation.
This code empirically doesn't work.  It's not entirely clear why, even
having done quite a bit of debugging; partly because the code is quite
convoluted, and because it shows the symptoms of people making changes
over time without really understanding how it was supposed to work.

Moreover, this code targets an old version of the APNs provider API.
Apple deprecated that in 2015, in favor of a shiny new one which uses
HTTP/2 to meet the same needs for concurrency and scale that the old
one had to do a bunch of ad-hoc protocol design for.

So, rip this code out.  We'll build a pathway to the new API from
scratch; it's not that complicated.
2017-08-26 14:16:05 -07:00
Greg Price 3bceeec89f push notifs: Add logging on creating device tokens.
We'd been getting errors from APNs that appeared to say that the
device tokens we were trying to send to were invalid.  It turned out
that the device tokens didn't match the "topic" (i.e. app ID) we were
sending, which was because the topic was wrong, which was because we
were using the wrong SSL cert.  But for a while we thought it might be
that we were somehow messing up the device tokens we put into the
database.  This logging helped us work out that wasn't the issue, and
would have helped our debugging sooner.
2017-08-26 14:16:05 -07:00
Aditya Bansal f0c4f4d4bc soft-deactivation: Stop creating flag list for soft-deactivated users. 2017-08-26 13:48:16 -07:00
Tim Abbott 27101ae931 trello: Use client_head wrapper in tests. 2017-08-26 13:45:27 -07:00
Tim Abbott f51f89a86e test_upload: Explicitly declare subdomains. 2017-08-26 13:45:27 -07:00
Tim Abbott d18f389bb5 test_messages: Set subdomain explicitly in most tests. 2017-08-26 13:45:27 -07:00
Tim Abbott f48bad2734 test_signup: Remove now-unnecessary mocking of subdomain. 2017-08-26 13:45:27 -07:00
Tim Abbott 9c85ccf70f test_signup: Use HostRequestMock.
PostRequestMock is less useful and going to break soon.
2017-08-26 13:45:27 -07:00
rht e2e56a3e71 test_subs: Fix dict unpacking. 2017-08-26 09:01:10 -07:00
rht 437b2a3146 Update "MacOS" text to "macOS" 2017-08-26 09:00:42 -07:00
Greg Price c4915aaff9 feedback: Add type on Redis-fetched data.
This brings type-checking to the last place we fetch
data from Redis, with the exception of our APNs code
which is being replaced (with a Redis-free version,
thanks to improvements in Apple's APNs API) shortly.
2017-08-25 16:14:33 -07:00
Greg Price 5ba4b1bd4f rate_limiter: Add types on Redis-fetched data.
This gives us type-checking, to help prevent bugs like the
last couple of commits fixed in our Tornado code and our
missed-message email handling.  Fortunately no behavior
changes are needed here.
2017-08-25 16:14:33 -07:00
Greg Price b63e995e82 tornado: Fix a Redis-caused str/bytes bug in `status_inquiries`.
Because the Redis client returns exclusively bytes -- even for
hash keys -- even on Python 3, the test `'response' in status`
was always returning false, and the line that tries to decode
as JSON was never running, so we were passing `response`
through as a `bytes` object encoding some JSON.

I'm not sure what the impact of this bug was, and in particular
whether something downstream would have fudged it to make up for
this error.
2017-08-25 16:14:33 -07:00
Greg Price dfbd80f302 email_mirror: Convert subjects back to str from Redis's bytes.
Redis and the Redis client know nothing but bytes.  When we take a
`bytes` object it returns and pass it down as `subject` here, it
causes an exception deep inside message processing if the realm has
any filters, when `bugdown.subject_links` attempts to search the
subject for the filters, which are of course `str` patterns.

For symmetry, make the conversion to bytes on the storing side
explicit too.
2017-08-25 16:14:33 -07:00
Tim Abbott 20c0d27317 test_narrow: Specify subdomains explicitly. 2017-08-25 16:09:52 -07:00
Tim Abbott edc095db6d test_subs: Explicitly declare subdomains. 2017-08-25 16:09:51 -07:00
Tim Abbott 6caca80ab7 test_presence: Specify subdomains for Zephyr tests. 2017-08-25 16:08:37 -07:00
Tim Abbott 7a5eb9dd9f tornado: Add support for testing with subdomains. 2017-08-25 15:42:58 -07:00
Tim Abbott acdeaca2a8 test_zephyr: Explictly declare subdomain in requests. 2017-08-25 15:42:50 -07:00
Tim Abbott 43cfe73908 tests: Make requests use the "zulip" subdomain by default.
Previously, we didn't pass customized HTTP_HOST headers when making
network requests.  As we move towards a world where everything is on a
subdomain, we'll want to start doing that.

The vast majority of our test code is written to interact with the
default "zulip" realm, which has a subdomain of "zulip".  While
probably longer-term, we'll wish this was the root domain, for now, we
need to make our HTTP requests match what is expected by the test
code.

This commit almost certainly introduces some weird bugs where code was
expecting a different subdomain but the tests doesn't fail yet.  It's
not clear how to find all of these, but I've done some grepping.
2017-08-25 15:42:49 -07:00
Tim Abbott ba64d4ee29 server_settings: Add additional subdomains test case.
This will help preserve 100% test coverage as we refactor to set
REALMS_HAVE_SUBDOMAINS=True unconditonally.
2017-08-25 15:42:43 -07:00
Tim Abbott 64e895533b test_docs: Add tests for different subdomain states.
This helps maintain 100% test coverage on the new test_classes code.
2017-08-25 15:42:43 -07:00
Tim Abbott b0c8404622 tests: Add subdomain option to client_get and friends.
This should help make it easy to set the domain explicitly in tests
where that's important.
2017-08-25 15:42:42 -07:00
Tim Abbott 4b709de9c9 python3: Remove six.PY2/six.PY3 checks. 2017-08-25 11:06:43 -07:00
Tim Abbott 4229faf36e tests: Remove old six.PY2 code paths. 2017-08-25 11:05:16 -07:00
Tim Abbott b8e7369dee mypy: Remove type: ignores not needed in Python 3. 2017-08-25 11:04:20 -07:00
Tim Abbott 498c298c14 rate_limiter: Fix buggy use of NotImplementedError. 2017-08-25 09:53:09 -07:00
Tim Abbott bee86b6e6b send_email: Fix modification of mutable default value. 2017-08-25 09:43:53 -07:00
Tim Abbott 537ad1ff1b templatetags: Fix buggy exception clause. 2017-08-25 00:39:58 -07:00
Tim Abbott 1bb09e35d2 message: Add assertions for invalid recipient types. 2017-08-25 00:39:36 -07:00
Tim Abbott f3c73e4aa4 actions: Add assertion for invalid flag operations. 2017-08-25 00:34:56 -07:00
Tim Abbott 35f1bbb968 process_new_human_user: Simplify prereg_user logic.
We don't need the old code paths now that we don't have an MitUser
model anymore.
2017-08-25 00:34:06 -07:00
Umair Khan 9720d3a986 accounts_register: Use redirect_to_deactivation_notice. 2017-08-25 00:09:06 -07:00
Umair Khan 43c40f6144 Add tests for deactivation notice. 2017-08-25 00:09:06 -07:00
Umair Khan b473ff54ce Show realm deactivation notice for login/register.
Fixes #6247
2017-08-25 00:09:06 -07:00
Tim Abbott 50defd9b70 test_classes: Remove some unnecessary functions. 2017-08-24 23:33:12 -07:00
Tim Abbott 7d08ff69f0 tests: Remove most references to get_api_key.
This test helper doesn't really have value.
2017-08-24 23:30:46 -07:00
Tim Abbott e2ae096035 test_signup: Fix coverage of remaining find_my_team code. 2017-08-24 23:30:46 -07:00
Tim Abbott 59aae22f99 registration: Fix find_my_team handling of unusual users. 2017-08-24 23:17:08 -07:00
Tim Abbott ca7075a0a8 test_signup: Clean up find_my_team test suite. 2017-08-24 23:17:08 -07:00
Tim Abbott eeabed9119 models: Add new get_user_profile_by_api_key helper.
This results in a slight performance increase.
2017-08-24 23:17:08 -07:00
Tim Abbott 80caa5c66f socket: Use get_user_profile_by_id.
This should have a slight performance benefit.
2017-08-24 23:16:42 -07:00
Tim Abbott ffafa05bd5 decorator: Remove unnecesary import. 2017-08-24 23:16:31 -07:00
Tim Abbott 2aab6e0f49 forms: Replace is_inactive with more comprehensive check.
While we're at it, we clean up the old confusing error messages.
2017-08-24 23:16:31 -07:00
Tim Abbott b3dbba3ad4 actions: Extract validate_email_for_realm helper. 2017-08-24 23:16:31 -07:00
Tim Abbott c8f53e55db websocket_client: Use get_system_bot.
This messy code is used only for our websocket Nagios tests, so using
get_system_bot makes sense.
2017-08-24 23:16:18 -07:00
Tim Abbott e915fa058a test_classes: Stop using get_realm_by_email_domain.
get_realm_by_email_domain was intended to be registration flow code
not used in other code, but it was leaked to a few places.  This
removes one of the main remaining references to it outside the
registration code path.
2017-08-24 21:38:02 -07:00
Tim Abbott 95ed00bade tests: Remove now-unused subscribe_to_stream helper. 2017-08-24 21:38:02 -07:00
Tim Abbott 69059dcac8 tests: Clean up subscribing from webhook tests. 2017-08-24 21:37:57 -07:00
Tim Abbott 5fa7c3e0b2 test_classes: Clean up API for unsubscribing.
The old API required test authors to unnecessarily repeat themselves.
2017-08-24 21:37:57 -07:00
Tim Abbott eb720485c5 tests: Add and use new self.subscribe.
This new method cleans up the API for subscribing to something from a
test case.
2017-08-24 21:37:57 -07:00
Tim Abbott 60105fe38a registration: Remove accounts_home_with_realm_str.
This was the old mechanism for logging into a specific realm on a
server with more than one not using REALMS_HAVE_SUBDOMAINS.
2017-08-24 20:44:52 -07:00
Tim Abbott 522562f68f outgoing_webhook: Stop using get_realm_by_email_domain.
There was no reason to do a complicated lookup to get the realm here.
2017-08-24 20:27:00 -07:00
Tim Abbott 80458945c7 tests: Remove unnecessary use of get_realm_by_email_domain.
That function was primarily intended for some limited registration
code paths, not the generic usage it was getting.
2017-08-24 20:22:56 -07:00
Aditya Bansal 6a2c83f051 notifications: Group messages by (recipient, sender) for PM's.
This fixes a issue with multiple PM's being clubbed into a single
missed message email.

Fixes #6224.
2017-08-24 19:58:55 -07:00
Tim Abbott 0693656b89 register: Allow the empty string as a subdomain.
This is conditioned on the server being configured with
ROOT_DOMAIN_LANDING_PAGE=True.
2017-08-24 19:39:40 -07:00
Tim Abbott 3d4893d906 settings: Rename SUBDOMAINS_HOMEPAGE to ROOT_DOMAIN_LANDING_PAGE.
This new setting name is a lot more readable.
2017-08-24 19:32:16 -07:00
Tim Abbott ab61fe5922 auth: Fix Google auth to not assume SUBDOMAINS_HOMEPAGE.
Previously, Google auth would redirect you back to the login page on
this code path.
2017-08-24 19:03:42 -07:00
Eeshan Garg 31986d1b94 github_webhook: Update "pull_request unassigned" event fixture.
The older fixture for this event assumed that the "assignee" key
had a value of '{}' if no one was assigned to a PR anymore.
However, that is no longer true because testing with requestbin
showed that in the latest JSON payload for this event, the key
"assignee" now has the value of 'null' (None when converted to
Python) when a user is unassigned from a PR. The current code
didn't handle this correctly. This commit makes sure it does!

Its unclear as to whether the old fixture was simply wrong or
whether GitHub changed its payloads in any way.
2017-08-24 16:48:00 -07:00
Tim Abbott 8b0c0c33b5 login: Fix logging for login/register actions.
Previously, Zulip's server logs would not show which user or client
was involved in login or user registration actions, which made
debugging more annoying than it needed to be.
2017-08-24 16:29:27 -07:00
Tim Abbott a570a57fd5 login: Log which user was authenticated in mobile flows. 2017-08-24 16:29:27 -07:00
Tim Abbott 5206dad373 decorator: Fix is_browser_view handling of e.g. mobile apps.
We may end up with some endpoints that could be the browser or the
mobile apps, and we want the right default to happen here.
2017-08-24 16:26:57 -07:00
Tim Abbott 7ffc107061 decorator: Rename is_json_view to is_browser_view.
This improves clarity, now that we're planning to start logging in the
login/registration pages, which aren't browser views.
2017-08-24 16:25:08 -07:00
Tim Abbott a3bc041894 send_password_reset_email: Simplify argument parsing. 2017-08-24 14:41:45 -07:00
Vishnu Ks 2b076ef822 management: Move all_users option to ZulipBaseCommand. 2017-08-24 14:35:18 -07:00
Vishnu Ks 9d043e7fb0 management: Use self.style attribute for colored output. 2017-08-24 14:29:32 -07:00
Vishnu Ks f4df74d968 management: Use add_user_list_args in send_password_reset_email. 2017-08-24 14:29:32 -07:00
Vishnu Ks 65a20b3b99 management: Use add_user_list_args in remove_users_from_stream. 2017-08-24 14:29:32 -07:00
Vishnu Ks 0949924ea3 management: Use add_user_list_args in add_users_to_streams. 2017-08-24 14:29:32 -07:00
Vishnu Ks a82b3f1ea5 management: Use add_user_list_args in turn_off_digests. 2017-08-24 14:29:32 -07:00
Vishnu Ks f9a6dffe1a management: Add add_user_list_args function to ZulipBaseCommand. 2017-08-24 14:29:32 -07:00
Steve Howell 87c4961597 Add zerver/lib/topic_mutes.py
This is mostly pure code extraction.

It also removes some dead code in update_muted_topic, where
were updating muted_topics spuriously before calling
do_update_muted_topic.
2017-08-24 14:20:35 -07:00
Robert Hönig 18a080cd6c Don't handle json payload key errors inside webhooks.
Fixes first part of #6213.
2017-08-24 11:33:14 -07:00
Tim Abbott 93fb6a1688 models: Add support for using the root subdomain.
Previously, realm.uri and realm.host didn't support using a subdomain
of the empty string (""), aka using the root domain.

Also, since we're already accessing self.subdomain, we don't need to
check REALMS_HAVE_SUBDOMAINS again.
2017-08-23 23:19:19 -07:00
Tim Abbott f46f3871b4 integrations: Add support for using root subdomain.
This fixes up the URL/link construction to make the root subdomain work.
2017-08-23 23:18:36 -07:00
Tim Abbott d44ac5c320 auth: Clean up google_oauth2_test arguments. 2017-08-23 20:50:03 -07:00
Tim Abbott d3e3c704d4 do_create_realm: Remove unnecessary second return value.
Unlike creating a stream, there's really no reason one would want to
call the function to create a realm while uncertain whether that realm
already existed.
2017-08-23 20:07:17 -07:00
Tim Abbott 8a65fdce49 subdomains: Fix over-aggressive redirect to find_my_team.
If the root domain is a valid subdomain, we don't want to redirect
everyone away from it.
2017-08-23 20:07:17 -07:00
Tim Abbott 397340b454 test_events: Fix a missing mypy import. 2017-08-23 20:04:20 -07:00
Vishnu Ks 8418f0d30e dev_login: List realms and show only users in the selected realm. 2017-08-23 19:27:32 -07:00
Tim Abbott 225debdbc5 test_events: Fix a misplaced type annotation. 2017-08-23 19:19:14 -07:00
Tim Abbott 8cbdaca9f5 fix_unreads: Fix handling of muted_topics on missing streams.
If the stream no longer exists, we can just ignored the muted_topics
entry.
2017-08-23 18:14:11 -07:00
Steve Howell f797604e66 Add test coverage for unreads count (stream muting). 2017-08-23 18:00:59 -07:00
Tim Abbott 7918551fa9 fix_unreads: Help postgres figure out the most efficient query.
In theory, this shouldn't make a difference, but in practice, this
helps postgres make better use of our unread messages index.
2017-08-23 18:00:33 -07:00