Commit Graph

5424 Commits

Author SHA1 Message Date
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
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
Steve Howell
274938bf5f Eliminate approximate_unread_count().
We use page_params.unread_msgs.count in the web
app instead.

Fixes #1300.
2017-08-14 12:39:00 -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
f9b5a270d0 integrations: Remove titles from integration docs. 2017-08-10 10:21:53 -07:00
Jack Zhang
fc6c2b321b portico: Reimplement /apps routes using pushState. 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
e56b060ef4 github_webhook/doc.md: Add link to deprecated Github Services integration. 2017-08-10 10:21:53 -07:00
Jack Zhang
8187b7ab57 bitbucket2/doc.md: Add link to deprecated Enterprise integration. 2017-08-10 10:21:53 -07:00
Jack Zhang
1e6570fa5d Update integrations doc context relative urls. 2017-08-10 10:21:53 -07:00
Jack Zhang
9461f2f799 docs: Update /integrations links to new pushState routes.
Update Email, Beanstalk, Hubot, JIRA, and Trello integrations
links.

The Hubot integrations section (/integrations#hubot-integrations)
was removed  in an earlier redesign of /integrations. This commit
replaces the link with the hubot-scripts organization on
Github, which displays the comprehensive list of all integrations
available via Hubot.

Fixes #5875.
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
Jack Zhang
63ad7b6769 Rename /integrations/doc API endpoint as /integrations/doc-html. 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)
357c9ed016 mypy: Pass empty dict to makeRecord for args, instead of None. 2017-08-09 18:04:21 -07:00
neiljp (Neil Pilgrim)
a6bb8f552b mypy: Mark get_session_user() as returning Optional[int]. 2017-08-09 18:04:21 -07:00
Tim Abbott
1d10941712 register: Don't display field to enter password unless needed.
This should significantly improve the user experience for new users
signing up with GitHub/Google auth.  It comes complete with tests for
the various cases.  Further work may be needed for LDAP to not prompt
for a password, however.

Fixes #886.
2017-08-09 13:44:57 -07:00
Umair Khan
2c9a57161a registration: Add test for password less remote reg. 2017-08-09 13:44:57 -07:00