Commit Graph

4337 Commits

Author SHA1 Message Date
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
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
4be814fc16 integrations: Add OpsGenie integration. 2017-08-15 08:42:19 -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
Steve Howell
658ac782a2 Add page_params.unread_msgs.count.
This field is convenient for bankruptcy checks.  Clients could
calculate it from page_params.unread_msgs before this change, but
it would kind of a painful calculation.

To add count, we had to simplify the mypy annotations, which weren't
really accurate before.
2017-08-14 12:38:09 -07:00
Steve Howell
c0dec29f5f Exclude inactive streams from unread counts. 2017-08-14 12:38:09 -07:00
Tim Abbott
09f84f91f4 request: Improve documentation of request.py. 2017-08-14 09:49:29 -07:00
rht
668af8b6f9 mypy: Annotate zerver/lib/exceptions.py. 2017-08-14 09:47:28 -07:00
rht
2541b29bdc mypy: Annotate zerver/lib/request.py. 2017-08-14 09:47:28 -07:00
Jack Zhang
ab9021678e Remove secondary lines of text from JIRA, Github, and Trello integrations. 2017-08-10 10:21:53 -07:00
Jack Zhang
4125311d6f integrations.py: Add tag for legacy integrations. 2017-08-10 10:21:53 -07:00
Jack Zhang
a704dad06b integrations: Replace underscores with dashes in CATEGORIES keys.
The CATEGORIES keys, in a similar fashion to INTEGRATIONS keys,
are utilized for links.
2017-08-10 10:21:53 -07:00
Steve Howell
c7b9044ee5 Fix apply_unread_message_event() for mentions.
We were exiting this function in certain cases before updating
mentions. This bug was always there, but it was flaky in terms
of database setup whether the tests would fail, so now the
relevant test sends three consecutive messages.

We also avoid putting duplicate message ids in mentions.
2017-08-10 05:09:04 -04:00
neiljp (Neil Pilgrim)
a6bb8f552b mypy: Mark get_session_user() as returning Optional[int]. 2017-08-09 18:04:21 -07:00
Vishnu Ks
6b46762384 management: Fix typo in get_realm CommandError message. 2017-08-08 14:13:19 -07:00
Vishnu Ks
679fece79d management: Add argument for specifying help in add_realm_args. 2017-08-08 14:13:19 -07:00
neiljp (Neil Pilgrim)
b782db48e1 mypy: Remove superfluous older 'type: ignore' annotations. 2017-08-08 11:27:51 -07:00
neiljp (Neil Pilgrim)
3711da0dc9 mypy: Mark request_data as Optional based on requests API. 2017-08-07 21:27:50 -07:00
Jack Zhang
d9c1ad5db2 hotspots.py: Add SEND_ALL flag.
Used to view all hotspots in development.
2017-08-05 18:32:37 -07:00
Harshit Bansal
5a5072730c realm_emoji: Don't accept animated realm emoji with unequal dimensions.
Fixes: #3654.
2017-08-05 18:07:21 -07:00
neiljp (Neil Pilgrim)
6bed9da353 mypy: Amend flock contextmanager to accept Union[int, IO[Any]]. 2017-08-05 17:53:18 -07:00
Tim Abbott
4bb979d869 test_helpers: Fix annotation for avatar_disk_path. 2017-08-05 17:53:18 -07:00
neiljp (Neil Pilgrim)
3ca34bebdc mypy: Use Callable as parameter for simulated_queue_client.
Previously the type was annotated as 'type'.
2017-08-05 12:08:59 -07:00
Rishi Gupta
4bf8ac2498 generate_test_data: Replace source with non-Gutenberg text.
It's hard to find literature with the community tone we're going for, that
is consistent with the Zulip code of conduct, etc.

This commit removes the special tooling for Gutenberg plays, and changes the
text to be some mixture of scigen, Communications From Elsewhere,
chat.zulip.org, and various books from the public domain.
2017-08-05 11:04:35 -07:00
Rishi Gupta
4350b52740 generate_test_data: Fix remove_line_breaks algorithm. 2017-08-05 11:04:35 -07:00
Tim Abbott
dd49bec93c Fix changing email addresses back after email change.
We apparently were not correctly clearing the user_profile's email
address from caches when changing email addresses, which meant that
trying to look up the old email in the user_profile caches would still
work.

Fixes #6035.
2017-08-05 10:49:44 -07:00
Vishnu Ks
e7f5da83ac management: Create list realms command.
Fixes #5917.
2017-08-04 14:25:03 -07:00
Steve Howell
63f7b9a579 Remove "all" option for flag-updating endpoint.
The "all" option for 'message/flags' was dangerous, as it could
apply to any of our flags.  The only flag it made sense for, the
"read" flag, now has a dedicated endpoint.
2017-08-04 14:10:46 -07:00
Steve Howell
541156792e Add /mark_all_as_read endpoint.
This change simplifies how we mark all messages as read.  It also
speeds up the backend by taking advantage of our partial index
for unread messages.  We also use a new statsd indicator.
2017-08-04 14:10:46 -07:00
neiljp (Neil Pilgrim)
814dce0452 mypy: Set self.doc_context in integrations.py to Optional. 2017-08-03 11:03:14 -07:00
Umair Khan
ef1b880082 rate_limiter: Upgrade api_calls_left to generic API. 2017-08-02 18:01:39 -07:00
Umair Khan
81e2128774 rate_limiter: Upgrade incr_ratelimit to generic API. 2017-08-02 18:01:39 -07:00
Umair Khan
9e33917d25 rate_limiter: Upgrade max_api_calls to generic API. 2017-08-02 18:01:39 -07:00
Umair Khan
ca9ac1948e rate_limiter: Upgrade max_api_window to generic API. 2017-08-02 18:01:39 -07:00
Umair Khan
9c08b62448 rate_limiter: Upgrade unblock_user to generic API.
Change name to unblock_access as well.
2017-08-02 18:01:39 -07:00
Umair Khan
23be0875a1 rate_limiter: Upgrade block_user to generic API.
Change name to block_access as well.
2017-08-02 18:01:39 -07:00
Umair Khan
b2a2664715 rate_limiter: Upgrade clear_user_history to generic API.
Changes the name of the function to change_history as well.
2017-08-02 18:01:39 -07:00
Umair Khan
dd281367ae rate_limited: Upgrade is_ratelimited to generic API. 2017-08-02 18:01:39 -07:00
Umair Khan
3643c4a73e rate_limiter: Use RateLimitedUser class.
This commit lays groundwork for transitioning to using RateLimited
class in our rate limiter API.
2017-08-02 18:01:39 -07:00
Steve Howell
257e110996 unread: Only send clients 5000 most recent unread messages. 2017-08-02 09:40:47 -07:00
Rishi Gupta
3e9a85ecb2 onboarding: Add turtle reaction to an initial message. 2017-08-01 22:51:05 -07:00
Rishi Gupta
31c011dfcc onboarding: Add picture to onboarding messages. 2017-08-01 22:47:57 -07:00