Commit Graph

202 Commits

Author SHA1 Message Date
Tim Abbott 565acffbc5 Fix populate_db pointer restore.
(imported from commit e7984f5a762fde833c3b8520ef556fbd841aacbb)
2012-12-11 17:18:59 -05:00
Tim Abbott 3014a12cef populate_db: Truncate too-long messages on replay.
(imported from commit 4d89bf8a9235d5ed65863a851a13c91f4fb8632e)
2012-12-11 17:17:38 -05:00
Luke Faraone c65d6113ed Factor out notifying of a new user into a separate function, notify on manage.py create_user.
(imported from commit 1a6aa0536dbfea8035b6bbd76528e70d90aa8b60)
2012-12-07 17:32:16 -05:00
Luke Faraone 5b70b4a04f Introduce new manage.py command which creates users with default passwords.
(imported from commit ba5ed9cb6ee91435b184845019391e5dc38fc3aa)
2012-12-07 17:32:15 -05:00
Tim Abbott b5c8fd73f5 populate_db Use message_type variable consistently.
We previously were only using it at the first loop through all
messages, which meant code accessing the message type copied from one
place to another would break (potentially subtly), because things
would work if and only if the very last message happened to have the
same type as what is expected in the relevant piece of code.

(imported from commit ad9ce5efdb200e0c0d5c3ffa6db33113fdad8c5a)
2012-12-06 10:32:45 -05:00
Tim Abbott 28aa976be3 Fix desktop notifications being enabled on every settings change.
(imported from commit 09375c78125987de3223a17239fdef9273ccabe6)
2012-12-06 10:32:45 -05:00
Tim Abbott 8b15b11cbd populate_db: Simplify a bunch of message type checking code.
(imported from commit 6eaf857d3eef8d700c5251bdd242b9bbbc8cdb72)
2012-12-05 15:34:19 -05:00
Tim Abbott 970969fc44 Add new timestamp_to_datetime helper function.
(imported from commit 6791d009ae2e8371abe2c929e87c816a1981f5fe)
2012-12-05 15:34:19 -05:00
Tim Abbott f843152427 log_event: Clean up duplicated timestamp setting code.
(imported from commit dc3b3144ca23106bef2d953b00dc042115008703)
2012-12-05 15:34:19 -05:00
Tim Abbott 4d607c79f1 populate_db: Remove potentially confusing parenthesis.
(imported from commit 9d4dd543f0787c4eae5f7c697b7edcab4cdc8a7c)
2012-12-05 15:34:19 -05:00
Tim Abbott a6f744a11f populate_db: Fix inefficient pointer update at end of replay.
This cuts a 30s operation down to about 2s on my machine.

And also move the code to run before we print the "done" message and
have logging for how long it is taking.

(imported from commit 2f20f8ca3fee714735a50fe6c6cfd630df452768)
2012-12-05 15:34:18 -05:00
Tim Abbott 156f6ee576 Log an event on new realm creation.
(imported from commit 98872c7e5922fecd2bed9b544ff5fffd8147343c)
2012-12-05 15:34:18 -05:00
Tim Abbott 81d560dc1f populate_db: Preserve the user's date_joined on replay.
(imported from commit 91dcb4f41e0e58f165db6a7417e57548914ddab7)
2012-12-05 15:34:18 -05:00
Tim Abbott 8e3bcdaa19 Add user_created event type and appropriate replay code.
This is necessary for correctly replaying new user signups on non-MIT
domains.

(imported from commit e5a9d37b8772bd9794579ef16e7039196ac06f62)
2012-12-05 15:34:18 -05:00
Tim Abbott d6218a15b1 populate_db: Use a function to make email address fixups consistent.
Also add a missing fixup on the subscription events.

(imported from commit f7e2577fca8a3df3cef900c8535612ea8615b2e8)
2012-12-05 15:34:18 -05:00
Tim Abbott fc5e626515 populate_db: Update users table when processing newly created user.
(imported from commit cfcf620888e8d395ca2f808cfff1ee5de89ba2ac)
2012-12-05 15:34:18 -05:00
Tim Abbott a289efb425 populate_db: Request a new DB connection after run_parallel.
This is the only code change needed to make our code
postgres-compatible.

(imported from commit a94ad0856c46ead2892674fe18d86d49876a6160)
2012-12-04 10:59:26 -05:00
Tim Abbott eea553ce40 banish_broken: Fix handling of jesstess|MIT.EDU@mit.edu.
(imported from commit 50e596261dc678a1aa4b28bec34a6f592c8dc748)
2012-12-04 10:59:26 -05:00
Tim Abbott d850bc764f Fix stream name case issues in populate_db.
When we changed our stream name model to treat stream names as
case-insensitive, we didn't update populate_db to do the same.

This commit makes that update, which is to use the lower-cased stream
name for dictionary lookups and deduplication, but the original-case
stream name for actually creating streams.

(imported from commit fc32ec75a5ae286bce7ec86c6e6fb6893888cbd0)
2012-12-04 10:59:25 -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
Keegan McAllister 3715583d29 Implement a command to expunge old UserMessages and Messages from the database
(imported from commit a4873dfa8737c483411d12f30daaebebebf859f9)
2012-11-30 17:24:37 -05:00
Keegan McAllister c8b6e72cbf Implement a command to expunge old entries from log files
(imported from commit 28bc40bf12dd8cea0ff9b842f72e7713640e55a6)
2012-11-30 17:24:37 -05:00
Tim Abbott bc2ace726c Fix bad Django test suite interaction with get_client default.
authenticated_api_view and authenticated_json_view call
update_user_activity with a client generated using
@has_request_variables with a default of e.g. get_client("website").
Because that get_client call only happens once on importing the
module, if those client objects didn't exist previously in the
fixtures, then the first test will generate objects with ids 2 and 3,
and then the second test will dump the database, restore from the
fixtures, and then eventually generate client objects with ids 4 and
5.  But since the default values were only computed at module load,
we'll still end calling add_user_activity with client objects with ids
2 and 3, which don't exist in the newly restored database.

Fix this madness by just making sure those two client objects exist in
the database.

(imported from commit d940e129d077a560d9a0f96ec3daa2e16ce21c8b)
2012-11-28 17:41:39 -05:00
Keegan McAllister b5dccbfa87 Return a special value to initiate longpolling
Fixes #261.

(imported from commit dd0312c3574c9ca924ab76edcb2fb6c03085be32)
2012-11-28 15:28:14 -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
Jeff Arnold a6ec875268 [schema] Add enable_desktop_notifications to user profile
(imported from commit f5b543e8446263ce8855561441a6d4c1a8d41f4d)
2012-11-26 14:43:55 -05:00
Keegan McAllister ec6ebd034b Add Nagios bot user
(imported from commit e36ea06908b488e4003463e1afa34181fd299316)
2012-11-26 14:42:55 -05:00
Keegan McAllister b21bdc91cb Fix email addresses generated by populate_db --extra-users
(imported from commit bdb93e51966ca8c0e20d67cccbe50e80e2592127)
2012-11-23 19:19:46 -05:00
Luke Faraone dad00fa29f Add script to create new realms.
(imported from commit 764d41f28b1af10860ea4d03a6aa983f40d3ffd7)
2012-11-21 16:42:15 -05:00
Luke Faraone b1ba5bf1b2 [manual] Send a message when a new user creates an account.
(imported from commit 2c69be9bfbbe947db41188cbdfc05cf887dc858f)
2012-11-20 16:41:55 -05:00
Tim Abbott 4198dc74f1 Fix banish_broken tool.
(imported from commit 505c4a86ab106abab4c36af7c5f67c955f143c1d)
2012-11-14 16:57:21 -05:00
Tim Abbott b22249d861 Helper scripts to fix some buggy users.
We have a lot of forged users that have bad fullnames due to
historical versions of our fullname computations; this function will
clean those up.

Also, we have a bunch of users with emails like foo|mit.edu@mit.edu
that were the result of a mirroring bug that we want to get rid of
from autocomplete -- putting them in a useless realm name will do.

(imported from commit 6e305093653ca9d327e9e28491636e99d16cfe1d)
2012-11-14 15:03:49 -05:00
Keegan McAllister 31496e9189 Generalize Tornado-related settings
(imported from commit 76a1338a87e1a6663aa7602a499e2d769814bf08)
2012-11-13 10:59:02 -05:00
Tim Abbott de4548dcb5 populate_db: Don't give huddle senders 2 UserMessage rows per message.
This bug was caught by our new unique_together constraints.

(imported from commit 5392c12cdc8e5c9603652ba2a32ae4400375f14b)
2012-11-08 18:00:46 -05:00
Tim Abbott 2be66f0e8a populate_db: Don't create huddles with 2 copies of the same person in them.
Bug caught by our new unique_together constraints.

(imported from commit 37c1fc459b98050417e907653a5a4fc97004903b)
2012-11-08 17:59:31 -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 3b8dbbc7d7 Use django.utils.timezone.now consistently
(imported from commit f223d9c1f6c77012db342b8be7aaed964b9f18c6)
2012-11-07 18:51:33 -05:00
Tim Abbott ff369373bf populate_db: Strip whitespace from stream names.
(imported from commit a33b4983994040060f8d7631238250297f4d152e)
2012-11-07 17:30:50 -05:00
Tim Abbott 02b7bcf1a4 populate_db: Make double-unsubscribes not a fatal error.
(imported from commit 4dadb28f9c310659ddd780e98da70da55ace7187)
2012-11-07 15:49:45 -05:00
Tim Abbott 6a690d4d4a Create our various bot users without subscriptions.
(imported from commit 9f9249cdb295f147d8b8b5cef17709c9aaa66418)
2012-11-06 16:59:28 -05:00
Tim Abbott a6cd21a1b8 Log events to a file named after the current server.
Merging these log files together is future work.

(imported from commit 54abf1ed41c2d8ba220fd3af0d997256c2718db0)
2012-11-06 14:12:19 -05:00
Keegan McAllister e9c81a4a8b runtornado: Don't apply response middleware twice
This was causing us to log some requests twice, and might have more serious
consequences as well.

(imported from commit 0bb2d7207ee3e4e04679215a7f5ae637cd26aa19)
2012-11-06 13:15:49 -05:00
Keegan McAllister 8259059119 runtornado: Remove ability to run without specifying exactly one port
The zero-port case never actually worked, because addrport wasn't an optional
parameter in run_one.  And multiple ports was implemented using the
multiprocessing library, which is just bad news.  Since we have no need for
this, remove it before it can cause trouble.

(imported from commit 9d913924701f30d23ebe878b76c8f1f0da2800e2)
2012-11-06 13:15:49 -05:00
Luke Faraone 75c6fa7202 When doing a deployment, set the site name to app.humbughq.com.
(imported from commit b89f72f0cb94fae7678db570a1e9774dbe471ba9)
2012-10-30 15:13:12 -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
Tim Abbott 9caf205ed9 Fix missing tables when clearing databases.
(imported from commit 950839216af8366b87564fb310cb1ac47711ae02)
2012-10-29 14:54:18 -04:00
Keegan McAllister da252e8499 runtornado: Abort view processing if request or view middleware returns a response
This is the behavior specified by Django.  Since this was broken before,
our CSRF protection had no effect on Tornado views other than printing
a warning message :(

(imported from commit 7975d3c9b6c18915f917ac2da4592a55f6b6a658)
2012-10-27 17:28:07 -04:00
Tim Abbott 7c8bde5d90 Add log/restore for fullnames and passwords.
(imported from commit 048ca3c86b9f077fcbccd5df4a509191a545da4c)
2012-10-25 15:52:26 -04:00
Keegan McAllister eef027560a Remove unused imports
(imported from commit eb576627ff72e57fee0e3a4c357f51ad74cd6c86)
2012-10-25 15:22:18 -04:00
Tim Abbott 8c4a834206 Add function for activating MIT users.
(imported from commit 0de45fc341249332909d5a0ecef4d49918658a1a)
2012-10-25 14:46:58 -04:00
Tim Abbott 722249a9fc Use a variable for repeatedly referencing old_message['type'].
(imported from commit 1b8e8fef61582dab06ffbb9a9b71c83c2629f0f2)
2012-10-25 14:46:43 -04:00
Tim Abbott 6e1ec1a2ec Move our various bots into api/bots/.
(imported from commit f5803441b9b84872b942dff8e1c0ad1100788bcd)
2012-10-25 13:53:34 -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
Tim Abbott a9667d81a8 Fix performance regression caused by last commit.
(imported from commit f0abf93dbab92c5627903284fafad310de039fe6)
2012-10-22 22:01:55 -04:00
Tim Abbott 8c16295301 populate_db: Fix replaying personal messages from logs.
(imported from commit 685a426fe59fa240c8ae5cf357a43d4df0a3f05d)
2012-10-22 21:36:32 -04:00
Tim Abbott 846469c39c [schema]: Rename userprofile to user_profile.
(imported from commit adfb6152b7ec32557e3465d961695eb870506d5a)
2012-10-22 18:55:45 -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
Tim Abbott a695732bda Seed the populate_db random number generator.
This makes it not to produce 10 copies of each message.

(imported from commit 35ab5f14ec104b4ea52137dac4fa2840194f3777)
2012-10-22 13:59:46 -04:00
Tim Abbott d3a693080e Fix receiving messages on the ShakeSpeare streams.
(imported from commit 4ce60d57e66363da1bd3c2b93fcf008eee795769)
2012-10-20 19:54:29 -04:00
Tim Abbott dab25bdff7 populate_db: Be a little more defensive about message types.
(imported from commit fe23365180847065a9a3292f7873dcb36bb277db)
2012-10-20 19:48:05 -04:00
Tim Abbott 55d9c08c83 populate_db: Fix case bugs importing old messages.
(imported from commit dba8e3419f5827344a42f28c31798fdaff7cf002)
2012-10-20 19:43:06 -04:00
Tim Abbott dcfef6b1a9 Fix restored personals going to the wrong user.
(imported from commit 362c9f3d833c96a5f3530138a0e9360bff183cbf)
2012-10-20 19:20:48 -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 2c89103b23 Actually update current subscriptions based on changes in logs.
(imported from commit b36637562dd0e358f1718d38778c735bb75fd77a)
2012-10-20 18:41:51 -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 b2ce9aaa18 populate_db replay: Parse the json from old messages first.
(imported from commit bdd900b7618ce85d27eebe4d2a745c4d2734cb85)
2012-10-20 10:44:50 -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
Keegan McAllister bbb67f61cc populate_db: Indicate progress on --replay-old-messages
(imported from commit 1f1043bca0952650c744d6012b11d607f2eb3cde)
2012-10-19 15:17:34 -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 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 b2103e61ef print_initial_password: Print API keys too
(imported from commit b4fccc2947cb2c2d9e5f732c6e151bc12f091683)
2012-10-17 18:23:01 -04:00
Keegan McAllister 8a1ba0d720 Add a management command to print the initial password for an account
(imported from commit 0a2b7d8215961801dbd24d9af89785e857b9ba14)
2012-10-17 18:23:01 -04:00
Keegan McAllister cc8a14fcf8 Create accounts with passwords which are deterministic but hard to guess (from the outside)
(imported from commit 964610fec6c4690c1e881f2bab252296663c819a)
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
Tim Abbott 3e994c16b7 Rename/reorganize our urls to be more consistent.
(imported from commit ca3cc7ccd5d7da83a9c60968527378ee1118648e)
2012-10-16 15:56:06 -04:00
Tim Abbott 2de4d1d448 Add social and test to default subs added after DB dumps.
(imported from commit 828c733c9f5d1bdd5fc0aa2e162b800f8db7b22f)
2012-10-11 11:53:57 -04:00
Tim Abbott ac3f4393ff Rename instance to subject.
(imported from commit 6b4693da03f106448c137cf81cf9801cac44f2b8)
2012-10-10 18:01:39 -04:00
Tim Abbott 613010675c Rename class => stream in populate_db.py.
(imported from commit 8546b2e7823f8df0f69b317bb3c6df1a4da49537)
2012-10-10 17:48:17 -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 bc3646691d Rename create_classes to create_streams.
(imported from commit 5c2e1f840e4774d392554a4c4cf49746f10550a9)
2012-10-10 17:47:12 -04:00
Tim Abbott 95f95d7e54 klass => model as a local variable to refer to our models.
(imported from commit c58a3133bfd8db13d34f8def4cf73e7526214e8e)
2012-10-10 17:47:12 -04:00
Tim Abbott 8daff2e05e Rename ZephyrClass to Stream.
(imported from commit ae51b7a9e03f322dfe2dfccd250cbfc23adfe32e)
2012-10-10 17:47:12 -04:00
Tim Abbott 2170c7a352 Rename zephyrs to messages in various local variables.
(imported from commit 91ac7e47c51fdcaf6559b06f07e36b041aad3e2c)
2012-10-10 10:29:48 -04:00
Keegan McAllister e1113a6d08 populate_db: Fix mit_subs_list import
(imported from commit b67abb47892d561b9e300a324528303694bcf8de)
2012-10-06 17:53:05 -04:00
Tim Abbott 9cfa8a868f populate_db: Read from the correct messages log path.
(imported from commit ec7ef103ddf06cdc89c02659ceefcab1f64c89e4)
2012-10-05 14:59:23 -04:00
Tim Abbott 52a36945fe populated_db: Rename many functions/variables from zephyr => message.
(imported from commit d796561eded00511e4dfd7fe2bd5ac102125d4ea)
2012-10-03 18:14:15 -04:00
Tim Abbott 1ab81cff92 [schema] Rename Zephyr => Message in the schema.
(imported from commit 4f402f150c45d2097d6b16943935e6e370b4f8d8)
2012-10-03 18:14:15 -04:00
Tim Abbott 83ceba0a2d Remove old /api/get_updates view.
(imported from commit 5a33a61bfb4b3aa40e28c356f5b4048db775b901)
2012-10-03 16:58:31 -04:00
Tim Abbott cca5f7b76a Rename do_send_zephyr to do_send_message.
(imported from commit df4dc741bf00a197ca5ab39373bc9a3eda379684)
2012-10-03 12:27:34 -04:00
Tim Abbott be1a890a09 populate_db: Restore users' pointers to last after database resets.
(imported from commit d6c5a58173602e7e07b6851a6d22ed129b4f3733)
2012-10-02 16:58:13 -04:00
Tim Abbott 5a5b5de650 Rename /api/v1/get_updates to /api/v1/get_messages.
(imported from commit f856637158cf9fda64ba333b532a5941de8fcbab)
2012-10-02 16:29:34 -04:00
Tim Abbott 18a3888373 [schema] Add an API for sending/receiving messages.
(imported from commit 209d525dc5892fc4c392a8ced1588c838cbb17c4)
2012-10-02 15:49:25 -04:00
Keegan McAllister 4e6a239580 populate_db: Default to mit.edu realm on inport
This is something of a temporary hack.  In the future, we should make
zephyr_mirror.py smarter about fixing up the realms.

(imported from commit bdcff1a834904616538f430b4513ec7619b95e95)
2012-09-28 18:35:38 -04:00
Tim Abbott b43dd303b6 Use tornado for new /api/get_updates query.
(imported from commit 84b85fc5bb0de4144fde00ea13d14f74b1dd9bd1)
2012-09-27 17:37:05 -04:00
Keegan McAllister 20240d869c Rename get_updates_longpoll to get_updates
(imported from commit 15635904584b324bdfa1414caea12c3bc4ce54c8)
2012-09-27 15:46:36 -04:00