Tim Abbott
cf31374497
bulk_create_streams: Fix missing select_related().
...
bulk_create_streams was taking about 10 seconds to run with prod data;
this should be a basically immediate operation. The cause was a
missing select_related on one of the loops through all streams.
(imported from commit 8b82f0c41facc3999bb699dbc350708ac69797e9)
2012-12-04 10:55:31 -05:00
Jessica McKellar
55e68fc89a
Log subscription color changes so they can be replayed by populate_db.
...
(imported from commit 5c7f46ed0d727926e9819cb2d71eb31f241e2e34)
2012-12-03 12:46:27 -05:00
Jessica McKellar
71371823f8
[schema] Add a StreamColor table.
...
(imported from commit 2906c30ad326373bc6265bf30dd0a70e11d69c7d)
2012-12-03 12:46:26 -05:00
Keegan McAllister
36816c46e2
Add a function to remove all Messages that are not referred to by any UserMessage
...
(imported from commit cdad013aed0fd8d1bc6ec8c2dcf5905390a01339)
2012-11-30 17:24:37 -05:00
Zev Benjamin
f568ff20c2
Remove format_delayed_updates_response
...
(imported from commit d1aa1a1f36fc5ec36f1658aec489db84ae469f7c)
2012-11-28 16:36:43 -05:00
Jessica McKellar
4832a6a1fe
[schema] Add a management script to create default streams for a domain.
...
Run this script on an existing realm to create or change default
streams, which new users will get upon account creation.
(imported from commit 8938dcbd3520d97d25b4c6ca783d35c9aef52df0)
2012-11-28 14:07:16 -05:00
Jessica McKellar
cca39ca5e8
Add default subscriptions upon non-MIT user creation.
...
We'll probably eventually get fancier with this, suggesting various
default sets depending on the company or making it easy for one person
to create default subs for several people at once.
Until we know what we want, keep it simple.
(imported from commit 14319dd50c67fe33ac6f15288dba4916ce0a89ac)
2012-11-26 21:02:29 -05:00
Jeff Arnold
a6ec875268
[schema] Add enable_desktop_notifications to user profile
...
(imported from commit f5b543e8446263ce8855561441a6d4c1a8d41f4d)
2012-11-26 14:43:55 -05:00
Jessica McKellar
bdf3473bac
Fix bug where sending a PM would display as sent to the wrong person.
...
In get_display_recipient, the userprofile was selected incorrectly by
user_id instead of the userprofile_id. In production, this hasn't
resulted in a user-visible error because we use MySQL and user ids are
always equal to userprofile ids.
This does happen if you are using SQLite locally and run populate_db,
which adds a bunch of users in parallel in an insufficiently
transactional way.
(imported from commit c25a04b4919e3efdfc6996b03492f7714d9034e8)
2012-11-20 15:08:50 -05:00
Keegan McAllister
1ea92c0953
Manage file locking using the 'with' statement
...
This is clearer and more exception-safe.
(imported from commit b67641b05da9dbf8e5a887f398bac81ab5985cf3)
2012-11-16 13:43:44 -05:00
Keegan McAllister
af36b437b6
log_event: Use 'with' for files
...
(imported from commit d49b46ecd8aa74679ade3820004d10cb42940ad3)
2012-11-16 13:43:44 -05:00
Keegan McAllister
ccf14b89c2
log_event: Don't flush the log file right before we close it
...
There's no need.
(imported from commit 8c3b933b7fddfb858ee4dc201b63b6fe921dc8e9)
2012-11-16 13:43:44 -05:00
Keegan McAllister
f132cd311b
log_event: Close the lock file after we're done with it
...
(imported from commit 023e50e1aeeafee334f9b55e12ab91aa84a7872a)
2012-11-16 13:43:44 -05:00
Tim Abbott
7227cb32f8
zephyr_mirror: Compute zephyr mirror fullnames server-side.
...
(imported from commit 9e6f6f9fe49d60ed30753582480e592613feb3c8)
2012-11-14 15:03:46 -05:00
Tim Abbott
0971b3d8e6
Add proper transaction handling in create_user_if_needed.
...
(imported from commit cab9cb4886acf61f36a0b0bc80d87ed9037cc414)
2012-11-14 14:33:31 -05:00
Keegan McAllister
42a5ea9d2e
Specify requests.post data as a dict
...
These were lists of pairs because we were going to repeat keys, but that didn't
work anyway.
(imported from commit 687b3f7b8a2821d057719c725f1f39db3992ae5c)
2012-11-13 17:33:41 -05:00
Keegan McAllister
f82e8fc4d1
Move Markdown rendering out of the Tornado server
...
(imported from commit fc726939aa1061c40b292899dbbc9ade3b29ea01)
2012-11-13 17:33:41 -05:00
Keegan McAllister
c0204ea5b3
get_display_recipient: Sort huddle recipients by email address
...
We need a deterministic order for the client test suite, and it seems like a
good idea generally.
(imported from commit cc8fc555611f2d2f1b21e63ce6860d446baa3410)
2012-11-13 15:09:15 -05:00
Keegan McAllister
a954277647
get_{display,log}_recipient: Use a join query
...
(imported from commit 1278f46655760842e21a62ca5add891515ee1945)
2012-11-13 15:09:15 -05:00
Keegan McAllister
31496e9189
Generalize Tornado-related settings
...
(imported from commit 76a1338a87e1a6663aa7602a499e2d769814bf08)
2012-11-13 10:59:02 -05:00
Tim Abbott
9e9438153c
[schema] Store analytics on usage of our product.
...
(imported from commit 4fbf8215225fc8f505b9c749ccf80c556af13e87)
2012-11-08 18:00:57 -05:00
Tim Abbott
9a14073dda
models: Add unique_together constraint on UserMessage table.
...
(imported from commit 79fcc1c9db11cc89a300b9d78a3c2f8cccb0917c)
2012-11-08 15:10:34 -05:00
Keegan McAllister
d52728e3ae
Recipient: use a dict to name types
...
(imported from commit 35ab065e7def38cb684672e48f2ca10f5f6479ad)
2012-11-08 10:48:34 -05:00
Keegan McAllister
b57270322a
models: Always pass a tuple to string %
...
(imported from commit c2881ef8f60fd7be2f70138868214d42d41b492d)
2012-11-08 10:48:13 -05:00
Keegan McAllister
979d997cf8
bulk_create_huddles: Use a set for existing_huddles
...
(imported from commit af66c6e4e87109feafbafdc6e84cf02903ca93ca)
2012-11-08 10:48:13 -05:00
Keegan McAllister
246c0a37bc
Get rid of bare 'raise' outside 'except'
...
Within 'except', 'raise' re-raises the current exception. But outside, it produces
TypeError: exceptions must be old-style classes or derived from BaseException, not NoneType
which is pretty confusing as a generic "something has gone wrong" exception.
(imported from commit 9fcd003a952b82df67726c26161dced079978a32)
2012-11-08 10:48:11 -05:00
Keegan McAllister
5933a902c7
Remove unnecessary line-continuation backslash
...
(imported from commit afabcea50432b0e00f17e7a4cc4cb6c4a0c19cf2)
2012-11-08 10:47:09 -05:00
Keegan McAllister
a70d82b8fc
Use comprehensions more consistently in bulk create
...
(imported from commit f6b67b9ce74b379004e5fde6c99368c077a77f7b)
2012-11-08 10:47:09 -05:00
Keegan McAllister
51a96484f9
Consolidate callback code
...
(imported from commit e79ea42df3506bedd2077dcc63a45d32fe7b73de)
2012-11-08 10:47:09 -05:00
Keegan McAllister
9b9373d2ba
Make callbacks_table class data rather than global
...
(imported from commit 39699304255b475ccab8a4760b155f3307cfe5d9)
2012-11-08 10:47:09 -05:00
Keegan McAllister
f89366f5dd
Use a new-style class for Callbacks
...
For consistency with the rest of our Python code.
(imported from commit 02659914f50b488039fe8c65bd1de796e2a16e65)
2012-11-08 10:47:09 -05:00
Tim Abbott
218588ead0
models: Comment the IntegrityError code in get_client ( #326 ).
...
(imported from commit 85c3580084dcd4c28f319a19d684e5a5af7069c7)
2012-11-07 18:22:32 -05:00
Tim Abbott
573cc4db33
models: Add unique_together restrictions for various tables.
...
(imported from commit 30957d465d5e7bc728e854b8b99f6ad99b98dba6)
2012-11-07 17:31:16 -05:00
Tim Abbott
f342217700
Add timestamps to our various non-message logged events.
...
(imported from commit 65102419ac0032ccedcbdb342dbea9b91bbe3e13)
2012-11-06 14:12:19 -05:00
Tim Abbott
1adc54185f
Fix unnecessary usage of realm ids creating new users.
...
(imported from commit 5870b583efffa4a5280c81125eefecc23978cf11)
2012-11-02 20:55:31 -04:00
Keegan McAllister
02aa92a604
Correct comment on filter_by_subscriptions
...
This isn't dead code; it's used by tests.
(imported from commit ce6cfc049d2cb8050aff1fef1b77a3778b7ceacb)
2012-11-02 14:57:38 -04:00
Tim Abbott
426ab9559d
Fix creating new users via zephyr mirroring.
...
(imported from commit 05e01efabdce081fc574486916c7db343f2cdb1d)
2012-10-31 14:06:35 -04:00
Waseem Daher
e7e05d8617
Fix up some overzealous "instance->subject" renames.
...
(imported from commit f4ddcfd3749d374cc6abee3b1e7a5aacc3b83e16)
2012-10-30 16:48:00 -04:00
Tim Abbott
44b332693e
Fix the fact that new auto-created MIT users are active.
...
(imported from commit 577f1a0165a56fc3cc1ed6f0a54f6c5f31345cc7)
2012-10-29 17:30:06 -04:00
Luke Faraone
5dad59e864
Implement MIT signups.
...
Here we introduce a new manage.py command, activate_mit, which takes a
number of usernames and sends out emails to the users with instructions on
how to activate their accounts.
(imported from commit f14401b55f915698e83ff27b86434f53e64685f3)
2012-10-29 16:59:37 -04:00
Tim Abbott
6c39bf5cbd
Cut out duplicated code between clear_database and populate_db.
...
(imported from commit 4bb44c20d2f0477d8a3db72788f82b0cf8572b2d)
2012-10-29 14:54:18 -04:00
Zev Benjamin
ec9e0a4b9f
Have get_updates include an "update_types" array in its response
...
This is similar to the previous "reason_empty" variable, but captures
why we've returned from the call even when there are updates and all
the reasons if there are multiple. For now, it's useful for debugging.
(imported from commit fd8d9e859660e51b57178d066b184f831b71a0b6)
2012-10-25 18:12:11 -04:00
Tim Abbott
7c8bde5d90
Add log/restore for fullnames and passwords.
...
(imported from commit 048ca3c86b9f077fcbccd5df4a509191a545da4c)
2012-10-25 15:52:26 -04:00
Tim Abbott
8c4a834206
Add function for activating MIT users.
...
(imported from commit 0de45fc341249332909d5a0ecef4d49918658a1a)
2012-10-25 14:46:58 -04:00
Keegan McAllister
b30b5f396e
to_dict: Include the content type with each message
...
(imported from commit 413ce08029832c6bed2a43f27a1caf809fb962b6)
2012-10-24 15:43:43 -04:00
Keegan McAllister
7da2ddea8e
Reorganize to[_log]_dict
...
(imported from commit 2f811cf6a42e5b5661679158c0053dd4ebb40dbd)
2012-10-24 15:07:14 -04:00
Tim Abbott
f1e4a27106
Optimize populate_db's common code for setting up real users.
...
(imported from commit 074b30ac88101f8e00ddcb60b5b05defc0a11998)
2012-10-23 17:52:10 -04:00
Tim Abbott
1b67b6b711
Don't deliver messages to "fake" Zephyr users created by populate_db.
...
(imported from commit c88760a88382ffc07cf5f79f3093a2bfec429d53)
2012-10-23 17:52:10 -04:00
Zev Benjamin
8a39292b5d
Fix bouncy pointer from pointer updates
...
The previous code path was buggy. We now do separate pointer update
checking for the cases where get_updates returns immediately vs. when
it returns from a callback.
(imported from commit f236a80cd0b94bc097dbd17f113d7a9d27368025)
2012-10-23 16:39:04 -04:00
Zev Benjamin
c8dd5229ed
Rename updater_session to pointer_updater
...
(imported from commit 7646b8e636393d64ef07d0251f8c83beecf114aa)
2012-10-23 16:39:04 -04:00
Tim Abbott
386b48e80f
Don't log tabbott/extra test messages.
...
(imported from commit 8e1adecca14e5440298fd93b41e1a43da37c807f)
2012-10-23 11:08:27 -04:00
Tim Abbott
846469c39c
[schema]: Rename userprofile to user_profile.
...
(imported from commit adfb6152b7ec32557e3465d961695eb870506d5a)
2012-10-22 18:55:45 -04:00
Tim Abbott
93616039bc
Use the new client data model to deduplicate mirroring.
...
(imported from commit 6ac38534aea11b1e7f8f332e76251f9501f9ab3e)
2012-10-22 18:31:36 -04:00
Tim Abbott
2b1902dcc7
Return a user_profile from create_user_if_needed.
...
(imported from commit d71a9b1f326f783e387bb70b5215c934799fb5f2)
2012-10-22 17:47:05 -04:00
Zev Benjamin
f817bf6144
Pass the session that updated the pointer from Django to Tornado
...
This allows us to check whether the session that updated the pointer
is the same as a session that is doing a long poll to avoid sending
new pointer information when that information is coming from the same
session.
We still return from the long poll early, though, which is sub-optimal.
(imported from commit 7d4be0956f112eacefb7d198ea929957cd2b05e3)
2012-10-22 17:16:47 -04:00
Zev Benjamin
732ca19729
Synchronize the pointer across sessions
...
The client may now optionally send its current pointer during
get_updates and the server will return the latest pointer if it
differs and was updated more recently by a different session.
(imported from commit e43b377d7dfb52f83cefb0b1003863d5407caf80)
2012-10-22 16:44:57 -04:00
Zev Benjamin
66d7678423
Add UserProfile callback for pointer updates
...
(imported from commit bfa9c15d82f092a1810cfcee1a88e1e292bc4cb8)
2012-10-22 16:06:38 -04:00
Zev Benjamin
2a4c3b5bff
Abstract the callbacks table in preparation for more kinds of callbacks
...
(imported from commit 695d5bceb4657ef25ba5983212082ee0c76b9d33)
2012-10-22 16:06:38 -04:00
Zev Benjamin
7ac0625e39
Add model field indicating which session most recently modified the pointer
...
(imported from commit 819ab358d9fa6f22ad8ccee56fe723ea7711ebc5)
2012-10-22 16:06:38 -04:00
Tim Abbott
f26a614bb3
Fix Client handling in the test suite.
...
(imported from commit 56841a00052c3aa85f2eeb45133439a46f3caf82)
2012-10-22 13:23:16 -04:00
Tim Abbott
7530163fb8
Fix stream Verona's Recipient being created twice.
...
(imported from commit 710572ff8681530c52f861d9e5607eaf8390c657)
2012-10-20 20:06:43 -04:00
Tim Abbott
6a7cbaf4b1
Add some more defensive lower-casing when creating streams.
...
(imported from commit 25a62b0105ce7b6b871b7570d087970fed7c6d9b)
2012-10-20 19:52:01 -04:00
Tim Abbott
edf9a8e7e5
Fix incorrect setting of initial API keys in bulk import.
...
(imported from commit ec492c787a5575f1f7b2fe68986999bbdd072a04)
2012-10-20 18:48:12 -04:00
Tim Abbott
7b3b4362dd
[schema] Add a Client model keeping track of the sending client.
...
(imported from commit 31a430b1de14ce973addafd5d13ace049a8f8091)
2012-10-20 18:41:54 -04:00
Tim Abbott
a8e4c818c6
Make logging of new subscriptions conditional on changes.
...
(imported from commit fff72906a52838bba144a960c0bc6a3487bef41b)
2012-10-20 18:26:21 -04:00
Tim Abbott
56dab6cb26
Log changes to subscriptions and replay them in populate_db.
...
(imported from commit d3055eb44326bdc59a6bc96d00b5b0bc6da86059)
2012-10-20 18:26:21 -04:00
Tim Abbott
d68cf3696b
populate_db replay: Use bulk_create to create objects.
...
This cuts the time required to import 38000 messages (with 140000
message receipts) from about 10 minutes to just under 40 seconds on my
laptop with sqlite.
(imported from commit d53b0d1360408c77f38353b58fbb25875262cb40)
2012-10-20 18:26:18 -04:00
Tim Abbott
e434fa141e
Use .objects.create and .objects.get_or_create.
...
This eliminates a bunch of unnecessary code and also fixes a bunch of
places where we were improperly not using transactions.
(imported from commit f194ae9226f9229fc56a0b1b21615534f486ea0c)
2012-10-19 17:42:14 -04:00
Tim Abbott
1d55c06ede
Move mit_sync_table code into the correct process.
...
(imported from commit bc40f865f94d7b39db5e49eba09370c3fa53dc6f)
2012-10-17 22:35:02 -04:00
Keegan McAllister
b9e9938197
create_user_if_needed: Use proper initial passwords
...
(imported from commit 009208ac64548dd6f8773ccc7738ab0c391d816a)
2012-10-17 21:08:59 -04:00
Keegan McAllister
4f56362e0f
Change formatting of notify_new_message request
...
The requests library doesn't encode repeated key form data reliably.
(imported from commit 3cc9f5379c299a57f69bb5b7ff3b85f0c066269f)
2012-10-17 18:24:15 -04:00
Keegan McAllister
ea916951f4
Disable notify_new_message calls in testing and populate_db
...
(imported from commit 07a0fea4173e2e27a90ac5f111927f0000377764)
2012-10-17 18:23:01 -04:00
Keegan McAllister
a545876d56
Rename notify_waiting_clients -> notify_new_message
...
We might have other URLs for other notifications.
(imported from commit 4c1c5fe2f039816fef4c268f34692ca4f19d81e8)
2012-10-17 18:23:01 -04:00
Keegan McAllister
c851bc4632
Generate initial API keys in the same manner as passwords
...
(imported from commit 754fa391b441c520082650a0cf3bacf050bf81b3)
2012-10-17 18:23:01 -04:00
Keegan McAllister
5e70b5a291
Split off the Tornado code into a separate process
...
(imported from commit 95dbd0f438cdba06d6e6c6c539a2a3d49c577cfd)
2012-10-17 18:23:01 -04:00
Keegan McAllister
81f0d61c3b
Factor out Gravatar hash calculation
...
(imported from commit 29872722fb4856773d98fc987a1e2d6eb99ad8b2)
2012-10-17 01:09:16 -04:00
Keegan McAllister
bc43613a10
Some import cleanup
...
(imported from commit 265cebb011309b9a880035ccd587a5e51554803a)
2012-10-15 16:16:10 -04:00
Keegan McAllister
fa729c838a
Move our various Markdown hacks into their own file
...
(imported from commit b03a5c64cc95964936c4aba7d667807969e35d21)
2012-10-15 16:16:09 -04:00
Tim Abbott
8bc511d24e
Re-initialize the markdown engine every 30 messages.
...
Otherwise, the performance leak associated with highlighted code can
cause get_updates to become increasingly slow.
(imported from commit 3c81f245a795e5dd2629c0e571054f2d87089cb7)
2012-10-15 15:29:49 -04:00
Tim Abbott
71146c8718
Use select_related to get the userprofiles for new message recipients.
...
(imported from commit afa729230f4ef6fb7f591b3f852fa0b271d64992)
2012-10-15 12:56:03 -04:00
Tim Abbott
002294d522
Save UserMessage objects within a transaction.
...
(imported from commit bd7f36801a754d4f9c09b5d370eee6b62a470b1a)
2012-10-15 12:54:53 -04:00
Tim Abbott
ec37eaf734
Use select_related() when querying UserProfile objects.
...
(imported from commit 584859312e089ad98c4b43032ea29f03eb44a97f)
2012-10-15 12:29:27 -04:00
Tim Abbott
a92be363d7
performance: Cache display_recipients.
...
(imported from commit 9ca18bd75213423cbf17c6262113822d3009c320)
2012-10-15 11:38:54 -04:00
Tim Abbott
41e935fd28
Send the sender_short_name to clients.
...
(imported from commit 1652f5cadbe9c90d4c6d53c97cb23305aaaaa34d)
2012-10-12 18:35:28 -04:00
Zev Benjamin
c4d35280ea
Make Message's display_recipient field be an object with consistent names for both personals and huddles.
...
(imported from commit 8b00f16b036ed3fb3f7d56e7393271ec1d458ea5)
2012-10-12 11:34:42 -04:00
Keegan McAllister
d19d3d2bd7
Hack around Markdown parser failures for now
...
(imported from commit dba079d444d40e36c91508b86b243bdc805c6222)
2012-10-11 21:45:22 -04:00
Keegan McAllister
3ca3be297e
Disable Markdown heading markers by padding with spaces
...
Because # will display literally now.
This still fails in some cases, such as
> # foo
(imported from commit 40654a4f1dac940ba131f2a104440b6ecb7eafd1)
2012-10-11 16:23:18 -04:00
Keegan McAllister
2c3d7d6116
HTML-escape messages on output
...
(imported from commit f199fddf887ffbd22ebac76448accb4c48b64a24)
2012-10-11 15:01:54 -04:00
Tim Abbott
eb63177a56
Fix timestamps in logging
...
(imported from commit c23570fa00ea682681a0065ffddd86670e5c59af)
2012-10-10 21:34:57 -04:00
Tim Abbott
a5a8a07370
Increase the maximum instance length to 60.
...
(imported from commit e1d79e059324be03ecb84d1bdd93f83bcc4a1a8d)
2012-10-10 18:19:38 -04:00
Tim Abbott
ac3f4393ff
Rename instance to subject.
...
(imported from commit 6b4693da03f106448c137cf81cf9801cac44f2b8)
2012-10-10 18:01:39 -04:00
Tim Abbott
cdcaaa578f
Rename class => stream in models.py.
...
(imported from commit c9513da997e126bc3c84c6d66176d3402a57db66)
2012-10-10 17:47:13 -04:00
Tim Abbott
44e9e4cebf
Rename Recipient.CLASS to Recipient.STREAM.
...
(imported from commit a530194163f7260c73921137fa1ff671f14516f6)
2012-10-10 17:47:13 -04:00
Tim Abbott
1fc4780a81
Rename create_class_if_needed to create_stream_if_needed.
...
(imported from commit 1bbc792332981723d3d29b24ad03811d62ced5f1)
2012-10-10 17:47:13 -04:00
Tim Abbott
8daff2e05e
Rename ZephyrClass to Stream.
...
(imported from commit ae51b7a9e03f322dfe2dfccd250cbfc23adfe32e)
2012-10-10 17:47:12 -04:00
Tim Abbott
38c76266bf
Escape pound sign before running markdown parser.
...
(imported from commit 418f4f76c579b5db9ec7f30cfc92c3f815323756)
2012-10-05 14:59:23 -04:00
Keegan McAllister
b8fb58968e
Implement conservative linkification on the server side
...
(imported from commit 970bcb4adf980d386442602fbb6297919fcee4d9)
2012-10-04 16:52:10 -04:00
Tim Abbott
89c73ca25f
Replace 'zephyr' => 'message' in code internal to models.py.
...
(imported from commit 16449713202a915d12d3de2e4b4b6ac56e6d6237)
2012-10-04 14:38:07 -04:00
Tim Abbott
fbf321c783
Revert "Add hopefully temporary hack to deal with bad zephyrs in DB."
...
This reverts commit 85fc39c39c7602990f4d8be15aa96349c544d16f.
(imported from commit b0c111a9288a92c739d5d439b6dfeaa8a4e78dd8)
2012-10-03 22:40:50 -04:00
Tim Abbott
6789356b4b
Add hopefully temporary hack to deal with bad zephyrs in DB.
...
(imported from commit 85fc39c39c7602990f4d8be15aa96349c544d16f)
2012-10-03 18:23:45 -04:00