Commit Graph

72 Commits

Author SHA1 Message Date
Tim Abbott 375551aaa6 Clean up most hardcoding of mit.edu domain checks.
This moves all this code to be gated on a few virtual realm settings.
2016-07-26 20:30:12 -07:00
Steve Howell 3fa745ebe3 Remove untested code in is_public_stream().
We were calling valid_stream_name(), but more appropriate
validation checks for stream names happen elsewhere in the codepath.
2016-07-26 18:10:00 -07:00
Tim Abbott afaac85dc6 Move get_sqlalchemy_connection to its own file. 2016-07-19 15:28:41 -07:00
Taranjeet Singh 3031214718 zerver/views/messages.py: Fix line with length greater than 120. 2016-07-18 15:05:52 -07:00
Steve Howell 2bfa763c0b Use topic_name() in update_message_backend(). 2016-07-18 14:10:11 -07:00
Steve Howell 60bd20da61 Remove zerver/lib/query.py (dead code). 2016-07-16 14:51:15 -07:00
Rishi Gupta 09754c9861 Remove JsonableErrors from actions.do_update_message.
There were a bunch of authorization and well-formedness checks in
zerver.lib.actions.do_update_message that I moved to
zerver.views.messages.update_message_backend.

Reason: by convention, functions in actions.py complete their actions;
error checking should be done outside the file when possible.

Fixes: #1150.
2016-07-15 13:55:49 -07:00
Tim Abbott 305189956b update_message_flags: Log number of messages updated. 2016-07-12 19:12:49 -07:00
Tim Abbott 3647973069 update_message_backend: Reorganize validation checks.
The new organization more clearly does the permission check first.
2016-07-10 18:01:59 -07:00
Tim Abbott 05632b68e1 edit: Add validation for setting empty content. 2016-07-10 18:01:59 -07:00
Tim Abbott 211a166abc message edit: Move new topic non-empty check to view. 2016-07-10 18:01:59 -07:00
Rishi Gupta 43c2f35776 Add realm setting to disable message editing.
This is controlled through the admin tab and a new field in the Realms
table.  This mirrors the behavior of the old hardcoded setting
feature_flags.disable_message_editing.  Partially resolves #903.
2016-07-10 11:57:24 -07:00
Steve Howell c680c6a981 Removed unused to_non_negative_float() function. 2016-07-09 07:37:13 -07:00
Eklavya Sharma 26b8e7357a zerver/views/messages.py: Operate on bytes in highlight_string. 2016-07-07 12:42:51 -07:00
acrefoot e4ed9195dc Remove rest_dispatch hack and optimize imports.
For a long time, rest_dispatch has had this hack where we have to
create a copy of it in each views file using it, in order to directly
access the globals list in that file.  This removes that hack, instead
making rest_dispatch just use Django's import_string to access the
target method to use.

[tweaked and reorganized from acrefoot's original branch in various
ways by tabbott]
2016-06-24 16:11:03 -07:00
Tomasz Kolek 9ae68ade8b Add is_webhook option to authentication decorats.
Modified:
authenticated_rest_api_view
authenticated_api_view and validate_api_key.
2016-06-21 11:47:38 -07:00
John Hergenroeder 16a19226f6 Add linter check for redundant REQ whence argument. 2016-06-16 13:53:39 -07:00
Eklavya Sharma 53084fe03c Use text_type as type of cache keys and update users.
This changes the type annotations for the cache keys in Zulip to be
consistently text_type, and updates the annotations for values that
are used as cache keys across the codebase.
2016-06-11 09:10:34 -07:00
Hyunchel Kim b0702c62fc Annotate zerver.views.messages partially. 2016-06-07 21:09:30 -07:00
Umair Khan 08fbd57245 [i18n] Make error messages translatable.
Make all strings passing through `json_error` and `JsonableError`
translatable.

Fixes #727
2016-05-31 07:40:42 -07:00
Tim Abbott 960144a49e Desupport using uninstantiated REQ with has_request_variables.
This makes life difficult for doing static type annotations, and
didn't make the code look that much better anyway.
2016-05-31 07:31:15 -07:00
Tim Abbott 92bec8cfea Merge Zulip 1.3.12 security release. 2016-05-10 11:32:26 -07:00
Tim Abbott 3cde06ea33 Add support for setting HTTP status codes in JsonableError. 2016-05-10 09:50:48 -07:00
Preston Hansen 635828069f Add feature to mark all in stream/topic as read with mouse.
Fixes #736.
2016-05-08 09:02:46 -07:00
Tim Abbott 49799440a4 Replace use of django-guardian with fields on UserProfile.
As documented in https://github.com/zulip/zulip/issues/441, Guardian
has quite poor performance, and in fact almost 50% of the time spent
running the Zulip backend test suite on my laptop was inside Guardian.

As part of this migration, we also clean up the old API_SUPER_USERS
variable used to mark EMAIL_GATEWAY_BOT as an API super user; now that
permission is managed entirely via the database.

When rebasing past this commit, developers will need to do a
`manage.py migrate` in order to apply the migration changes before the
server will run again.

We can't yet remove Guardian from INSTALLED_APPS, requirements.txt,
etc. in this release, because otherwise the reverse migration won't
work.

Fixes #441.
2016-04-20 21:51:52 -07:00
Ashish 42fe918138 Delete old route for json/get_old_messages. 2016-04-11 21:38:23 -07:00
Ashish c0a218edfc Delete old route for /json/update_message_flags. 2016-04-11 21:38:23 -07:00
Tim Abbott ec7bb0b011 Add PEP-484 type annotations to zerver/views/. 2016-04-03 15:40:23 -07:00
Ryan Moore 2fe0700f55 Update memcache -> remote cache in inline documentation. 2016-03-31 12:56:42 -07:00
Eklavya Sharma 9e3c3e14f5 Partially apply Python 3 libmodernize.fixes.fix_dict_six.
Refer to #256
2016-03-19 15:52:58 -07:00
Tim Abbott 5bacda3662 python3: Fix usage of .keys()/.values() to handle iterators.
This fixes the places where we use the result of .keys(), .items(),
and .values() that wouldn't work with an iterator to wrap them with
list().
2016-01-26 21:11:25 -08:00
Tim Abbott e95739961f Remove now obsolete /json/send_message route. 2015-12-12 18:14:08 -08:00
Tim Abbott 33295180a9 Apply Python 3 futurize transform libmodernize.fixes.fix_unicode_type. 2015-11-01 09:35:06 -08:00
Tim Abbott cd6f8e9191 Apply Python 3 futurize transform libmodernize.fixes.fix_map. 2015-11-01 09:35:05 -08:00
Tim Abbott b68d116e3a Remove old is_super_user helper functions.
(imported from commit 85655ea9369f5dc309f6f687bac578924571c9ee)
2015-09-20 11:13:20 -07:00
Zev Benjamin 4d3f0cdc74 Encode unicode strings using UTF-8 before applying search highlighting
(imported from commit 45ded691fb89ccff12e76d5ca3b593ce3ff3f2e0)
2015-03-19 15:25:42 -07:00
Tim Abbott 6ac6fd5e56 Remove requirement that local_id by a float in local echo.
(imported from commit c3de78760c1c7e11c6791719420b59df604d5319)
2014-06-25 11:44:16 -07:00
Zev Benjamin 27aaa3b1bf Rename mit_to_mit -> same_realm_zephyr_user for uniformity and clarity
(imported from commit 74063d6c8bb9e9fbf62c24dcd8a18294b8f7b51f)
2014-03-06 21:59:55 -05:00
Zev Benjamin cc9fe19a9f Special case Jabber mirroring same-realm check for ist.mit.edu
We can't just check that the realms are the same because ist.mit.edu is an open
realm and uses @mit.edu email addresses.

(imported from commit 7dbaa81cea6e4f82563dfc0cfe67a61fe9378911)
2014-03-06 21:59:55 -05:00
Steve Howell e7769d9004 Add back end support for in-home/in-all narrows.
(imported from commit bfa54fbb8c7eaced19e354514536d75c30a24b15)
2014-03-05 14:56:34 -05:00
Jason Michalski de545d5fa0 [schema] Add a default to stream option to user profile
This allows bot owners to configure which streams messages are delivered
to without needing to change webhook URLs or configuration files.

(imported from commit 32a0c26657c145b001cd8cb3ce0a0364d48902ce)
2014-03-05 14:16:18 -05:00
Steve Howell 82a935080d Support has:* searches on the back end.
(imported from commit a6a6f465ce0343d4a5313ee54f6ff427940a03ab)
2014-03-05 13:58:53 -05:00
Zev Benjamin 406e3025fb Recognize new-style client name for Jabber mirror
(imported from commit 3c1f8120f4daa809e0844602bc8bea659837d84e)
2014-03-03 17:29:53 -05:00
Steve Howell 4bc50c3560 Rename NarrowBuilder.__call__ to add_term().
We also call the objects "builder" instead of "build."

(imported from commit aa3fcedc8eb97c21f29aa651cf1f6852ff311e7d)
2014-02-27 20:25:38 -05:00
Steve Howell c9140a6def Exclude muted streams in exclude_muting_conditions().
If we call exclude_muting_conditions() with a non-stream
narrow, it will now include a condition to exclude streams
that are not in your home view.  As of now, this code only
executes during testing, but it sets the stage for doing
better in:home queries on the back end.

(imported from commit bbd764bd0e9588a50e4a82c915e82a2c1b99d73e)
2014-02-27 20:25:37 -05:00
Steve Howell b822c83b02 Avoid redundant query clauses for muted topics.
If we are already narrowing to a stream, then we can disregard
muted topics in all the other streams and create a simpler query
for the DB to execute.

(imported from commit 35a074a76eec99922034a381741355da3fdd5b39)
2014-02-27 20:25:36 -05:00
Steve Howell fab6b0f7ae Handle non-existent streams in exclude_muting_conditions().
Due to the way we store muted topics, it is possible that a
muted topic stream name may no longer exist, and we need to
handle that case gracefully.

(imported from commit 4d18ec55e45213657a67e160848229678f212765)
2014-02-27 20:25:36 -05:00
Steve Howell 9d21787cd7 Extract exclude_muting_conditions() in messages.py
(imported from commit 97144097406377eb40383c7d1314c74dd713719c)
2014-02-27 20:25:35 -05:00
Zev Benjamin 1a6929d9ae Handle get_old_messages case where num_before = 0 and num_after = 0 and a narrow is specified
Previously, we assumed that num_before or num_after would be always be non-zero
after adjustment for the anchor.  However, we don't adjust num_before or
num_after when a narrow is specified.

(imported from commit 9239fef140e109b11bdfbeef42e9fbed78660ad1)
2014-02-19 12:24:17 -05:00
Steve Howell 8b58d8574b Use check_bool instead of json_to_bool.
(imported from commit 52eb892a92e293d6ecb854c51bd7bd32355206c9)
2014-02-18 13:02:08 -05:00