Commit Graph

598 Commits

Author SHA1 Message Date
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
Steve Howell 4ad8ad2b5a Extract get_realm_user_dicts() from fetch_initial_state_data().
(imported from commit 2f0f52d90eba22a4b72bd6173e60ab463482b7d6)
2014-01-24 16:34:12 -05:00
Jason Michalski 1f98c4f4ce Add support for updating the stream description
The stream description can now be updated, but the UI is not yet updated
on success.

(imported from commit f45e0a9d5138d828ae98d6d49645ab3ddc966704)
2014-01-24 14:47:44 -05:00
Jason Michalski 4104f00229 [schema] Add description to streams and display it
A description was added to the streams and it is now displayed on the
subscriptions page. It can not be set in the UI yet.

(imported from commit 81d08b65eee42dba87cd99dd5bd30106c4eb6c6a)
2014-01-24 14:47:44 -05:00
Luke Faraone 1c67d05e5f Handle duplicate GCM registrations by dropping the old ones.
While we're at it, lets comment up the function so I know what this is
doing next time :)

(imported from commit e745be75fcd6dbce9997e1d73464619fc8b73996)
2014-01-23 19:21:28 -05:00
Jessica McKellar ee7a1f0953 tutorial: add helpful in-app links and be consistent with realm welcome message.
(imported from commit 2057dbe2606d32721192021ed2046ed9f412d8a7)
2014-01-23 17:06:29 -05:00
Jessica McKellar 086eab8bb5 bugdown: support modal in-app links in messages.
(imported from commit 0e3c0ff61cf9a84bae81e37b0a6d79831dea9224)
2014-01-23 17:06:29 -05:00
Leo Franchi 56d9446c41 [socket] Use socket req ids that contain queue ids
(imported from commit 781eafe60bf117d79ce3a30deea02ec1e875060a)
2014-01-23 16:28:58 -05:00
Leo Franchi 7743aa191c Pass through local_id and sender_queue_id in non-rabbitmq case
(imported from commit 8989225a0943b39e45bd5debe405acb9768acc8c)
2014-01-23 16:28:58 -05:00
Steve Howell 2283aa52cb Use "stream" as our type for updates to Stream.name.
(imported from commit 2eedbff5fac77b9e654ba88900167048573e4056)
2014-01-23 13:27:11 -05:00
Steve Howell bc6da3717f Fix obscure bug with page_params.is_bot.
If a name change event arrived during the call to
fetch_initial_state_data(), we would call apply_events() to
update the data structure that eventually becomes page_params.
Our update code, instead of surgically updating the fields, was
just overwriting the record, which led to is_bot being taken
out of the record when only full_name was in the event.

Apart from fixing the "update" case to do the right thing,
this commit also does a bit of cleanup on the code handling
"realm_user" events to make it more generic in how it does
add/remove/update.  If we could standardize our events a bit
more, this could eventually lead to DRYing up some of the
apply_events() code.

(imported from commit 772e2fcd6a5605ccb6e8d1bc499b5f336934cf3c)
2014-01-23 13:01:04 -05:00
Steve Howell 3b12e63d8d Send notifications for is_admin changes.
(The client doesn't do anything with them yet.)

(imported from commit df2f406644fe271af53e32a6b3521752b6a1ac41)
2014-01-22 14:43:28 -05:00
Leo Franchi c0fdbf81cf Use the feedback connection for getting APNS feedback
(imported from commit d371188e0437606b3ff435ee9c005cee2849f6ae)
2014-01-22 13:50:15 -05:00
Leo Franchi 4dac0e7d37 Print out APNS tokens in b64 format for ease of use
(imported from commit d38eb1629a599681c42f1f8d817c90229b547516)
2014-01-22 11:59:02 -05:00
Leo Franchi 6903d87809 Retry on APNS failure / retry request
(imported from commit b9d1c414731de7a4ad5d3bc93c3dce1286cbdb38)
2014-01-22 11:59:02 -05:00
Leo Franchi c0d3b2fd89 Remove APNS tokens from our database if we get an invalid token notification
(imported from commit 5ec3c053684f9574a31103e7821309de883baa82)
2014-01-22 11:59:02 -05:00
Leo Franchi 226d894257 Prefix apple-specific APNS logs with APNS:
(imported from commit 2fa866b3a626c3e42f340bc68e8bc27aef6fd521)
2014-01-22 11:59:02 -05:00
Jason Michalski c30a411c10 Add custom markdown tag to render a stream subscribe button
When new streams are created we now send a message with a custom
markdown tag that renders a subscribe button.

(imported from commit 9dfba280b3b4ff4f32f6431ef9227867c8bf4b40)
2014-01-22 11:28:31 -05:00
Leo Franchi 669951b631 Send push notifications regardless of idle status for robinhood.io, zulip.com
(imported from commit 49d2c954f6537d28ef3f8ccad669c56430afdbde)
2014-01-21 14:48:57 -05:00
Jason Michalski 4c90392261 [schema] Add an per-user option to disable notification on new streams
Added a default_desktop_notifications boolean to userprofile with a UI
in Zulip Labs. This flag is used to default the notification flag on new
subscriptions.

(imported from commit a25223cc5ecf09980cf877991e25034bb3fd4046)
2014-01-16 20:13:34 -05:00
Jessica McKellar a1d128b6cb Flush memcached on a stream privacy change.
Otherwise uninvited users can join a stream recently turned
invite-only.

(imported from commit ab43bf3b856a0e3b71e6e06cee1519214b7763cd)
2014-01-15 17:13:56 -05:00
Waseem Daher 9eed2c50b9 email-mirror: Support '.' as an alternate for '+' (and bugfix).
Google Groups won't let you add an email address that has a '+' in it
as a member of a group, so we allow '.' as well.

This commit also fixes a current issue with email mirroring, where it
doesn't work if you had a + in the stream name.

This fixes Trac #2102.

(imported from commit 9a7a5f5d16087f6f74fb5308e170a6f04387599e)
2014-01-15 16:07:19 -05:00
Jason Michalski 60f878b45e Limit cross-realm private messages to zulip.com users
Cross-realm private messages are only used to respond to support
requests. So now cross-realm private messages are only allowed if
exactly two realms are in the private message and one of them is
zulip.com.

(imported from commit f01a2824e214682acb22a6995714a9d1b0d0c66f)
2014-01-15 16:07:19 -05:00
Luke Faraone 0b5036e0fb Let message recipient in process_message be passed as an argument.
(imported from commit cfcfb9edf748a35d279235ee11a05b1a00c934b5)
2014-01-15 16:07:18 -05:00
Zev Benjamin db23674749 Do query time tracking at the psycopg2 level instead of the Django level
This allows us to track the query time of SQLAlchemy and raw queries.

(imported from commit 818a4ee41786ffc57b80d7ed1cfba075f29b6ee5)
2014-01-14 11:47:12 -05:00
Tim Abbott e38ac2f9ac Index the presence data sent from Django to Tornado by ID.
(imported from commit 8ffb70562b49ba93c5b0927b34dc57a743d49564)
2014-01-13 16:54:06 -05:00
Tim Abbott e890f06c1c Move missedmessage hook checks on UserProfile settings to workers.
This does result in a few more rabbitmq events to be processed (though
a negligible number compared to what we already do), but it saves a
database query from inside Tornado whenever we occasionally have a
cache miss looking up the UserProfile, which is far more important.

(imported from commit a553a00a3004ba27bfb54ffbc3e9c9b170ebae4d)
2014-01-13 16:54:05 -05:00
Zev Benjamin 22ae828685 Support Tornado 3
The only thing that needed changing was our instrumented IOLoop.

(imported from commit 17833500f03949f45a546050a1f99675e9f6b1b5)
2014-01-10 21:39:06 -05:00
Steve Howell e832e937c5 Make emojis be 20px tall in missed message emails.
(imported from commit 687b099f19d69f41876571c08a0627f061067f86)
2014-01-10 21:39:05 -05:00
Steve Howell 1a679795e1 Flatten the code for build_message_payload.
(imported from commit b58c91468b36d33c163d4994b501eac796d10e8f)
2014-01-10 21:39:05 -05:00
Waseem Daher fe748f7633 Make Twitter preview look like other inline image previews.
(imported from commit ca4ff9146679a5348bf53d06e992972e9a4b628a)
2014-01-10 21:39:04 -05:00
Steve Howell 3e48b4fd95 Update mentioned flags after message edits.
(imported from commit 67886db571193a0f53cf72aa00af9e5e75729dc0)
2014-01-10 21:39:03 -05:00
Steve Howell 8d79606136 Update has_alert_word flag after message edits.
(imported from commit cad1b5646742506c1e84a42366fd58aaaf6dc17d)
2014-01-10 21:39:02 -05:00
Steve Howell 0326fa92b4 Send UserMessage flags for update_message events.
When we edit a message, send out UserMessage flags to the recipients.
This sets the stage for making sure that changes related to
user-specific alert words or mentions get sent out to users.

(imported from commit bce1de19acef44b5e106352f261203352ece02b9)
2014-01-10 21:39:02 -05:00
Jason Michalski 9e822403bb Linkify twitter media links
Image and video links in the twitter API are media and need to be
handed on separately. We also include a preview image if the media link
is a to a picture.

(imported from commit 2bd00d267e51b29ad0ba681195b2bfea9b991d8c)
2014-01-10 21:39:02 -05:00
Jason Michalski 1352dccea5 Add support to linkify links and mentions on twitter
This converts links in tweets to a tags. We also convert the displayed
text to the target of the twitter short URL. Mentions are linked to the
users twitter page.

(imported from commit 192d5546a7eea82759f9ae30d82c102aed15ff71)
2014-01-10 21:39:01 -05:00
Tim Abbott 1470cb8bf4 do_send_messages: Only pass active recipient users to Tornado.
Previously, we were processing in Tornado mirroring dummy users (and
deactived users) as recipients -- resulting in bugs where the missed
message hooks would fire for these nonexistent users.

Our Tornado real-time delivery system only needs the list of active
users both for delivery and for presence information updates.

(imported from commit b81143f106a4d0eefa4b838e7c074b2963259746)
2014-01-10 21:39:00 -05:00
Tim Abbott 4bf3ace444 [manual] Allow signups for emails held by non-MIT mirror dummy accounts.
Before this is deployed to prod, we need to manually frob our database
to set the is_mirror_dummy=True bit for all existing mirror users.

(imported from commit 39f1938cef091cf1d7d97307f76b137fe1d92b6c)
2014-01-10 21:38:59 -05:00
Jessica McKellar d3f6c4ef36 Log the actual sending of digest emails in addition to queuing possible ones.
(imported from commit e43ac59e71620fe715db462347db228d5a950aed)
2014-01-10 21:38:59 -05:00
Tim Abbott 47500d8352 [schema] Add a bit for whether inactive users are mirror dummies.
(imported from commit bb21bb2c62ac09742484d7a4ca8907e7d864b982)
2014-01-09 11:08:35 -05:00
Jessica McKellar 8e3911269e Strip whitespace from emails before looking up DB entries in a few places.
(imported from commit eafdce98450d16c0ca51c4cb17a139811a6124bc)
2014-01-07 20:24:21 -05:00
Jessica McKellar 511e1a12e3 Add a management command to deactivate old realms.
(imported from commit f6b1d0cb5b10f91683afcffea88b23b1a75a9ad2)
2014-01-07 20:24:20 -05:00
Leo Franchi c7836626ea Accept a pass-through local_id option in send_message
(imported from commit 3f7b8e862a92d8a11b68da9ff23f711b6b25b5e2)
2014-01-07 17:33:34 -05:00
Leo Franchi 76892c52aa Send realm filters to clients
(imported from commit a3ba31701baa4d515ea3bf36c39d7255f1dd20d6)
2014-01-07 17:33:33 -05:00
Luke Faraone df4b2d9f85 Break out non-Twisted email mirror code into separate library
(imported from commit 45c3e70ba81cdb44f1e9db4f162e5f2d2fe5ead6)
2014-01-06 13:36:53 -05:00
Steve Howell 654ce3e0c7 Add make_stream_private endpoint.
(imported from commit b504c24fd651ecf8814e64725a9f303dc085b14e)
2014-01-06 11:59:47 -05:00
Steve Howell e0c62c5eda Add make_stream_public endpoint.
(imported from commit 03d4cff5587d0aa149997f2f6ae28ec4ede95d7a)
2014-01-06 11:59:47 -05:00
Zev Benjamin fb602da502 Don't log exceptions that we know aren't bugs when adding events to event queues
(imported from commit 55074e68603119bd11cc5218453a4e1eab710feb)
2014-01-03 14:40:55 -05:00
Jessica McKellar 30367d0c0f digest: don't include automated messages in hot conversation accounting.
(imported from commit ab8db46c644b3cf66a4bc654d204d870b8fae91f)
2013-12-31 16:45:21 -05:00
Jessica McKellar 8091634814 Move sent_by_human check to a method on the Message class.
(imported from commit 2ef49051932f9633ad11130952591c5c5b147f12)
2013-12-31 16:42:38 -05:00
Jessica McKellar 61103d8349 digest: On an app server, only send digest emails for domains it manages.
(imported from commit 9aea636a19eb6fdefacdc7dc393bf075a05862c5)
2013-12-20 12:50:23 -05:00
Tim Abbott 2264a07c03 Update server-side app checks to handle the new app names.
(imported from commit da7b2c06b413add1881b2d80a89794d0db9c810f)
2013-12-19 17:21:26 -05:00
Tim Abbott a70072f5cf socket: Don't throw traceback when sessions are expired.
(imported from commit 16c876b5bbd0c6ecd5ef48369a7f71ca74d1183f)
2013-12-19 16:52:53 -05:00
Tim Abbott 2ca5f43f05 Report json format 500 errors from all json format views.
Previously, we only did this via rest_dispatch.

(imported from commit b0edfdccea294378292b64677a64d5b01f936b08)
2013-12-19 16:48:51 -05:00
Jessica McKellar 0d7ea7353f Don't show broken images in digest and missed PMs emails.
(imported from commit 92297b4c8f020e30b5c00e93bf32df6e19069dd8)
2013-12-18 14:31:04 -05:00
Jessica McKellar 96ea91056e Support displaying emoji in digest and missed PM emails.
(imported from commit b440da2501ccb6dd95dc79c3fbce1e81b17c38f4)
2013-12-18 14:31:04 -05:00
Jessica McKellar 2f59f69a1f digest: tweak sender information.
(imported from commit fafc54d4b9c9cda447c42f2bd24845aee62624c2)
2013-12-18 14:31:03 -05:00
Steve Howell be1857ceb3 Add blank line to check_list (cosmetic).
(imported from commit 20a9eed98846e976c7fa2cfdb43e25e1c43c850d)
2013-12-18 12:47:32 -05:00
Steve Howell 6f573feaeb Add "length" option to check_list validator.
(imported from commit 4f8e203f964d1c936fe548b2f77a2e4aae745ae9)
2013-12-18 12:45:29 -05:00
Tim Abbott 3b7bf691e7 Add tool to query our usage stats as of a given date.
This contains the various fixes that needed to be made in order to get
accurate statistics.

Most notably, the active_users_between function in the previous
version of zerver/lib/statistics.py was broken for end dates in the
past, because it used the UserActivity table to get its data -- so in
fact it really was querying "users last active between".

This commit isn't super clean, but I figure we're probably better off
having our latest code for historical usage data in git so it doesn't
bitrot and anyone can improve on it.

(imported from commit 24ff2f24a22e5bdc004ea8043d8da12deb97ff2f)
2013-12-17 15:34:44 -05:00
Jessica McKellar 1d11e2cce0 digest: don't show new users for MIT.
(imported from commit b7453cb30e6fcf5b36a5e3e53f67faeb17e74048)
2013-12-17 10:47:16 -05:00
Tim Abbott 2276c6e524 Add support for loading a narrows-only embedded Zulip window.
Features:
* Only shows messages in the narrow
* New messages in the narrow will arrive as they are sent
* Works even for streams you're not subscribed to
* Automatically subscribes you to a stream on send
* Doesn't update your pointer
* All searches etc. automatically have the narrow added

(imported from commit 2e12b76849f6ca0f53dda5985dad477a04f7bbac)
2013-12-16 17:46:02 -05:00
Tim Abbott 7c829c4024 Extract adding clients to the various dicts to a function.
(imported from commit 667e5736710c23becdf4ebe5688a31421ac632f5)
2013-12-16 17:46:02 -05:00
Tim Abbott af347acf99 Fix narrow stream event queues with all event types.
(imported from commit 69c2f6f1be3dd864b5da85104b83235f0dd4df50)
2013-12-16 17:46:02 -05:00
Steve Howell 4184b9d56f Add validators.py (with tests).
This sets up a scheme to validate complex data structures and
give specific error messages for improperly typed parameters.

(imported from commit 33b2f070d993da4ee929119dd41503bd0128c8eb)
2013-12-13 18:19:07 -05:00