Commit Graph

862 Commits

Author SHA1 Message Date
Tim Abbott 0b96e5e43f Fix connection not being closed cleanly on event queue GC.
Apparently, our event queue garbage collection logic never actually
disconnected any existing handler objects.

We fix this by disconnecting the handler inside cleanup(), adding a
special check to avoid creating a pointless timeout object.
2016-03-20 16:53:13 -07:00
Tim Abbott 12a5a3a6e1 Actually fix main Tornado memory leak of handler objects.
This line appears to have been lost in rebasing from the original
implementation of 1396eb7022faec4c2d91553800a35781a96dd5bd; so the
previous fix actually only addressed the issue in a rare exception
case.
2016-03-20 16:53:12 -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
Eklavya Sharma 176c507b0a Removed calls to ifilterfalse.
Replaced calls to ifilterfalse by list comprehensions because
ifilterfalse is not part of python 3.  Also changed some lists to sets
for faster lookup.

Refer to #256.
2016-03-19 15:46:31 -07:00
Eklavya Sharma 186efc6a6d Handle unicode properly in camo.
In Bugdown's InlineHttpsProcessor.run, hex_encoded_url was not being
decoded to utf-8. This was causing problems in python 3.

Refer to #256.
2016-03-19 15:46:07 -07:00
Tim Abbott 1396eb7022 Fix Tornado memory leak of handler objects.
In 2ea0daab19, handlers were moved to
being tracked via the handlers_by_id dict, but nothing cleared this
dict, resulting in every handler object being leaked.  Since a Tornado
process uses a different handler object for every request, this
resulted in a significant memory leak.  We fix this by clearing the
handlers_by_id dict in the two code paths that would result in a
Tornado handler being de-allocated: the exception codepath and the
handler disconnect codepath.

Fixes #463.
2016-03-17 18:33:59 -07:00
Eklavya Sharma c59185e119 Apply Python 3 futurize transform libfuturize.fixes.fix_print_with_import
Refer #256
2016-03-10 22:02:17 -08:00
Tim Abbott df0d2a726d python3: Add missing utf-8 encoding/decoding in various places. 2016-03-08 09:14:15 -08:00
Tim Abbott a46647a87a python3: Mark certain strings as unicode strings.
This is required in Python 3 since these strings are combined with
other unicode strings.
2016-03-08 09:14:11 -08:00
Reid Barton 9735025167 Refactor logic around restricted_to_domain.
Add a function email_allowed_for_realm that checks whether a user with
given email is allowed to join a given realm (either because the email
has the right domain, or because the realm is open), and use it
whenever deciding whether to allow adding a user to a realm.

This commit is not intended to change any behavior, except in one case
where the Zulip realm's domain was not being converted to lowercase.
2016-02-07 10:54:52 -05:00
Tim Abbott 3469fd4bb2 Fix last remaining use of file() -> open(). 2016-02-03 19:31:46 -08:00
Tim Abbott 3475a5c1ed Fix test_runner.py fast_test_only return type. 2016-02-03 19:29:44 -08:00
Tim Abbott 693b9110df Fix weird import of get_user_profile_by_email from decorator.py. 2016-02-03 19:29:44 -08:00
Tim Abbott 23705f4f16 Remove duplicate self._log_data initialization. 2016-02-03 19:29:07 -08:00
Tim Abbott df1670ef59 Fix various float initialization to use 0.0 instead of 0.
This is needed to type-check these values.
2016-02-03 19:29:07 -08:00
Tim Abbott fc02ea9f67 do_add_default_stream: Fix return value if stream exists.
Discovered using mypy static type checker.
2016-02-03 19:28:48 -08:00
Tim Abbott e6e2584c5a test_runner: Cleanup fast_tests_only types. 2016-02-03 19:25:19 -08:00
Tim Abbott ee6062691a Fix missing None in check_none_or return. 2016-02-03 19:25:18 -08:00
Tim Abbott f03bfc5816 Fix missing prefix cache error output. 2016-02-03 19:25:18 -08:00
Tim Abbott 8654b57c7b bugdown: Move definition of current_node above set_text function using it. 2016-02-03 19:25:18 -08:00
Tim Abbott 8dcdb1d8a8 actions: Remove duplicate import of RealmFilter.
Apparently we were importing it twice in the same import statement.

Discovered using mypy.
2016-02-03 19:25:17 -08:00
Tim Abbott e9f39922a0 notify_subscriptions_*: Fix use of leaked stream variable.
While I believe this actually produced correct output since users are
always subscribed to streams within their realm, this code was
definitely wrong.

Discovered using the mypy type-checking tool.
2016-02-03 19:25:17 -08:00
Tim Abbott aad3bff193 Harden style rule for % comprehensions and fix existing errors. 2016-02-02 23:08:19 -08: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 f5de149976 python3: specify explicit sorting algorithm for subscriptions. 2016-01-26 21:11:25 -08:00
Tim Abbott bd0918cd5a python3: Use zip from the six.moves package. 2016-01-26 21:11:24 -08:00
Tim Abbott 757e89260e Migrate use of StringIO to Python 2+3 compatible six.moves.cStringIO.
And add a check for additional usage of the original StringIO module.
2016-01-26 21:09:43 -08:00
Tim Abbott 1f44417fc1 Switch to using Python 3 style division everywhere.
Also add testing for this to our Python 3 compatibility test suite.
2016-01-26 21:09:43 -08:00
Tim Abbott 6528b18ad3 Switch all urllib/urlparse usage to six.moves.urllib.
This provides Python 2+3 compatibility for our use of urllib.

Also add a test to avoid future regressions.
2016-01-26 21:09:43 -08:00
Tim Abbott 700055c194 Apply modernize transform libmodernize.fixes.fix_file.
This replaces use of file() with open() which is python 3 compatible,
and also adds it to our python 3 support test suite.
2016-01-26 21:09:42 -08:00
Tim Abbott 83dd51dcd6 Remove now-obsolete get_message_by_id_dbwarn transition code. 2016-01-26 21:05:11 -08:00
Tim Abbott eecd1513b3 Don't access/store full Client objects in Tornado queue servers.
At present, we only do a few simple checks on the client type inside
the event system, and this saves database/memcached queries.

Note that this preserves the structure of the marshalled name in
to_dict/from_dict as client_type to avoid an unnecessary migration.
2016-01-26 21:04:32 -08:00
Tim Abbott e3b6bfa3ca Remove code for pickle event queue store.
Since we've had the JSON store in all environments for some time, we
no longer need this legacy code.
2016-01-26 20:59:34 -08:00
Tim Abbott f6073d1708 Move HTTPResponse construction out of event_queue.py. 2016-01-26 20:59:19 -08:00
Tim Abbott a9bf4b4cc7 Store the client name for the current handler in ClientDescriptor. 2016-01-26 20:58:01 -08:00
Tim Abbott c7e3c3ce38 Look up client descriptors by handler_id.
Previously, client descriptors were referenced directly from the
handler object.  Once we split the Tornado process into separate queue
and connection servers, these will no longer be in the same process,
so we need to reference them by ID instead.
2016-01-26 20:57:25 -08:00
Tim Abbott ea6211c041 Allocate handler ids in AsyncDjangoHandler setup process. 2016-01-26 20:56:53 -08:00
Tim Abbott ae760a351e Move most of ClientDescriptor.finish_current_handler into library. 2016-01-26 20:56:08 -08:00
Tim Abbott 7df61fccbd Add user_profile_email field to ClientDescriptor. 2016-01-26 20:55:59 -08:00
Tim Abbott 2ea0daab19 Track Tornado handlers by uniquely assigned IDs rather than objects.
This is early preparation for splitting apart Tornado into a queue
server and a frontend server.
2016-01-26 20:55:41 -08:00
Tim Abbott 8b42fdd0d7 Move get_events logic into a backend function in event_queue.py.
This commit is somewhat ugly, but its purpose is to be early
preparation for splitting Tornado into a queue server and a frontend
server, and this code belongs, by and large, in the queue server
component.
2016-01-26 20:51:54 -08:00
Tim Abbott 5a6154c8ba test_helpers: Fetch streams from cache in subscribe_to_stream. 2016-01-26 20:41:01 -08:00
Tim Abbott f9791558e9 test_runner: Support continuing running tests after a failure. 2016-01-26 20:41:01 -08:00
Tim Abbott fdf708039b Disable empty-stream notifications for email gateway bot. 2016-01-23 11:37:52 -08:00
Alexander Trost 84f7a1f1ea Make rabbitmq, redis, and memcached configurable via user settings.py.
Previously these were hardcoded in zproject/settings.py to be accessed
on localhost.

[Modified by Tim Abbott to adjust comments and fix configure-rabbitmq]
2016-01-21 22:07:56 -08:00
Tim Abbott 6d29dd2884 Fix do_remove_default_stream handling of nonstandard input.
Previously:
* It wouldn't raise an exception if the stream didn't exist
* It didn't correctly handle being passed a stream name
that differed in case from the stream name in the database.
2016-01-09 22:52:35 -08:00
Tim Abbott 8099aa5470 Fix passing notifications_stream to set_default_streams.
Previously, this would throw an IntegrityError, because it had just
been added in the loop.
2016-01-09 22:52:35 -08:00
Tim Abbott bddf971554 alert_words: Only fetch and cache non-null alert word sets.
This removes from our cache a moderate amount of totally useless alert
word data corresponding to users who don't have any alert words.

Thanks to @dbiollo for the suggestion!
2016-01-09 20:01:38 -08:00
Tim Abbott 84114ab31f Simplify realm_user_count to do just do a database count() query.
Just doing the database query is more readable, and has about the same
performance as before in the case where active user dicts for the
realm are in cache (and is substantially better in the rare case that
this isn't in the cache).

Thanks to @dbiollo for the perf investigation and suggestion!
2016-01-09 20:01:37 -08:00
Tim Abbott 023f45190f rest_dispatch: Add support for using with websockets integration. 2015-12-12 18:14:08 -08:00
Tim Abbott a79e89b28f Cleanup remaining usage of % comprehensions without explicit tuples. 2015-12-05 15:29:42 -08:00
Tim Abbott 74853709a8 Rename NOTIFICATION_STREAM_NAME to clarify it's a default. 2015-12-05 14:14:44 -08:00
Tim Abbott 6b1494927d set_default_streams: Don't force-create notifications stream. 2015-12-05 14:14:44 -08:00
Tim Abbott f6f8f1fe36 Use new-style classes consistently for Python 3 support.
Also add the fixer for this to our list of fixers we check.
2015-11-04 08:01:52 -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 f7878a61e1 Apply Python 3 futurize transform libmodernize.fixes.fix_xrange_six. 2015-11-01 09:35:06 -08:00
Tim Abbott 5ffb4deb8d Apply Python 3 futurize transform libmodernize.fixes.fix_raise_six. 2015-11-01 09:35:05 -08:00
Tim Abbott cd6f8e9191 Apply Python 3 futurize transform libmodernize.fixes.fix_map. 2015-11-01 09:35:05 -08:00
Tim Abbott ffc900fe6e Apply Python 3 futurize transform libmodernize.fixes.fix_int_long_tuple. 2015-11-01 09:26:17 -08:00
Tim Abbott 2ea0663a4a Apply Python 3 futurize transform libmodernize.fixes.fix_imports_six. 2015-11-01 09:26:16 -08:00
Tim Abbott b3ac668779 Apply Python 3 futurize transform libmodernize.fixes.fix_filter. 2015-11-01 09:26:16 -08:00
Tim Abbott 651b011514 Apply Python 3 futurize transform libmodernize.fixes.fix_basestring. 2015-11-01 09:26:16 -08:00
Tim Abbott f3783fb4a1 Apply Python 3 futurize transform libfuturize.fixes.fix_print_with_import. 2015-11-01 09:26:16 -08:00
Tim Abbott 43abd83d1c Apply Python 3 futurize transform lib2to3.fixes.fix_ws_comma. 2015-11-01 09:26:14 -08:00
Tim Abbott daddf7c519 Apply Python 3 futurize transform lib2to3.fixes.fix_numliterals. 2015-11-01 09:25:49 -08:00
Tim Abbott 06f6ee6566 Apply Python 3 futurize transform lib2to3.fixes.fix_idioms. 2015-11-01 09:25:47 -08:00
Tim Abbott 5ce6a3c8f9 Apply Python 3 futurize transform lib2to3.fixes.fix_funcattrs. 2015-11-01 08:09:54 -08:00
Tim Abbott 8c34c40924 Apply Python 3 futurize transform lib2to3.fixes.fix_except. 2015-11-01 08:08:33 -08:00
Kara McNair a8e5755c7b Add tests for processing emailed-in stream messages (success & fail)
Prior to adding reply-to-missed-message-email functionality, adding
automated tests for simpler case - incoming stream messages. Added
to new file test_email_mirror.py.
Also removed the "if not body" code from process_stream_message that
will never run because of an upstream ZulipEmailForwardError exception.
2015-10-31 17:26:23 -07:00
Tim Abbott a36ac151ef Fix newly invited users receiving private stream history.
Also add a test to avoid this regressing in the future.

Fixes #230.
2015-10-26 23:36:37 -07:00
Steven Oud d5435fad1d Consistently use /usr/bin/env python2.7 in shebangs and commands. 2015-10-21 22:58:21 +00:00
Tim Abbott 71a06d58de Convert uses of Realm.objects.get() to get_realm().
get_realm is better in two key ways:
* It uses memcached to fetch the data from the cache and thus is faster.
* It does a case-insensitive query and thus is more safe.
2015-10-15 09:16:58 -04:00
Tim Abbott 51ed5028dc Remove unnecessary get_realm_name function. 2015-10-15 09:16:58 -04:00
Tim Abbott 90e61d3b61 Call process_new_human_user consistently when creating new users.
Previously we only did this when new human users were created via the
login process, which meant the management command to create a user did
not add the user to default streams (for example) and any future code
that might want to register a new Zulip user (such as the LDAP
integration) would need to import views/__init__.py in order to
properly set this up.
2015-10-15 09:16:58 -04:00
Tim Abbott 355e1bbd94 Move process_new_human_user and helpers from views to actions.py. 2015-10-15 09:16:58 -04:00
Kara McNair d72f75a7e1 email-mirror: Support missed message email token string format.
The do_send_missedmessage_events_reply_in_zulip function in the email
mirror didn't support EMAIL_GATEWAY_PATTERN that wasn't of the form
%s@example.com (which resulted in replies to missed message emails failing
to be parsed).
2015-10-14 16:02:15 -04:00
Darren Worrall 8b002040e0 Correct twitter library in requirements.
This also requires updating the required version of oauthlib; previously an
appropriate version was being installed only because it was a dependency of
the wrong twitter library.

This only affects development environments and/or hand-built
installations relying on the contents of requirements.txt.

To fix existing environments, the incorrect api needs to be explicitly
removed with `pip uninstall twitter`.

Fixes #86.
2015-09-30 13:49:33 -07:00
Darren Worrall bec3c0943a Fix validation that twitter creds are present.
They are looked up as secrets which initialize to `None`, but the code
was checking for empty strings.

This, along with #80, fixes #81.
2015-09-30 09:27:37 -07:00
Tim Abbott 3770142635 Revert "Host "preview failed" image locally."
This reverts commit 39f2908a32c0276b1d87ecedc876c71dd35a9b2f.

We're not including the preview_fail.png image in the release.

(imported from commit 2de1451de2f9b1727fc3a7e64c380b71c0f2caa8)
2015-09-25 00:44:20 -07:00
Tim Abbott b68d116e3a Remove old is_super_user helper functions.
(imported from commit 85655ea9369f5dc309f6f687bac578924571c9ee)
2015-09-20 11:13:20 -07:00
Tim Abbott 858d0a984b Move API super users configuration into the database.
(imported from commit 3cc702f93e7252b42930dba4bde93a915b6dbf44)
2015-09-20 11:13:20 -07:00
Tim Abbott 80a8725a03 Remove certain hardcoded email addresses in Zephyr mirroring.
(imported from commit 9fd492b5463f04741558687f27522d48a5dc795b)
2015-09-20 00:36:12 -07:00
Tim Abbott 36a9dc2cf7 Cleanup various minor Zanitization issues.
(imported from commit 5784eb5ac70706f72b05463354434a83a6e1beaa)
2015-09-20 00:25:38 -07:00
Tim Abbott e29c473077 Simplify analytics code to not filter certain low-interest users/realms.
(imported from commit 2dcf2e50b65c8b96d893cbe7dcdbbe652e6a90ff)
2015-09-19 23:42:28 -07:00
David Roe 3ac95ddc1a Add UserProfile flag to control whether we have a left side userlist.
Previously this was hardcoded for a single customer.

(imported from commit a6b7095050aa10cef976541505d9b09a35453f48)
2015-09-19 23:22:59 -07:00
Tim Abbott a59e41b5ee Simplify twenty-four-hour time logic to be more generic.
(imported from commit bda4972b32b17a36518eddef701748f3a548e376)
2015-09-19 23:22:26 -07:00
Tim Abbott 930c64df8a Move zulip.com-related statsd configuration out of main settings.py.
This also removes the convenient way to run statsd in the Dev VM,
because we don't anticipate anyone doing that.  It's just 2 lines of
config to configure it anyway:

STATSD_HOST = 'localhost'
STATSD_PREFIX = 'user'

(imported from commit 5b09422ee0e956bc7f336dd1e575634380b8bfa2)
2015-08-22 13:49:43 -07:00
Tim Abbott 83a653efce Change semantics of ZULIP_COM to include ZULIP_COM_STAGING machines.
(imported from commit 2e84c756b4ac41c13d619ab6ceb99e347d1f48cb)
2015-08-21 10:41:14 -07:00
Tim Abbott d0afb75619 Clarify documentation for SMTP delivery code.
(imported from commit 3b13f39fd56e9c381201911479c1326883c38445)
2015-08-21 10:33:36 -07:00
David Roe 3f7cb34b00 enterprise => voyager
(imported from commit 04be792bb480d5e5db1c91d296d1000cf1682571)
2015-08-21 10:33:35 -07:00
David Roe edf7e732a2 ENTERPRISE => VOYAGER.
(imported from commit 4f8080b9f506a87ca40bef32e39de5218cba916a)
2015-08-21 10:33:35 -07:00
David Roe d702ddb3cf DEPLOYED => PRODUCTION
(imported from commit a7d365c07916c5103fc721c712db94f9af977640)
2015-08-21 10:33:35 -07:00
David Roe 8778c4726a Add settings.DEVELOPMENT as a complement of settings.DEPLOYED.
(imported from commit 0437140d9fee7eec7b28abe583cfe8cde3e07c21)
2015-08-21 10:33:35 -07:00
David Roe 24f6743288 Eliminate TESTING_DEPLOYED.
(imported from commit 477d8b7a15f703df1e10ae5682e02fea5ce040e4)
2015-08-21 10:33:35 -07:00
Reid Barton ecc07333af Django 1.8 compatibility: miscellaneous changes
(imported from commit 086fac44cbdce1986a07e2ade00412dd538b4f23)
2015-08-20 23:15:45 -07:00
Reid Barton 0aab583bb1 Django 1.8 compatibility: transactions
- autocommit is now the default
- commit_on_success is now atomic

(imported from commit b6166ca666ff23d34f2871ca365ce3ec66b0fa86)
2015-08-20 23:15:45 -07:00
Reid Barton 9db521a931 Django 1.8 compatibility: extracting the user from a session
django commit 596564e80808 stores the user id in the session as a
string, which broke our code that extracts the user id and compares
it to the id of a UserProfile object.

(imported from commit 99defd7fea96553550fa19e0b2f3e91a1baac123)
2015-08-20 23:15:45 -07:00
Reid Barton 9ded218950 Django 1.7 compatibility: miscellaneous changes
(imported from commit 1f63d936c3d195acd033bb42fddacd240af3889b)
2015-08-20 23:01:26 -07:00
Yoyo Zhou ef320c6e95 Remove Redis remote authentication feature.
We can add it back later but for now we can just stick with localhost
since that's what most people will want.

(imported from commit c5fe524282219dc62a0670f569c0cb6af04be339)
2015-08-20 21:58:59 -07:00
David Roe 13f3b448e5 Kill Embed.ly integration.
(imported from commit dfe42a26e57100108c3c50298041bd520e0d8b1b)
2015-08-20 19:46:48 -07:00
Anders Kaseorg 5c6cd40fe7 recipient_for_emails: Fix type error
Fixes
[
  File "/srv/zulip/zerver/lib/actions.py", line 605, in recipient_for_emails
    if not (normalized_emails & admin_realm_admin_emails or normalized_emails & settings.CROSS_REALM_BOT_EMAILS):
TypeError: unsupported operand type(s) for &: 'set' and 'list'

(imported from commit f39a95dad7b3207e9188fc03926cd116061ef3f3)
2015-08-20 18:40:31 -07:00
David Roe 3515a69e43 Remove public_streams_disabled.
(imported from commit 1d0c8db92bf8e4c44bd1c96063acfd6eea74925c)
2015-08-20 18:12:53 -07:00
Tim Abbott 1880e96a22 Fix tests broken by twenty-four-hour-time feature.
(imported from commit 4f6215b303de8e27323141f687e046048f1456b5)
2015-08-20 17:59:16 -07:00
Kate Buckner 4d0f7c7ea4 Add a user-visible setting for 24-hour time display.
(imported from commit d934824fd6b72e64a455aac9ff4585b262145f02)
2015-08-20 17:33:16 -07:00
David Roe bfa70675cb Remove notify_for_streams_by_default.
(imported from commit 9963c97ffec82fe7cf2921bd51422545c29a8915)
2015-08-20 17:33:16 -07:00
acrefoot 0a6bb975c3 Replace settings.OG_ZULIPER_EMAILS with database lookups
Also renames the OG_ZULIPER_EMAILS to CROSS_REALM_BOT_EMAILS

(imported from commit a9e0ccebbd6b37376e535600670ad493dc8de7e1)
2015-08-20 17:20:41 -07:00
David Roe 8cb7b759c6 Add tests for new realm properties, fix revealed typo.
(imported from commit 49ffcf7edc64c2dbc3cf41ed64222390072c2e88)
2015-08-20 15:29:46 -07:00
David Roe 5b7f3466ba Add feature where only admins can invite new users.
This is controlled through the admin tab and a new field in the Realms table.

(imported from commit e78a6f48160e2a1bbc68d278beb726fe31515266)
2015-08-20 15:29:46 -07:00
David Roe 472898cfc6 Allow adding users to realms more easily in Dev VM.
Include new field on Realm to control whether e-mail invitations are required
separately from whether the e-mail domain must match.
Allow control of these fields from admin panel.
Update logic in registration page to use these fields.

(imported from commit edc7f0a4c43b57361d9349e258ad4f217b426f88)
2015-08-19 22:24:53 -07:00
Yoyo Zhou 5f74e6e76d Fix a lint warning in notifications.py caught by newer pyflakes (0.9.1)
zerver/lib/notifications.py:353: list comprehension redefines 'msg' from line 336

(imported from commit 094a21616f8fe7ffe05719c6de6449ade5c43517)
2015-08-19 11:43:49 -07:00
Luke Faraone 494d02cc35 Skip S3 write/read test cases
(imported from commit 838c9a5245b45fc9082f753fe6756f270c7378a7)
2015-08-16 16:45:15 -07:00
acrefoot c545a42a67 fall back to debugger if one of the test modules has an importerror
(imported from commit 856415f91dee53c72511e68f710a952fbe1a5f2e)
2015-07-30 21:08:13 -03:00
Jason Michalski 802a3dd357 Enable missed message notifications for zulip.com
Also increase the number of messages sent as context from 5 to 10 and
look up to 15 minutes in to the past for context.

(imported from commit bfaed9bcff1ee2047fc3b7a63acf93cd2d47cc7d)
2015-02-20 21:13:36 -05:00
Leo Franchi 0ae8e28635 Exit without exception if this APNS attempt has no connection
(imported from commit bbdd9f3e11946739459f34b2580e4a7371b158a0)
2015-02-11 07:20:51 +00:00
Leo Franchi d865732e0d Maintain two APNS connections and send correct notifications to each
Now we have 2 different Zulip apps out there, and they are signed with
two certs: Zulip and Dropbox. The Dropbox-signed apps are going to need
to be sent APNS notifications from the appropriate APNS connection

(imported from commit 6db50c5811847db4f08e5c997c7bbb4b46cfc462)
2015-02-11 06:57:25 +00:00
Jason Michalski 1eebcb472d Only allow users in the OG zuliper list to send cross realm PMs
Changes from allowing all of the zulip realms to a whitelist of users.

(imported from commit 5ad2db9a62b430ef2c9d867e4afdf661b11ae96a)
2015-01-30 23:39:47 -08:00
Tim Abbott 4f1388706c Disable digests and Missed Message notifications for internal realm.
(imported from commit 24a25bcf6653c674ac8a34324a4674e438f0af38)
2015-02-05 18:40:13 -08:00
Tim Abbott 1dbe00f164 Clean up indentation in do_send_messagemessage_events.
(imported from commit 010f0087693b1cf56bff380737e0070f476ca61a)
2015-02-05 18:40:13 -08:00
Leo Franchi a5063cf046 Dropbox domain is zulip.com
(imported from commit 73e9196783eaba7c62f5668e373bb1b5d372663e)
2015-02-05 15:30:08 -08:00
Steve Howell 6b1adf11f7 Disable stream desktop notifications for new Dropbox users.
(imported from commit 42deed48a2d475912041829a700fea4217868e9e)
2014-10-06 15:27:55 -07:00
Jason Michalski 718a6ea697 Fix the message count in missed message email
Missed message email were including the context messages in the number
of messages you were mentioned in.

(imported from commit 1749c5d272d2e17d6e28456ace932f80715103a3)
2014-10-06 15:27:54 -07:00
Jason Michalski 23ef278d29 Allow replying to missed PM emails on the zulip.com realm
* Fixes a few bugs with missed message address for PMs and huddles.
* Uses missed message address for all missed message reply-to headers on
  the zulip.com realm.

(imported from commit 61dd09386e1bbdf9a5096e2400984d31e73a5b74)
2014-10-06 15:27:54 -07:00
Jason Michalski 0726ec5931 Fix a bug when uses_left starts out larger than 1
(imported from commit cc08b63912c3188eeddbeee7ae73ae73143ec6ab)
2014-10-06 15:27:54 -07:00
Jason Michalski 2a5ec20295 Add support for one time use email address
The one time use address are a unique token which maps to stored stated
in redis. We store the user_id, recipient_id, and subject. When an email
is received at this address it is sent to the stored recipient by the
stored user. Anyone with this address can send a single message as this
user.

(imported from commit 4219417bdc30c033a6cf7a0c7c0939f7d0308144)
2014-10-06 15:27:54 -07:00
Jason Michalski 52944622f8 Split missed message emails by recipient
Send a different missed message email for each recipient. This allows us
to set a different reply to address for each one. PMs and huddles use
the existing logic, replies will be sent to all parties via email.
Missed @-mention emails will have the reply to address set to the
stream's email address.

(imported from commit bfb7cf7c1382adbf3720caa74cbb927c10dea267)
2014-10-06 15:27:53 -07:00
Waseem Daher 569abda653 Host "preview failed" image locally.
Who knows when this Cloudfront URL will stop working!

(imported from commit 39f2908a32c0276b1d87ecedc876c71dd35a9b2f)
2014-07-29 21:46:35 -07:00
Paul Ruan 12cb8ceae0 Time out when waiting for OpenGraph links that take too long.
One common place that this happens (for us) is on a local
Dropbox .dev.corp.dropbox.com instance, which can't be reached
by the Zulip servers.

This commit also:
* Fixes the test suite
* Properly previews /photos/ links

(imported from commit b4788b6236e7a9d390e1efc4673be34d9ba5e091)
2014-07-29 21:46:35 -07:00
Jason Michalski 94ec1f3741 Better previews for dropbox shmodel.
Getting previews for docs using open-graph protocol images.

(imported from commit 11a9b446eeb5786fdbf536681a100f43ad6db978)
2014-07-29 21:46:34 -07:00
Luke Faraone 5147b52267 Return correct OPTIONS in rest_dispatch
(imported from commit 095175cad4df982d2bf5603f3b927a3aa6d7f41f)
2014-07-29 21:46:34 -07:00
Waseem Daher a54d50ab2d Initial steps towards whitelabeling new realms.
Truthfully, the actual way to do this is going to be a bit
more involved and also involves changing Realm.NOTIFICATION_STREAM_NAME,
probably on a realm-by-realm basis.

(imported from commit b6a05849d215e07ee6716d116ff5e2c819d5b4be)
2014-07-29 21:46:34 -07:00
Jason Michalski 710a802f49 Add context to at mention missed messages
When you are at mentioned in a stream we will now send you up to the
last five messages which were sent in the past 5 minutes on the same
topic and stream.

(imported from commit 6df6c1cf868722a7bf76e54710e38741a7ac8f31)
2014-07-15 20:21:28 -07:00
Tolga Tezel 8b1199ee35 Add support for creating users with a specific ID.
(imported from commit 9a3438924cab8477a9c2494af1b5c2d32783e71c)
2014-05-07 14:06:59 -07:00
Luke Faraone 8f8b2519ea Redirect legacy URLs to their new secure location.
URLs with a realm of "unk" will be queried against the new bucket to
determine the relevant realm of the uploading user.

(imported from commit 5d39801951face3cc33c46a61246ba434862a808)
2014-05-05 20:26:29 -07:00
Tim Abbott 8b74a3e052 Remove unauthenticated file upload support from Zulip.
(imported from commit 97262590ac5ad56c18f415fa1c777510aed2baeb)
2014-05-05 16:14:09 -07:00
Tim Abbott f7535a0a1b Fix traceback sending bot messages to invite-only stream.
(imported from commit b9af67e87d8b7d52bddb8fa576af8fe9326ba13c)
2014-05-02 15:49:50 -07:00
Tim Abbott 0494e40c39 Merge zerver/tornado_callbacks.py into zerver/lib/event_queue.py.
It had stopped being a coherently distinct component a while ago.

(imported from commit 0617957bcfe8dcaf69143c88a96ddd51ecb31a98)
2014-04-23 17:22:31 -07:00
Luke Faraone 0a1d142d69 Refer to correct settings variable in email_mirror.py
(imported from commit c4e8b9ef417d8ba3c4db9692f4720b1cc1dc17a0)
2014-03-18 23:37:19 -04:00
Luke Faraone e6bb683922 Suppress presence changes to IDLE until timeout
This way if two browsers are disagreeing about your active status, the
active one wins. The active browser continues to update your timestamp,
and the idle browser's changes are discarded until the timestamp on your
active status expires.

(imported from commit dc29e013d045c4b72793097f611ba6802c58e57a)
2014-03-17 14:27:20 -04:00
Tim Abbott 400e355a2f Fix passing string as user_profile to upload_message_image.
(imported from commit b4841ef30527da6856482899d2e709cd528ff181)
2014-03-14 20:48:56 -04:00
Steve Howell d2f773a99d Handle empty Message table in act_on_message_ranges.
(imported from commit 609b0f531c4af23ddb6f3e5760dc9d251f1a4d3d)
2014-03-14 20:48:44 -04:00
Steve Howell fa37ac1d73 Add act_on_message_ranges() migration helper.
(imported from commit 9e6567c1a12a7d8e447ed80ee08723376eaee6fe)
2014-03-12 21:15:23 -04:00
Steve Howell da66220524 Add propagate_mode to event for topic updates.
(imported from commit c5bd140a46db5b6bc4164c21bcb698776fb0d786)
2014-03-12 21:15:21 -04:00
Steve Howell 9648fd1f9a Add stream_id to event for topic updates.
(imported from commit 2c0ff291672a2576e5812d8c3abdb71256ada61f)
2014-03-12 21:15:21 -04:00
Luke Faraone f4196ed6ef Don't allow sending messages to deactivated users or realms
We still don't show this in the frontend, aside from our usual "Not
delivered" message that we also show when you send to a non-existent
user.

Addresses #2349

(imported from commit 2f348b15a4d539987ddbcccbbf40e2be87c1f92d)
2014-03-11 15:11:53 -04:00
Waseem Daher ef23a4efe4 Disable authed uploads for zulip.com.
(imported from commit 3c432e730005e4c8404245c974b53c5a49fd4c9d)
2014-03-11 13:06:19 -04:00
Zev Benjamin eda05d23bf Optimize get_occupied_streams
In a test run with a hand-constructed query, this sped up the query time from
280ms to 50ms.

(imported from commit 8cbe199ca50a487491d13d6d6ef940ea668c1038)
2014-03-11 13:06:15 -04:00
Steve Howell 8f37c3f5fd Tolerate spaces after language in markdown fences.
See #2357.  We now support `~~~ .py ` with that trailing space.

Note that the test coverage is Python-side only due to
bugdown_matches_marked being set to false, since we don't yet
support language syntax on the client side.

(imported from commit ccd5fcb0eee01478d349161400103480678d7486)
2014-03-06 10:15:20 -05:00
Waseem Daher a9f01e382a Switch streams page over to use consistent buttons.
(imported from commit c4d7f658f361a759a38951349e027ac3e279fe9b)
2014-03-05 17:23:23 -05:00
Leo Franchi 05d911b913 Allow auto-linked URLs to end with a !, without including the ! in the url
(imported from commit 26fbf8d8318dc32f31f94f366750521afab94ac5)
2014-03-05 15:22:05 -05:00
Jason Michalski 3f6e53db6e Add bot_data module that updated with events
(imported from commit b0bd714258132fc81db763d316a15f5a81b1f4ff)
2014-03-05 14:16:20 -05:00
Jason Michalski 86175e8627 Add events for bots disabling bots
(imported from commit 9de3410555a45038c31341b3857782ffc8246cf7)
2014-03-05 14:16:20 -05:00
Jason Michalski 0165da405f Add events for bot default_events_register_stream changes
(imported from commit 143ed5b110a7f3b37f145dcd3fbe9133a183c7ec)
2014-03-05 14:16:20 -05:00
Jason Michalski f66d864f45 Add event for bot default_sending_stream changes
(imported from commit 7a859cf9f51b6ec1bacb1e3b3cfa9da2c6fbf32f)
2014-03-05 14:16:20 -05:00
Jason Michalski b5ca2631e6 Add event for bot default_all_public_streams changes
(imported from commit f189fb6692cb8c833cc2a1951ad8a4695cc4c27f)
2014-03-05 14:16:20 -05:00
Jason Michalski 3772344e2d Add events for bot avatar_url changes
(imported from commit c058386ce5ef9d89165c44fd853808cfe1f625f4)
2014-03-05 14:16:20 -05:00
Jason Michalski 280575aff0 Refactor json_set_avatar and patch_bot_backend to use do_change_avatar_source
(imported from commit eba0ff8a5c4409ac01c710455fe200b28f953b56)
2014-03-05 14:16:20 -05:00
Jason Michalski c0d104c110 Add events for bot api_key changes
(imported from commit 44e4e374ee4951c4d984c009ef7af825985fabbf)
2014-03-05 14:16:20 -05:00
Jason Michalski 64ba85aa19 Refactor regenerate_api_key and regenerate_bot_api_key to use do_regenerate_api_key
(imported from commit 5c54e4771b6730a8ebe304f6b6e86722d28eca8d)
2014-03-05 14:16:20 -05:00
Jason Michalski b161f4cff9 Add events for bot full_name changes
(imported from commit 7a8945982a060b208c5459a2b3d130eb84a72922)
2014-03-05 14:16:19 -05:00
Jason Michalski c17ed8dc8c Add bots to page_params and send events on bot creation
(imported from commit ce418b4f056576d57f82d26af621473c730c12d8)
2014-03-05 14:16:19 -05:00
Jason Michalski 846dfd5105 Update patch bot API to support setting stream defaults
Adds APIs edit a bot's default_to_stream, default_events_register_stream
and default_all_public_streams.

(imported from commit c848a94b7932311143dad770c901d6688c936b6d)
2014-03-05 14:16:18 -05:00
Jason Michalski 50db83508b Add API support for setting defaults in the add bot API
Support setting default_to_stream, default_events_register_stream, and
default_all_public_streams during in the bot creation API.

(imported from commit bef484dd8be9f8aacd65a959594075aea8bdf271)
2014-03-05 14:16:18 -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
Jessica McKellar 25a9eae74b Enabled authed uploads for Bargain Bit.
(imported from commit f793b7ac41341384b914168a3fc5ed637d63a645)
2014-03-05 11:55:02 -05:00
Steve Howell eec12ff268 Calculate has_* fields before saving Messages
Before saving a Message object, call update_calculated_fields()
to set the has_attachment/has_image/has_link fields.

Note that the pre_save hook we added here does not get called
if you call bulk_create, hence the explicit call to
update_calculated_fields() in do_send_messages().

(imported from commit 1d60ae5908ef186aa5ff1e39277dbb2b765e60d4)
2014-03-04 11:00:26 -05:00
Zev Benjamin 814aed7cbe Send an event when a stream is created, is deleted, becomes occupied, or becomes vacant
A stream is vacant when it has no subscribers and occupied when it has at least
one subscriber.

We have a slightly odd model where stream creation is conflated with
subscription creation.  Streams are created by attempting to subscribe to a
stream that doesn't exist.  We also hide streams with no subscribers from users
to make it seem like they've gone away.  However, we can't actually remove those
streams because we want to preserve history.

This commit moves us towards a separation of these two concepts.  By sending
events for stream creation, occupation, vacancy, and deletion, we allow clients
to directly observe the global state of streams rather than indirectly observing
subscription information.  A more complete solution would involve adding a view
for explicitly creating streams without subscribing to them.

This commit does not handle the intricacies of invite-only streams.  We
currently simply do not send these events for invite-only streams.

(imported from commit 5430e5a5eecefafcdba4f5d4f9aa665556fcc559)
2014-03-03 17:30:58 -05:00
Zev Benjamin 5c44fa9a29 Move bulk of get_streams_backend to actions.py
(imported from commit 3601444a2aabd1c613db61d71e6bc9fd6b4984d5)
2014-03-03 17:30:57 -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
Jessica McKellar 816c0a4393 Add a validator for arguments that are of a variable type.
We'll need this to validate subscription properties, which can be
strings or booleans.

(imported from commit 2572e334cd04ffe05151cba266e15a0ea7ae21c5)
2014-03-03 16:08:33 -05:00
Jessica McKellar 66edc784f9 Generate and handle client-side events for global notification changes.
(imported from commit 40056e8ae284da27db0215e7d8320c8f7db2c52b)
2014-03-03 16:08:33 -05:00
Jessica McKellar 53021bf7d3 Pass per-stream notification settings between frontend and backend.
(imported from commit 42e9b80a4c55e0911d457991d53ce71ca31625bb)
2014-03-03 16:08:31 -05:00
Jessica McKellar c673b3b0b1 Pass global stream notification settings between frontend and backend.
(imported from commit 28ec021e8e5166d3b270c81c5a4ad543d2185aa5)
2014-03-03 16:08:30 -05:00
Zev Benjamin 0b29a2f53a migrate.py: Add function for conditionally creating an index
(imported from commit f0ca7cc83e334d4210d21d33afa2e0196172176e)
2014-03-01 12:33:41 -05:00
Zev Benjamin 230802ee22 migrate.py: Add multiple columns simultaneously
(imported from commit 6cd01fcce6a6e18ce57be6f4da1fd394120b1f99)
2014-03-01 12:33:41 -05:00
Steve Howell 61611a2dac Add zerver/lib/migrate.py
(imported from commit 612a791d05721fb633bb1992e5288adf951143c3)
2014-02-27 20:25:38 -05:00
Steve Howell 630187d91b Avoid glitches running single tests involving SqlAlchemy connections.
(imported from commit 90b34ead998e2daf9e73fff867c3efb78076f4e1)
2014-02-27 20:25:35 -05:00
Waseem Daher 243c327d0a Properly preview images from Dropbox photo albums.
Reported by jhurwitz (sorta).

(imported from commit 8ae4c5f7af86c5492842142b89be8cab1a2c3fae)
2014-02-27 20:25:35 -05:00
Luke Faraone 7658886b02 email_mirror: Use internal_send_message instead of the API
Previously, the email mirror queue worker used the API bindings to send
messages to Zulip, as if it were any other API client.

This is inefficient since we're running the worker inside the Django
context on a machine with database access; we can instead just use the
internal message-sending functions we use elsewhere. This also resolves
potential issues with SSL certificates, etc. that might occur when we
were previously making a HTTPS connection.

(imported from commit 6de8015829bec440f1af0199a2138828e86ed2a4)
2014-02-27 20:25:33 -05:00
Luke Faraone f304b93b91 Quote "/"s in stream/topic names for digest emails
Previously, digest emails provided links to Zulip that didn't correctly
encode "/" if it occurred in a stream name or topic. By explicitly
specifying «safe=""», we can request that urllib.quote escape such
slashes.

Closes trac #2294.

(imported from commit 2e6334672969d4cf4032d2ea5dc80091af96d672)
2014-02-27 20:25:30 -05:00
Leo Franchi 38a4011a52 Return the realm domain if the requesting client requests it
(imported from commit c8e6e388460931076ae3d12b0c5a5dde46b39ffa)
2014-02-20 10:57:35 -05:00
Steve Howell 8bae4d746d Remove unused json_to_list function.
(imported from commit 9da59ee4edd3c569f798710267db5400b9abdb30)
2014-02-18 14:24:04 -05:00
Steve Howell 4bc76b2d6d Handle more types of data in extract_recipients.
We now allow the list of recipients to be sent as a
comma-delimited string with optional JSON encoding.

(imported from commit e928b037bbd258348eb5b2ecca486d0bb77f593e)
2014-02-18 14:24:04 -05:00
Steve Howell 6edb758136 Add test_extract_recipients.
(imported from commit 13a5d1287fd489664c7f667d5b75a513f5f744c1)
2014-02-18 14:24:03 -05:00
Steve Howell 3d04f5f738 Use check_list instead of json_to_list.
(imported from commit 9ead12bc2a4744b94a747ca27054124aacde7ae4)
2014-02-18 13:02:08 -05:00
Jason Michalski fa285fd1a9 Use case insensitive matching when linkifying tweets
(imported from commit c8a897f05a79a2b23998ffe186c77a9f7af4ae7f)
2014-02-15 15:33:22 -05:00
Leo Franchi 54e24a5765 Disable push notifications regardless of idle status for zulip.com
(imported from commit a1a1d551b7bf1423ecb31cf6a230f59c888a8a82)
2014-02-14 13:35:27 -05:00
Luke Faraone 89eef10d44 Match alert words inside markup.
We now will match an alert word even if it is used at the boundry of
bolding, backtick escaping, or caret quoting.

Closes trac #2186.

(imported from commit 984bc63eb621772c95a01ca5c5bfeb190767f71f)
2014-02-13 17:14:54 -05:00
Luke Faraone 4ebc4a4ef1 Expand characters allowed after an alertword.
We now support .';[ before a word and ';]! after.

Closes trac #2283.

(imported from commit b3e3cb3d8d49a8e74d0b6a108c5ec73e9d9b5f32)
2014-02-13 17:14:53 -05:00
Leo Franchi e0efae4d59 Alias ZulipDesktop client to website
(imported from commit 91e549bbc67b9d9f5edf35522b608aa397547edd)
2014-02-13 08:28:08 -05:00
Leo Franchi 298af207f7 Don't send stream-does-not-exist emails for deactivated realms
(imported from commit d5a5fa18cdd24af46fc72d4dc57b784dcef0beb2)
2014-02-10 13:23:28 -05:00
Zev Benjamin 631783f3cd [manual] Use dedicated Redis server for staging
Before we deploy this commit, we must migrate the data from the staging redis
server to the new, dedicated redis server.  The steps for doing so are the
following:

* Remove the zulip::redis puppet class from staging's zulip.conf
* ssh once from staging to redis-staging.zulip.net so that the host key is known
* Create a tunnel from redis0.zulip.net to staging.zulip.net
  * zulip@redis0:~$ ssh -N -L 127.0.0.1:6380:127.0.0.1:6379 -o ServerAliveInterval=30 -o ServerAliveCountMax=3 staging.zulip.net
* Set the redis instance on redis0.zulip.net to replicate the one on staging.zulip.net
  * redis 127.0.0.1:6379> slaveof 127.0.0.1 6380
* Stop the app on staging
* Stop redis-server on staging
* Promote the redis server on redis0.zulip.net to a master
  * redis 127.0.0.1:6379> slaveof no one
* Do a puppet apply at this commit on staging (this will bring up the tunnel to redis0)
* Deploy this commit to staging (start the app on staging)
* Kill the tunnel from redis0.zulip.net to staging.zulip.net
* Uninstall redis-server on staging

The steps for migrating prod will be the same modulo s/staging/prod0/.

(imported from commit 546d258883ac299d65e896710edd0974b6bd60f8)
2014-02-10 13:23:28 -05:00
Zev Benjamin 6691789cce Add helper function for returning a Redis client
(imported from commit 47f87d388d24343ac6b631181a55287eb8cd4a6d)
2014-02-10 13:23:28 -05:00
Tim Abbott 4891da83ad Fix autolinkification in Zephyr mirrored content.
Apparently the "inline" treeprocessor is what runs the inline
patterns.  Also re-enable the rewriting-to-https support.

(imported from commit 2fde2c1f15217a784f26b16db25ee745f424f2f0)
2014-02-10 13:23:27 -05:00
Steve Howell 72ee636571 Use stream_id as key for subscription removals.
Have the server send down the stream's id for removal
events, and have the client use that id to look up the
stream in its internal data structures.  This sets the
stage for eventually just sending the stream id (and not
the stream name) down to clients, once all our clients
are ready to use the stream id.

(imported from commit 922516c98fb79ffad8ae7da0396646663ca54fd0)
2014-02-10 13:23:27 -05:00
Luke Faraone fe55127eee Override realm of uploading user when invoked via the email mirror
Here, we don't want to check the uploading users' realm when determining
message privacy, because that'll prevent non-Zulip users from having
email-mirror-uploaded images. Instead, we just pass along the target
realm for the message explicitly to upload_message_image()

(imported from commit 6891261552135b1f41ff9da55ffe963ee5000556)
2014-02-07 09:45:57 -08:00
Luke Faraone 1e87e7c5c1 Switch authed_upload_enabled to check for a realm, instead of a UP
This is always a realm setting anyway, and it'll make reuse easier.

(imported from commit c64e1901b60051608cee3cf9a6b3aef8630ae237)
2014-02-07 09:45:57 -08:00
Leo Franchi 8ad2ca15cd bugdown: Match up to 8 groups of nested parens
(imported from commit e3d61ec644fdb293322cab0a4449d8e1a27a513a)
2014-02-06 17:26:01 -05:00
Leo Franchi 1c332f5d6a Standardize on 'subscription' as event type name for subscription changes
Our overall guideline is the type names for events are singular, and the list of
events of that type are plural. 'subscriptions' was not following this guideline
and (potentially as a result) had a bug where it was impossible for clients to explicitly
subscribe to subscription change events properly.

(imported from commit 7b3162141fd673746e0489199966c29ea32ee876)
2014-02-06 17:07:38 -05:00
Steve Howell da858afacf Save on S3 bills by passing validate=False into conn.get_bucket().
(See the comments in the code for details.)

(imported from commit e518b9d89aca8a6358c826bf7e7f03381e0560f4)
2014-02-06 12:14:14 -05:00
Steve Howell 3a96686cbc Add stream_id to page_params.{subscriptions,unsubscribed}
This isn't used by the client yet, but it should be harmless.

(imported from commit e09ac65ca802f5cf16375b8a93d34e0dfbcb76b4)
2014-02-06 12:09:52 -05:00
Tim Abbott ca3430862c More correctly disable markdown processing for Zephyr mirrored messages.
(imported from commit 688eead11c329e93c649ea1633dbf56328b5587b)
2014-02-06 10:25:35 -05:00
Luke Faraone e8834c2a9b Modify email mirror regular expression to match messages sent to any zulip.net server
(imported from commit 733a2ff2586c6c4bbe6536a3c42973726c8adb14)
2014-02-05 17:30:11 -05:00
Steve Howell 7449079191 Validate schema of events in EventsRegisterTest.
For EventsRegisterTest that test updates to streams and
subscriptions, we now validate the events generated by
the actions under test conform to predicted schemas.

We define the schemas with help from the validators code
that is also sometimes used to validate incoming request
parameters for our views.

(imported from commit b4222b920a588e15cccee4a2349c074ca9697448)
2014-02-04 16:25:32 -05:00
Steve Howell 662459b9e1 Fix do_rename_stream to update the stream's email address.
This change also makes it so that the test_rename_stream()
test exercises the code path.  We need to subscribe the user
to the stream in order to generate events.

(imported from commit 77f965efbf5a766eb8de23486e303fa135b2e638)
2014-02-03 17:38:22 -05:00
Jessica McKellar ea934cf286 Add backend tests for group signups.
(imported from commit bbb415f40225e6fc16aa8d1edf0b95b37e09f751)
2014-01-31 17:12:10 -05:00
Luke Faraone abc0be9c8c email-mirror: Catch ValueError returned by decode_email_address
This indicates that we didn't get the right sort of email address passed to us.

(imported from commit 26881d537296ea3d21ac29ff1b67ab260f838e13)
2014-01-31 15:33:15 -05:00
Jessica McKellar 9b1090506e Add tests for admins unsubscribing principals.
(imported from commit a2599ddc55ccddde3d39cb125bb1d5079772c652)
2014-01-31 11:23:14 -05:00
Steve Howell 5acf8ac0b6 Split out zerver/test_messages.py.
(imported from commit 61c40418bad4628a8f98298587a0e0defa9302bd)
2014-01-31 11:22:49 -05:00
Jessica McKellar 00673534ba digest: log send failures and unsubscribe hard-bounce emails.
(imported from commit 3ffcc335d4d3ad3955da8981ff1129888fe681a4)
2014-01-31 10:57:31 -05:00
Steve Howell cbec4126c8 Order the sections of fetch_initial_state_data() alphabetically.
(imported from commit cef5471660df1bdacf7d5ea18c8c629aec3e4bf4)
2014-01-30 05:40:45 -05:00
Steve Howell 9a0aca6878 DRY event_types checks in fetch_initial_state_data().
(imported from commit 9eead1178fbcd95b61a5deb7b548485702a1056f)
2014-01-30 05:40:45 -05:00
Tim Abbott 7151af5119 Fix disabling of markdown for mit.edu.
(imported from commit 952456ddab8112bf62e6d17e29325c6d974be7a5)
2014-01-29 14:39:53 -05:00
Steve Howell 7dbebf4e05 Improve test-backend output (show module name).
We now show the module name (e.g. "tests or test_hooks") in the
test output.  This change also eliminates the intermediate use
of slashes in the test_name var, which was passed to
bounce_key_prefix_for_testing().

(imported from commit 58e73301037a0b07d7e437514c247f7cb559420e)
2014-01-29 14:28:55 -05:00
Steve Howell 233ce4360f Handle realm_name in fetch_initial_state_data/apply_events.
Instead of having home() set page_params.realm_name directly from
the user_profile object, have fetch_initial_state_data() set it.
This is more consistent with how we treat other data, and it protects
us against a race condition where realm name updates arrive during
the DB fetching.

(imported from commit 545e3bd73f150438126e3f941e9bebc7aa1d0614)
2014-01-29 13:37:58 -05:00
Jessica McKellar da3fc3fede Add tests for stream deletion.
(imported from commit bfe52c6c5be3fc36907071f9ff096cf74aa9fb22)
2014-01-29 13:09:50 -05:00
Jessica McKellar eeb8464f4d Don't expose deactivated streams to users through clients or API.
(imported from commit c32715255b3286f52fb313d35659f9357082603a)
2014-01-29 12:41:21 -05:00
Jessica McKellar ac06d8870f Make a deleted stream actually appear deleted from the perspective of users.
In particular, make the stream history inaccessible and free up the
name to be re-used.

(imported from commit 6063b7a484ed0ba0279a17d2b3e9a92b5ef1f762)
2014-01-29 12:41:20 -05:00
Jason Michalski de522029d5 Switch to DiscoverRunner from DjangoTestSuiteRunner
(imported from commit 77dd694b20509bfdc7327186e0524d686f0415f7)
2014-01-29 11:34:31 -05:00
Jason Michalski a028bda264 Allow up to three twitter previews per message
(imported from commit 566b786f9ac0582f15f8f77363f63932ee5ceec8)
2014-01-29 11:00:41 -05:00
Steve Howell 12c095fd4b Extract test_runner.py
The file test_runner.py has our subclass of DjangoTestSuiteRunner
and various methods that help it work.

(imported from commit 8eca39a7ed3f8312c986224a810d4951559e7a8b)
2014-01-29 10:55:59 -05:00
Steve Howell 1b987b0803 Add API for changing realm names.
(imported from commit 4bc117ae2ca4acb8896b45cd7058556317287ef8)
2014-01-29 10:16:57 -05:00
Steve Howell a8bf9dfaf2 Add event support to do_set_realm_name().
(imported from commit c0abac9867aa211bb03e20a5dc1378cf476619ce)
2014-01-29 10:16:56 -05:00
Steve Howell 912f96e7ec Rename update_stream_cache() to flush_stream().
(imported from commit c67844ef7feb1924ec495c4451e33b56b237c88a)
2014-01-28 17:40:01 -05:00
Steve Howell 1e948d2d51 Add do_set_realm_name/get_realm_name.
(imported from commit cf1cd9e1de1169f542e5f0690ef94a576dfd5663)
2014-01-28 17:40:01 -05:00
Steve Howell c5edb58cd4 Turn flush_realm() into a post-save hook for Realm.
(imported from commit 97e44b51e2b35b4b5b64b4008f6a8d3585a26e33)
2014-01-28 17:40:01 -05:00
Steve Howell 57030f53cc Use cache_set_many() in the flush_realm() code path.
The function update_user_profile_caches now operates on a list
of user_profiles, so callers like flush_realm() can benefit from
having a single cache_set_many() call.  This slightly complicates
the call from flush_user_profile().

(imported from commit e064871d849b873c6ca388f00d4f7afaba1bf222)
2014-01-28 17:40:01 -05:00
Steve Howell bbafd1dda8 Have flush_realm() make O(1) cache_delete() calls in a couple places.
For the realm-wide caches of active user dicts and alert words, just
make a single call to cache_delete() when you are deactivating a
realm.  Before this change, we were doing O(N) cache_deletes as
part of the code path through flush_user_profile().  Now we just
call update_user_profile_caches() directly to clear the user_profile
caches.

This change also sets us up to turn flush_realm() into a post-save hook.

(imported from commit 699b4ea226ae15fc8c402cb4bc64ff6bdc041fc2)
2014-01-28 17:40:01 -05:00
Steve Howell 0eed5d20d2 Create cache.flush_realm() and call it from do_deactivate_realm().
This is a slight behavior change, as we now flush user_profile
caches for bots as well as humans.

(imported from commit 24c72c44d851ee4c66a67a4728cd6c548faeedcd)
2014-01-28 17:40:00 -05:00
Steve Howell dbc1172a20 Extract update_user_profile_caches().
This function updates all the user_profile-related caches
that are keyed on a per-user basis.

(This had some test coverage already.)

(imported from commit 37979400514a7b46a6dcb7e36665b0fee2f3c525)
2014-01-28 17:40:00 -05:00
Steve Howell 3776d11c3a Rename update_user_profile_cache() to flush_user_profile().
(imported from commit 1fddb8b8dfe7943ace70c51d762eeae2ee1203a0)
2014-01-28 17:40:00 -05:00
Jason Michalski 05e00575bb Only send stream update events to clients that need them
Stream name and descriptions updates were being sent to all of the
active users on a realm. They are now only send to users who would have
information about that stream.

(imported from commit 2621ee8029f7356bf44ec493d7b5361bd546a8f5)
2014-01-28 17:12:15 -05:00
Steve Howell 1dd674c7ae Make import statements take less vertical space.
(imported from commit 4d5901491d6c8c21fe045ac9751bc80613f94a59)
2014-01-28 17:04:51 -05:00
Steve Howell 80af0b8134 Move AuthedTestCase to test_helpers.py
(imported from commit bdaf63c5ed4e8d7c19e9c19f79151e8e7885c53e)
2014-01-28 17:04:51 -05:00
Steve Howell a8f2ecf48c Move context managers to zerver/lib/test_helpers.py
(imported from commit f57678fcb68aecdbb70ad86cd02cc5441695aaf5)
2014-01-28 17:04:50 -05:00
Steve Howell 8aaf1cf8c2 Add API for removing default streams from a realm.
(imported from commit 06433126e31b372dff8a23eb8bbea14515138c85)
2014-01-28 14:30:37 -05:00
Steve Howell af9a1e967f Add API for adding default streams to a realm.
(imported from commit 0f48f722dd618c0d054aafdf3d931ef014a5c3ee)
2014-01-28 14:30:02 -05:00
Steve Howell 4cf677eb6d Add do_remove_default_stream().
(imported from commit 559dcd93ca43f4ffba58119fe429df3f6843fd63)
2014-01-28 14:28:51 -05:00
Steve Howell 4ed661ca71 Add do_add_default_stream().
(imported from commit 34c96bdc3f5c2f7f119d2efe1606316878d34d03)
2014-01-28 14:28:51 -05:00
Steve Howell af00f4609a Extract get_default_streams_for_realm().
(imported from commit 6ef41615eb660fd161bfd53de09fea56266ddd2d)
2014-01-28 14:28:50 -05:00
Tim Abbott 3fddc11cc2 Process message events more similarly to how other events are handled.
(imported from commit 5ebcd7a10fe54a8ecafb9550348a1e0418d4cbda)
2014-01-28 13:42:50 -05:00
Tim Abbott 1cc3a6a903 Switch update_message to a generic event type.
(imported from commit db3c4d2326727ca05d25ab43ebc061d3e5cd0630)
2014-01-28 11:01:30 -05:00
Tim Abbott 167b883c38 Clean up the update_pointer tornado notification code path.
(imported from commit 94997dea54e6cc8e5b5a314a95d6114773462608)
2014-01-28 11:01:30 -05:00
Tim Abbott 0507b1bb06 Split out do_update_pointer from update_pointer_backend.
(imported from commit 25da1b324a9170677b0f6fc2e29841d6f2af9dec)
2014-01-28 11:01:29 -05:00
Tim Abbott 5ccb8b1bea Add tornado_callbacks.send_event with clean API for sending events.
(imported from commit 07209a1744ac9372273858a3e69e8a2fd9e06e06)
2014-01-28 11:01:29 -05:00
Tim Abbott 3bcba79e77 Send message data to Tornado via rabbitmq instead of memcached.
This is a lot simpler and eliminates a possible failure mode in the
data transfer path.

(imported from commit 19308d2715bbd12dc9385234f1d9156f91bdfae0)
2014-01-28 11:01:29 -05:00
Leo Franchi 0917a27b79 Document realm filter regexp oddities
(imported from commit 987d8ea679f40c31f2fe2280b6d585f82b20e606)
2014-01-27 13:43:55 -05:00
Leo Franchi 883157893c Use a UserMessage flag to indicate /me messages
(imported from commit ea503b0d3eb6e90230c0859be96ede60faf5c2bd)
2014-01-27 12:07:48 -05:00
Steve Howell 6fff91493c Fix bug in apply_events() for removing subscribers.
To mutate the state for removing subscribers, the previous
code was essentially adding in event['subscriptions'] to
state['unsubscribed'], but that was a naive approach, since
the event object only has the name of the subscriber, and not
the full subscription info.

We instead effectively copy records over from state['subscriptions']
to state['unsubscribed'], and we also do surgery on the subscribers
that made me need to add the user_profile parameter to apply_events().

With the code apparently working now, I was able to remove the
match_except() test helper and use a more thorough matcher in
the test on do_remove_subscription().

Part of fixing the "remove" case was cleaning up the "add" case,
since they aren't quite symmetric opposites of each other, although
under this refactoring they now share the new name() helper.

(imported from commit 0deab67d0c7b08b3ad962493efae3762a835fd29)
2014-01-27 10:41:29 -05:00
Tim Abbott da90d63046 Split out zerver/lib/notifications.py from actions.py.
(imported from commit 784b82834ee4fcb4431e77f8fb1c526f8eec82ad)
2014-01-24 17:33:56 -05:00
Steve Howell 1d95812770 Add is_admin to page_params.
Because full_name and is_admin changes go through many similar,
generic codepaths, it is almost more work at this point to keep
is_admin out of page_params as it is to just put it in.  So
I put it in.  This should pave the path for showing admins in
the GUI.

This commit actually starting by my adding a test
that calling apply_events() with the notification you get
when calling do_change_is_admin() updates
state['realm_users'] to be similar to what you would get
out of fetch_initial_state_data().  We didn't have test coverage
there before.  Making that test pass forced my hand to
either add is_admin to page_params or to special-case
apply_events() not to update page_params with is_admin.  I
chose the former approach.

(imported from commit 1e49d59c66540014284529c29d5007224be6a0c6)
2014-01-24 16:34:12 -05:00