Commit Graph

20392 Commits

Author SHA1 Message Date
Tim Abbott ba411b0539 digest: Use get_user_profile_by_id. 2017-08-15 12:53:48 -07:00
Tim Abbott 353a61b1d8 test_signup: Clean up re-fetching of user objects. 2017-08-15 12:52:23 -07:00
Tim Abbott e3e2d9093c analytics: Remove references to UserProfile.objects.get. 2017-08-15 12:48:33 -07:00
Jack Zhang a533ab5881 context_processors.py: Add flag for whether user is logged in. 2017-08-15 12:15:21 -07:00
Jack Zhang 182570d5f3 Deduplicate header markup for portico and portico-help templates. 2017-08-15 12:15:21 -07:00
Jack Zhang b82bdc82bf context_processors.py: Add flag for whether page is help center.
This is needed once the header markup is deduplicated.
2017-08-15 12:15:21 -07:00
Steve Howell f0de6bd461 node tests: Add "Starting node tests..." message. 2017-08-15 14:50:10 -04:00
Tim Abbott 4525843681 docs: Clarify documentation on verifying push notifications.
This is based on discussion in #6100.
2017-08-15 11:25:30 -07:00
Tim Abbott 93aa28ed08 decorator: Clean up ugly validation comment. 2017-08-15 10:55:32 -07:00
Tim Abbott 5a63ea0170 decorator: Extract validate_account_and_subdomain and deduplicate.
This fixes the significant duplication of code between the
authenticate_log_and_execute_json code path and the `validate_api_key`
code path.

These's till a bit of duplication, in the form of `process_client` and
`request._email` interactions, but it is very minor at this point.
2017-08-15 10:54:23 -07:00
Tim Abbott 127222e7e5 decorator: Clean up process_client call with positional argument. 2017-08-15 10:54:23 -07:00
Tim Abbott 0262609c3d decorator: Use validate_api_key in api_key_only_webhook_view code path.
This completes the effort to deduplicate the main code of our
authentication decorators.
2017-08-15 10:54:23 -07:00
Tim Abbott 319ea62cd9 decorator: Extract zerver/lib/profile.py.
This lets us remove this debugging function from our core
authentication codebase.
2017-08-15 10:54:23 -07:00
Tim Abbott 077c05fc78 decorator: Remove ancient client_name hack for iOS.
The old iOS app has been gone from the app store for 8 months, never
had a huge userbase, and its latest version didn't need this hack.  So
this code is unlikely to do anything in the future; remove it to
declutter our authentication decorators codebase.
2017-08-15 10:54:23 -07:00
Tim Abbott b46af40bd3 decorator: Refactor more code into validate_api_key. 2017-08-15 10:54:23 -07:00
Tim Abbott 5d2d939310 validate_api_key: Stop using 'profile' local variable. 2017-08-15 10:54:23 -07:00
Tim Abbott 25ec30dcf1 decorator: Deduplicate validate_api_key by using new helper function.
This should eliminate a bunch of duplicated code between these two
code paths.
2017-08-15 10:54:23 -07:00
Tim Abbott cc03c8766f test_helpers: Expand HostRequestMock variables. 2017-08-15 10:54:23 -07:00
Tim Abbott 5b8d04e18f decorator: Remove now-unnecessary cast. 2017-08-15 10:54:23 -07:00
Tim Abbott 5ebe507c9b decorator: Fix check for incoming webhook bots and move later
The check itself was correct, but the error message was in fact the
opposite of what this check is for.  In other words, the only things
these users can do is post messages, and the error message when you
tried to do something else was to tell you that the user can't post
messages.
2017-08-15 10:54:23 -07:00
Tim Abbott 3c37795675 decorator: Add localhost/Tornado hack to access_user_by_api_key.
This should make it possible to share that code with other code paths.
2017-08-15 10:54:23 -07:00
Tim Abbott 1144eed48b decorator: Clean up 'profile' variable reuse. 2017-08-15 10:54:23 -07:00
Tim Abbott a2011b5a48 decorator: Simplify control flow in validate_api_key.
This technically changes the behavior in the case that
!settings.ZILENCER_ENABLED but is_remote_zulip_server(role).
Fortunately, that case is mostly irrelevant (in that remote zulip
servers is a Zilencer feature).  The old behavior was also probably
slightly wrong, in that you'd get a zilencer-specific error message in
that case.
2017-08-15 10:52:46 -07:00
Tim Abbott a6647f335f decorator: Reorganize remote Zulip server code into one block. 2017-08-15 10:51:29 -07:00
Tim Abbott 052e173aae decorator: Simplify invalid API key error messages. 2017-08-15 10:51:29 -07:00
Tim Abbott 928a93bb9a decorator: Swap order of remote server if statements. 2017-08-15 10:51:29 -07:00
Tim Abbott 3157618b80 decorators: Extract access_user_by_api_key. 2017-08-15 10:51:29 -07:00
Tim Abbott 84da22da67 travis: Improve production test for HTTP success to not check length.
This will make life a lot easier when iterating on the login page.
2017-08-15 10:51:29 -07:00
Akash Nimare eb88bd9552 portico: Point desktop app links to latest release. 2017-08-15 10:51:22 -07:00
Tim Abbott ffc1ceeaa4 lint: Ban use of get_stream in the rest of messages.py.
This will help avoid potential future security bugs.
2017-08-15 10:40:02 -07:00
Tim Abbott 842bf77efb unread: Convert mark_topic_as_read to use stream IDs.
This is safer in its handling of potentially renamed streams.
2017-08-15 10:40:02 -07:00
Tim Abbott f3a41ac796 unread: Convert mark_stream_as_read to use stream IDs.
The logic is simpler and more robust.
2017-08-15 10:40:02 -07:00
Steve Howell 89f9017686 Create new endpoints for marking streams/topics as read.
The new endpoints are:
    /json/mark_stream_as_read: takes stream name
    /json/mark_topic_as_read: takes stream name, topic name

The /json/flags endpoint no longer allows streams or topics
to be passed in as parameters.
2017-08-15 10:17:29 -07:00
Steve Howell 60cc8fd58a Extract do_mark_stream_messages_as_read.
This function optimizes marking streams and topics as read,
by using UserMessage.where_unread(), which uses a partial
index on the "read" flag.

This also simplifies the code path for ordinary message
flag updates.

In order to keep 100% line coverage, I simplified the
logging in update_message_flags, so now all requests
will show the "actually" format.

This is an interim step toward creating dedicated endpoints
for marking streams/topics as reads, so we do error checking
with asserts for flag/operation, so we don't introduce a
temporary translation string.
2017-08-15 10:09:10 -07:00
Steve Howell ffe4f09c88 Extract update_stream_topic_message_flags.
This is mostly a pure code extraction, except that we now
disregard the `messages` option for stream/topic updates,
since the web app always passes in an empty list (and this
commit is really just an incremental step toward creating
new endpoints.)
2017-08-15 10:09:10 -07:00
Tim Abbott a6a3915dd7 messages: Move is_public_stream out of views code.
The main purpose of this change is to minimize access to get_stream in
views code.
2017-08-15 10:06:26 -07:00
Tim Abbott 9081f2cf44 reactions: Store the emoji codepoint in the database.
This is the first part of a larger migration to convert Zulip's
reactions storage to something based on the codepoint, not the emoji
name that the user typed in, so that we don't need to worry about
changes in the names we're using breaking the emoji storage.
2017-08-15 09:29:27 -07:00
Robert Hönig c5f0478374 linter: Add trailing whitespace check for json files. 2017-08-15 09:28:11 -07:00
Tim Abbott 3409806b88 test_narrow: Fix nondeterministic test failures with "lunch".
We recently changed the populate_db data set to include more variable
message content, which happened to include the possibility of the word
"lunch" appearing in the test messages.  This caused occasional
failures of the search tests that looked for messages containing
"lunch" starting at the beginning of time, not the beginning of the
test.
2017-08-15 09:20:45 -07:00
Robert Hönig 4be814fc16 integrations: Add OpsGenie integration. 2017-08-15 08:42:19 -07:00
Aditya Bansal a33790946b management: Add soft_deactivate_users command. 2017-08-15 08:33:16 -07:00
Aditya Bansal 25d9c7eea1 soft_deactivation: Add helper functions.
This commits adds new helper functions which are:
* get_users_for_soft_deactivation(): This function can be used to
fetch a list of human users which pass the criteria of minimum
inactivity period (in days) passed as a parameter to the function.
* do_soft_activate_users(): Given a list of users this function
reactivates them and help them catch up with the missing message
rows for them in the UserMessage table.
2017-08-15 08:33:16 -07:00
Aditya Bansal 0cb909b978 events: Fill in missing messages for a returing soft_deactivated user. 2017-08-15 08:33:16 -07:00
Aditya Bansal 658a14d0bb soft_deactivation: Stop creating UserMessage rows when soft deactivated. 2017-08-15 08:33:16 -07:00
Tim Abbott ce670a7892 soft_deactivation: Document add_missing_messages algorithm. 2017-08-15 08:33:14 -07:00
Tim Abbott 14aaefdd46 soft_deactivation: rename find_and_store_to_insert_stream_msgs.
The original name was very verbose, and a bit less clear.
2017-08-15 08:29:51 -07:00
Tim Abbott 45bc599b02 soft_deactivation: Clean up user_messages_to_insert. 2017-08-15 08:29:51 -07:00
Aditya Bansal 57858596ab soft_deactivation: Add new function 'add_missing_messages'.
This function will help us in creating undisturbed experience for
returning soft deactivated users.

Tweaked by tabbott to fix minor performance and clarity issues.
2017-08-15 08:29:51 -07:00
Aditya Bansal dc5510ce44 soft_deactivation: Add helper functions for deactivating users. 2017-08-15 08:29:28 -07:00
Tim Abbott 0cd287b3f5 mypy: Add documentation for requirements/mypy.txt. 2017-08-15 07:24:42 -07:00