Commit Graph

327 Commits

Author SHA1 Message Date
Tim Abbott b8579c6848 Disconnect handlers if the client closes a connection.
Tested using the following procedure (run-dev.py won't pass through
the client connect closing)

tabbott@monastery:~/zulip$ curl http://localhost:9991/api/v1/register  -u email:key  -d 'event_types=["message"]'
{"msg":"","max_message_id":2259,"last_event_id":-1,"result":"success","queue_id":"1386884005:0"}
tabbott@monastery:~/zulip$ curl -G http://localhost:9993/api/v1/events  -u email:key -d "last_event_id=0" -d "queue_id=1386884005:0"
(then hit ctrl-C)

(imported from commit 3c4f3d5caac97b3de53da994ff9cd9ef67b2b9ea)
2013-12-12 16:52:25 -05:00
Tim Abbott cc0ce6b437 Finish event handlers when disconnecting from an event queue.
This should help prevent timeouts from clients whose requests have
been supplanted.

(imported from commit fdb3a89c4ec02bb23d0fba50ea558d48cb786916)
2013-12-12 16:52:25 -05:00
Tim Abbott 46760e91cd rest_dispatch: Don't allow session auth on /api URLs.
This caused problems with our tests suite where we were using a logged
in browser session and actually acting as a different user.

(imported from commit 73b8cb39d5d669e682fbacf2f7e574c228885c2f)
2013-12-12 10:31:04 -05:00
Tim Abbott 291506a2b2 Add logging for when we disconnected an active handler.
(imported from commit 18c21a93bdf14485e5656bd7a38f2069eb8f2aad)
2013-12-11 17:23:56 -05:00
Tim Abbott fcf6ec16aa Fix pruning of event queues that only had virtual events.
(imported from commit 7b43d2164df6e95a6feb073b8f90c0862245d629)
2013-12-11 17:20:34 -05:00
Tim Abbott b10278c8e0 events: Fix incorrectly empty event queues with virtual events.
I'm not sure this had much impact, but it's definitely a subtle bug.

(imported from commit 0260d4c5c35ce8eac683e84f1d939a6704ce4e2b)
2013-12-11 16:59:48 -05:00
Tim Abbott df730ec163 Fix json_unauthorized.
(imported from commit 7537b3bbc21b947f91ec49060935e9e2f92be0ac)
2013-12-11 16:45:29 -05:00
Kevin Mehall 662edc2558 [manual] Backend support for Android GCM push notifications
This adds a dependency on gcmclient:
http://gcm-client.readthedocs.org/en/latest/gcmclient.html

pip install gcm-client

or

apt-get install python-gcm-client

(imported from commit 9f1fbf1f793e4a27baed85c6f1aa7a7b03106a10)
2013-12-11 15:37:48 -05:00
Kevin Mehall e4589700b6 [schema] Modify device token to support both iOS and Android
This replaces the AppleDeviceToken table with a generic
PushDeviceToken with a `kind` field to make it easier to add functionality
like per-device/per-stream settings that share code between Android and
iOS devices.

The schema must continue to work on prod with the old table name, so we
add the new table in parallel and can drop the old table once this code
hits prod and any necessary data is copied.

(imported from commit 0209a7013f2850ac6311f23c3d6f92c65ffd19e3)
2013-12-11 15:37:47 -05:00
Leo Franchi 2c39e28ff6 Use realm filters from the database in bugdown
(imported from commit 8e12bfb1b1fe9cad694f80a189efa64b0f102e81)
2013-12-11 14:39:10 -05:00
Zev Benjamin 874d4282c0 Disconnect handlers from event queues via a finally block
(imported from commit ac63a962f978b05a5d8d6bf81861b908b5fd54b3)
2013-12-10 17:44:35 -05:00
Zev Benjamin b566c0f201 Catch a wider range of exceptions when adding events to event queues
We have observed additional exceptions being thrown from zulip_finish and we
need to make sure that the handler is disconnected from the queue, or else the
event queue will keep throwing exceptions due to the handler being closed.

(imported from commit 59273aa14495216430b9eb1525b2cce230d8913d)
2013-12-10 17:40:30 -05:00
Zev Benjamin 0d989a6972 socket: Close old connections before registering new ones under the same id
(imported from commit f9b75288cbf7e2d9baa3254d57443eea5c1f3fc3)
2013-12-09 16:17:26 -05:00
acrefoot 33ddba3d30 extra debugging info for handle_push_notification
(imported from commit c4f63827fd37e7e99853380eaa268ab2e5ae23ce)
2013-12-09 11:15:20 -05:00
Zev Benjamin 5e19ad31bf socket: Increase redis response cache expiration time
(imported from commit 1b18530f01499af9a555c71f0281e62bd3164542)
2013-12-08 12:13:15 -05:00
Zev Benjamin 96bb739157 socket: Add some server-side logging for bug catching
(imported from commit 8579d8bbb414b063ae9cf36993975adaa86cb132)
2013-12-06 16:22:24 -05:00
Zev Benjamin 8535669d46 socket: Include the user in socket close log lines
(imported from commit fb5b9e54a07b6bfd85e913b8c97105305f8210eb)
2013-12-06 16:22:24 -05:00
Leo Franchi f55067a3db Actually use a UserMessage object instead of Message
(imported from commit 9613af82f62a9ea85a85f1ce662234f410457997)
2013-12-06 15:53:42 -05:00
Leo Franchi 4f2cb1bc1c Read read flags from UserMessage not Message
(imported from commit 4c0f6ec90992c61ba861f5f347655673e769bebc)
2013-12-06 15:08:02 -05:00
Zev Benjamin 657a750550 socket: Fix spelling
We don't ever actually check for this value so nothing else has to
change.

(imported from commit e6ccb153df7bd95c9d195aa83395592b309a2778)
2013-12-05 15:53:50 -05:00
Zev Benjamin 002df64811 Remove extraneous semicolons
(imported from commit 2077705c52e7255ab7ea1b4df71d2ae99f6018dc)
2013-12-05 15:53:50 -05:00
Tim Abbott fed3902fc5 Clean up debugging logs from tracking down slow receive.
(imported from commit e4b1f763522406255ce8be3c8d51b5d855a770cd)
2013-12-05 14:36:29 -05:00
Tim Abbott 55047280c9 Include a newline at the end of our JSON responses.
Otherwise, it's super annoying to work with these using curl.

(imported from commit 0047f07786dc07d7ac5cb671492f8ca40986d8cf)
2013-12-04 13:47:48 -05:00
Leo Franchi 1b53a77f1b Expect an ios client instead of iphone
(imported from commit d5d3cd129d7005fd9294096d3899df86155cd366)
2013-12-03 14:27:51 -05:00
Tim Abbott abded5f886 Upgrade event flag collapsing to support all flag changes.
(imported from commit a2ca74b779d67148aee41e92e4a4cb716620e566)
2013-12-03 12:21:04 -05:00
Tim Abbott d2486670a8 event: Add deduplication of server restart events.
(imported from commit e464aa8b68958fb9f9fe8c199b9e73df510d22bc)
2013-12-03 12:20:36 -05:00
Tim Abbott 54b06d046b events: Add support for not storing redundant events.
This should dramatically improve the speed of the dump/load part of
our restart process, especially with large long-lived event queues.

(imported from commit ae4ae20ba2ca4433e25a5e7beeb4fa4882c53972)
2013-12-03 12:19:42 -05:00
Tim Abbott ad9659ea54 events: Fix zulip_finish to not make assumptions about how queues work.
Previously, we had an issue with the ACKing protocol, where if a
virtualizable event (like a "read" flag) was dispatched to a queue
client immediately, we would not properly ACK the change because it
had been made a virtual event.

(imported from commit ea09812f8a5ba1d5aad65f536022e3dbc77b0f9e)
2013-12-03 12:19:42 -05:00
Jessica McKellar e15cc972ec digest: refactor sending the emails into a function for easier testing.
(imported from commit 2f3c8fb8e812c04ab838b1034ae0811309186625)
2013-12-02 18:58:03 -05:00
Jessica McKellar 207cfc449d Add unsubscribe links to digest e-mails.
(imported from commit 4e2a324decf4bc694752cc24b9085361338a08a5)
2013-12-02 18:58:03 -05:00
acrefoot da1466cfa9 handle case of message getting read while processing missed_message
(imported from commit cd53efe3645f5dc8943becc2b8dbd3d607bb8eba)
2013-12-02 16:00:56 -05:00
Tim Abbott 559f0896a1 Revert "events: Add support for not storing redundant events."
This reverts commit cc493fa50b4c339257e060b3f0c0956c682e449d.

(imported from commit 9e8edfc11d415d61581da482d66bc9fa30cbefdf)
2013-12-02 11:03:04 -05:00
Tim Abbott 5b601d8492 Revert "event: Add deduplication of server restart events."
This reverts commit 05467929ba376a0ce173119c5d90d83671fc544b.

(imported from commit 4f24a0f1fe72e71fa368e1d818d9406a76c131be)
2013-12-02 11:03:04 -05:00
Tim Abbott 2c2f404cb6 Revert "Upgrade event flag collapsing to support all flag changes."
This reverts commit dadf3852f2ca7aaa85fb97b3d265c990b4e5a38a.

(imported from commit de5a95572aa955b4a9419b80a99d2446c51730e7)
2013-12-02 11:03:04 -05:00
Tim Abbott 10bce7ffe8 Revert "Fix loading event queues that don't have a virtual_events attribute"
This reverts commit 99c5ae332d253313ed728883a388c61191ed3021.

(imported from commit d7b601a2897bac6e14b675e689ee63ccc6e8d67d)
2013-12-02 11:03:03 -05:00
Tim Abbott 5bc826067e Revert "Add comment in ClientDescriptor.to_dict and EventQueue.to_dict to avoid future bugs"
This reverts commit 45560539d09e9e1922130349be729005b786e632.

(imported from commit aa266941f03cdbe12f4315e65ec6c472cc207204)
2013-12-02 11:03:03 -05:00
acrefoot 717e06d94c remove log message on push notification
(imported from commit 45fc89e67a79aac3484c911d88aff3e470b4eff6)
2013-11-27 18:00:33 -05:00
acrefoot 8800dcdce4 more helpful error message when missing APNS certs
(imported from commit e21dc627844b9e28f93a924097176481d4135947)
2013-11-27 18:00:33 -05:00
acrefoot 8ee7536012 Send push notifications more aggresively
Unbundle the push notifications from the missed message queue processors
and handlers. This makes notifications more immediate, and sets things up
for better badge count handling, and possibly per-stream filtering.

(imported from commit 11840301751b0bbcb3a99848ff9868d9023b665b)
2013-11-27 18:00:31 -05:00
Zev Benjamin 9d0f801ad6 Exempt a particular client name from heartbeats for testing
(imported from commit 3914130384a7a9854b006405ffd2fe379bbd090d)
2013-11-27 10:39:31 -05:00
Jessica McKellar 2ba9415178 Factor welcome e-mail enqueuing into its own function.
(imported from commit 85054ee3e567d2ba7a4ed94c52a311d02f5e4d43)
2013-11-27 09:30:00 -05:00
Zev Benjamin 8899c62567 Add comment in ClientDescriptor.to_dict and EventQueue.to_dict to avoid future bugs
(imported from commit 45560539d09e9e1922130349be729005b786e632)
2013-11-26 18:39:31 -05:00
Zev Benjamin ce00fe0cd5 Fix loading event queues that don't have a virtual_events attribute
(imported from commit 99c5ae332d253313ed728883a388c61191ed3021)
2013-11-26 18:32:58 -05:00
Tim Abbott e9f4612281 Upgrade event flag collapsing to support all flag changes.
(imported from commit dadf3852f2ca7aaa85fb97b3d265c990b4e5a38a)
2013-11-26 18:12:52 -05:00
Tim Abbott fb5c42707e event: Add deduplication of server restart events.
(imported from commit 05467929ba376a0ce173119c5d90d83671fc544b)
2013-11-26 18:12:52 -05:00
Tim Abbott 1db8fba5aa events: Add support for not storing redundant events.
This should dramatically improve the speed of the dump/load part of
our restart process, especially with large long-lived event queues.

(imported from commit cc493fa50b4c339257e060b3f0c0956c682e449d)
2013-11-26 18:12:52 -05:00
Leo Franchi 501f063426 Replace email_to_domain with split_email_to_domain and resolve_email_to_domain
Now that we support email aliases, we have to be careful when going from
an email address to a domain that we assume we can use to get a Realm
object for. When we care about the Realm's domain, we want to follow
any RealmAliases that exist for a certain domain.

When we just care about the original email address domain itself,
for comparison or other purposes, use split_email_from_domain

This removes the ambiguity of having to decide when to use
email_to_domain + RealmAlias or just email_to_domain

(imported from commit 0e199495502d946ce2e1aae56263e7e8665be4ed)
2013-11-26 10:45:01 -05:00
Kevin Mehall b8a6100d2e bugdown: Open #-relative links in the same window.
Stream notifications shouldn't leave you with tons of Zulip windows.

(imported from commit e5ebfeff51f1e579d30a3a12eaf7341ef82f0449)
2013-11-25 17:34:59 -05:00
Jessica McKellar dbc1b4b501 Add a one-click unsubscribe link to missed message e-mails.
(imported from commit 719eb61c9b7722eb1b0996b4d5f2f8f5929ad701)
2013-11-25 15:18:40 -05:00
Tim Abbott 7cb261a0ed Set default streams to engineering,social when creating realms.
(imported from commit 4e174fec162be4138da099edfc4cfb8d5662b7f1)
2013-11-25 14:00:28 -05:00