Commit Graph

30969 Commits

Author SHA1 Message Date
Thomas Ip da6fb98d21 typescript: Set appropriate compiler options.
* Make type-checking stricter.
* Use more modern features.
2019-03-18 12:49:47 -07:00
Tim Abbott 4f628fd945 docs: Discuss replacing memcached with redis more clearly.
This is a common question we get in architecture discussions.
2019-03-18 12:40:53 -07:00
Tim Abbott 58ca1ba5a4 models: Disable caching of supported_auth_backends for now.
This seems to be causing hard-to-debug test failures.
2019-03-18 11:29:05 -07:00
Mateusz Mandera 5f88406133 rate_limit tests: Cover RateLimiterLockingException case in rate_limit_user. 2019-03-18 11:16:58 -07:00
Mateusz Mandera 1a3297d122 email_mirror: Make send_to_email_mirror.py use mirror_email_message.
We change the send_to_email_mirror management command, to send messages
to the email mirror through the mirror_email_message function instead of
process_message - this makes the message follow a similar codepath as
emails sent into the mirror with the postfix configuration, which means
going through the MirrorWorker queue. The reason for this is to make
this command useful for testing the new email mirror rate limiter.
2019-03-18 11:16:58 -07:00
Mateusz Mandera 1901775383 email_mirror: Add realm-based rate limiting.
Closes #2420

We add rate limiting (max X emails withing Y seconds per realm) to the
email mirror. By creating RateLimitedRealmMirror class, inheriting from
RateLimitedObject, and rate_limit_mirror_by_realm function, following a
mechanism used by rate_limit_user, we're able to have this
implementation mostly rely on the already existing, and proven over
time, rate_limiter.py code. The rules are configurable in settings.py in
RATE_LIMITING_MIRROR_REALM_RULES, analogically to RATE_LIMITING_RULES.

Rate limit verification happens in the MirrorWorker in
queue_processors.py. We don't rate limit missed message emails, as due
to using one time addresses, they're not a spam threat.

test_mirror_worker is adapted to the altered MirrorWorker code and a new
test - test_mirror_worker_rate_limiting is added in test_queue_worker.py
to provide coverage for these changes.
2019-03-18 11:16:58 -07:00
Mateusz Mandera 386813f42b test_queue_worker: Clean up test_mirror_worker.
We clean up test_mirror_worker for more readability, as well as make it
verify that mirror_email gets called the correct amount of times and use
a correct rcpt_to address, so that the test doesn't fail when some
verification of the address is added in the following commits
implementing rate limiting in the email mirror.
2019-03-18 11:16:58 -07:00
Mateusz Mandera 5b86734178 email_mirror: Change stream name encoding in mirror addresses.
Fixes #9840.

Old addresses caused bugs in some cases with non-latin characters in
stream names (see issue number above). We switch to using django's
slugify helper function to convert stream names to full ascii, while
also getting rid of problematic non-alphanumeric characters, in a
reasonable way. See Django's documentation for slugify to see more about
how this function works.

Tests extended by tabbott to cover cases where we do end up with ascii.
2019-03-18 11:14:22 -07:00
Mateusz Mandera a64a075ff1 email_mirror: Ignore stream_name part of receiving address.
To prepare for changing how the stream name gets encoded into mirror
email addresses while making sure old addresses keep working, we ignore
the stream_name part when receiving emails into the mirror and we only
look at the email_token to identify into which stream to mirror the
email.
2019-03-18 11:06:51 -07:00
Tim Abbott 898798a352 email_log: Fix buggy use of get_realm_stream.
I'm surprised that this wasn't a mypy error; we were passing a Realm
object as an integer, and predictably, this resulted in us
constructing a cache key that looked like this:

stream_by_realm_and_name:<Realm: zulip 1>:dd5...
2019-03-18 10:59:30 -07:00
Tim Abbott 51eeb0a3ee cache: Add missing : in test-backend key prefixes.
Previously, these cache keys looked like:
:1:9c26164d3a393e316e0f8210efe270e08710d45astream_by_realm_and_name:...

Now, they look like this:
:1:9c26164d3a393e316e0f8210efe270e08710d45a:stream_by_realm_and_name:...
2019-03-18 10:56:50 -07:00
Tim Abbott 5d20138d72 context_processors: Optimize calculation of social_backends.
This avoids a bunch of duplicated calls to auth_enabled_helper for our
social auth backends, which added up because auth_enabled_helper can
take 100us to run.
2019-03-17 15:20:36 -07:00
Tim Abbott a9350caee2 context_processors: Optimize calculation of no_auth_enabled.
This saves an unnecessary call to auth_enabled_helper.
2019-03-17 15:19:06 -07:00
Tim Abbott b4d47b129d backends: Further optimize auth_enabled_helper.
This avoids repeatedly calling a Django auth function that takes a few
hundred microseconds to run in auth_enabled_helper, which itself is
currently called 14 times in every request to pages using
common_context.
2019-03-17 15:14:06 -07:00
Tim Abbott cb78ddc491 models: Fix performance of supported_auth_backends with caching.
See the comment, but this is a significant performance optimization
for all of our pages using common_context, because this code path is
called more than a dozen times (recursively) by common_context.
2019-03-17 15:14:05 -07:00
Tim Abbott 79ae9175bb context_processors: Avoid useless duplicate queries for realm object.
We have a few code paths that call get_realm_from_request multiple
times on the same request (e.g. the login page), once inside the view
function and once inside the common context processor code.  This
change saves a useless duplicate database query in those code paths.
2019-03-17 14:08:53 -07:00
Tim Abbott f270e354b1 login: Fix unnecessary queries on /login/ in development.
This block of code with 2 database queries is solely for the /devlogin
endpoint.  Removing that block from the /login code path makes it
easier to test /login perf in development.
2019-03-17 14:03:57 -07:00
Tim Abbott 0a7b6909b9 login: Fix a useless query with DevAuthBackend.
This block was setting `realm` to a value that it already was if you
read a bit further up in the function.
2019-03-17 14:03:27 -07:00
Hemanth V. Alluri 1269b72f47 context_processors: Do not render inline previews for realm description.
We never intended to render them for this use case as the result would
not look good, and now we have a convenient bugdown option for
controlling this behavior.

Since we're not storing the markdown rendering anywhere, there's
conveniently no data migration required.

Fixes #11889.
2019-03-17 13:55:10 -07:00
Rhythm Sharma e1212c04d1 emoji: Add a few useful aliases. 2019-03-17 13:38:31 -07:00
Mateusz Mandera a269c4bdd4 email_mirror: Make email_token a unique column of Stream. 2019-03-17 12:55:35 -07:00
Eeshan Garg 623ee15bee webhooks/bitbucket: Account for missing user info.
According to our logs, some BitBucket enterprise payloads may
not contain the name of the user who pushed all the commits.
2019-03-16 15:09:03 -02:30
sameerchoubey a47edd4fc8 webhooks/jira: Use dictionary to map events to functions. 2019-03-16 14:27:00 -02:30
Rishi Gupta ee2af16dc9 help: Fix wording in set-your-profile-picture. 2019-03-15 14:13:50 -07:00
Steve Howell 0c029fa3df left sidebar: Remove broken animation for new PMs.
When new PMs came in, we would do a little
animation to show you the incoming message.
Unfortunately, it was broken and would animate
too many things.  (The code looks at a single
var to see if PM counts changed, but there are
actually mulitple PM counts.  We could fix that,
but we decided that this feature just isn't
worth the complexity.)

We still animate incoming mentions.

Fixes #11868.
2019-03-15 13:33:11 -07:00
Ben Muschol 243be91a9b settings: use i18n.t on profile picture upload message.
This fixes a small bug where the text previously was not being looked
up for translation.
2019-03-15 13:30:18 -07:00
Ben Muschol d526ff00f2 settings: Rename "user avatar" to "profile picture"
This renames references to user avatars, bot avatars, or organization
icons to profile pictures. The string in the UI are updated,
in addition to the help files, comments, and documentation. Actual
variable/function names, changelog entries, routes, and s3 buckets are
left as-is in order to avoid introducing bugs.

Fixes #11824.
2019-03-15 13:29:56 -07:00
Tim Abbott cfbe316215 version: Update version and changelog for Zulip 2.0.2 release. 2019-03-15 12:25:50 -07:00
vsvipul a41ada3398 image-action: Fix open and download hover highlight in night mode.
When we try to hover over Open or Download they were not highlighted
in night mode, because of incorrect specificity. This commit adds
highlighting in night mode (possibly fixing a regression when we made
night mode less aggressive about hover).

Fixes #11887.
2019-03-15 11:27:01 -07:00
Tim Abbott 0a145f2203 test_email_notifications: Fix a potentially flaky test.
The previous code assumed the `zulip` realm had ID 1.
2019-03-15 11:02:17 -07:00
Tim Abbott c7ebfdc978 notifications: Rename test_notifications to test_email_notifications.
Similar to the last commit, this makes the scope of this test suite
clearer.
2019-03-15 11:02:17 -07:00
Tim Abbott 50dc317466 notifications: Rename notifications.py to email_notifications.py.
This library is entirely about email notifications specifically, and
this rename should help make the codebase more readable.
2019-03-15 11:02:17 -07:00
Tim Abbott 28a4c143c8 emails: Move clear_scheduled_*emails to send_email.py.
It more properly belongs as part of our outgoing email library, not
notifications.py (which is really about email notifications).
2019-03-15 11:02:17 -07:00
Raymond Akornor 89351cdd19 send_email: Add ScheduledEmail support for multiple recipients.
Follow up on 92dc363. This modifies the ScheduledEmail model
and send_future_email to properly support multiple recipients.

Tweaked by tabbott to add some useful explanatory comments and fix
issues with the migration.
2019-03-15 11:02:12 -07:00
Tim Abbott 8e1dff708e apps: Simplify rendering logic using $.toggle. 2019-03-15 10:11:39 -07:00
theredcap 3aa16dcd73 templates: Add "Download APK" button in apps.html.
This allows user to download the latest version of android apk from
the apps/android.

This will help the users who use Android without Google Play to
download the app and install it with ease.

To implement this I added a Download APK link on the apps.html page
which always points to the latest released version.

Fixes part of #11647.
2019-03-15 10:11:39 -07:00
Anders Kaseorg bd50c6a152 resize: Don’t hide popovers on mobile resize.
Or on the scroll triggered by that resize.

Then we don’t need a kludge that skips the resize handler in
situations where it might hide popovers.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-03-15 09:52:08 -07:00
AsociTon 87f7a578e6 docs: Document a Windows GitHub Desktop bug.
Add the recommendation in docs for not using GitHub Desktop client for
zulip code as it has a bug of keeping the symlinks disabled and ignoring
any configuration done to re-enable it resulting into failure to identify
the received symlinks leading to failing test cases in the zulip development
environment.
2019-03-15 09:48:28 -07:00
Tim Abbott b58d3a37a7 stream_data: Add a comment explaining more topics logic. 2019-03-15 09:34:18 -07:00
Steve Howell ba0418c989 stream_data: Remove untested useless code.
This code was actually dead, due to the .empty() check above.  Fixing
this lets us restore 100% coverage.
2019-03-15 09:27:41 -07:00
Raymond Akornor ea112828dc mypy: Use python3 type syntax in test-backend. 2019-03-15 09:22:30 -07:00
Raymond Akornor 193de819b8 test-backend: Refactor test-backend to be more pythonic. 2019-03-15 09:22:30 -07:00
Tim Abbott 76891f6a02 node: Disable a failing coverage check. 2019-03-14 22:22:06 -07:00
Challa Venkata Raghava Reddy 8623a02d98 streams: Avoid showing more topics option when it's useless.
This makes the "more topics" option which appears below the list of
known topics in the left sidebar appear only when it's possible there
are actually more topics to be displayed.  Two specific cases it
resolves completely include:

* Newly created realms; this widget was a common source of confusion
  for new organization administrators.
* Newly created streams.

There are still some corner cases this doesn't handle, e.g. if you
just joined a private stream with protected history, but there isn't
as easy a fix for those.

Essentially rewritten by tabbott to fix code duplication and comment
extensively.

Fixes #10265.
2019-03-14 21:51:24 -07:00
Pragati Agrawal 2ccf5655da realm_logo: Refactor `build_realm_logo_widget` function.
As a follow up of commit (bf1c9420df), this
commit removes the `build_realm_day_mode_logo_widget` and
`build_realm_night_mode_logo_widget` function , and changes
`build_realm_logo_widget` to take single argument `is_night` and depending
on this argument, corresponding `day mode` or `night_mode` widget is
handled.
2019-03-14 17:05:22 -07:00
Abhishek Kumar Singh 32853a565f portico: Fix the partial visibility of zulip-octopus on landing page.
The image zulip-octopus.png was not fully visible on the
landing-page due to lesser width thus resulting into an incomplete
image.
2019-03-14 15:31:10 -07:00
vinitS101 ead9598fbe user status: Change Active now to Online now in full user profile.
Change "Active now" to "Online now" in Last seen field of
full user profile.
2019-03-14 15:19:09 -07:00
vinitS101 e90ed827bb user status: Change Last seen to Last online.
Change "Last seen" to "Last online" in the full user profile.
2019-03-14 15:19:09 -07:00
Steve Howell 64de28eb68 refactor: Make build_stream_popover more generic.
We now let the click handler find the stream id.
2019-03-14 15:06:41 -07:00
Tim Abbott 4f02795830 home: Fix parsing bug for initial narrows.
There's more we'll want to do here, but this at least avoids error
emails when users attempt to misuse this interface.
2019-03-14 14:53:03 -07:00