Commit Graph

690 Commits

Author SHA1 Message Date
Tim Abbott 8b4d406083 get_old_messages: Use a raw database query for empty narrows.
This improves the performance of the get_old_messages queries when
loading the home page by about a factor of 2.5x.

(imported from commit 581840a6ed7b391c9d9fde67f368fce816e567e2)
2013-06-24 10:17:10 -04:00
Tim Abbott a8d86d5fb2 get_old_messages: Refactor handling of UserMessage flags.
This is in preparation for having a case in which we query the
database directly to get the message flags, without going through a
UserMessage object.

(imported from commit d5218974680b0c4b028a84f3aae1c8242ceb08ce)
2013-06-24 10:17:10 -04:00
Tim Abbott e5e0544816 get_old_messages: Clean up code duplication in database queries.
(imported from commit c35aa71fc848c77f9c5c8edd8cc8acaa9481df74)
2013-06-24 10:17:10 -04:00
Tim Abbott 631a9048f7 Send message dicts to memcached as JSON dumps.
memcached stores objects sent to it using pickling, which is very
slow.  We work around this by sending memcached strings (i.e. JSON
dumps); pickling doesn't slow things down too much if all it is
getting is a string.

(imported from commit 0f0e534182eccb76c5731198e05a9324a1cef316)
2013-06-24 10:17:10 -04:00
Tim Abbott 222ef672b5 [manual] Use ujson instead of simplejson.
This saves something like 15ms on our 1000 message get_old_messages
queries, and will save even more when we start sending JSON dumps into
our memcached system.

We need to install python-ujson on servers and dev instances before
pushing this to prod.

(imported from commit 373690b7c056d00d2299a7588a33f025104bfbca)
2013-06-24 10:17:10 -04:00
Steve Howell b896c587e2 Extracted S3-related code to lib/upload.py
(imported from commit 4f0b0012b89d21b3bd445a2a6f84f3de72190e13)
2013-06-19 18:10:45 -04:00
Steve Howell 2b320f8d57 Allow user to upload an image for their bot's avatar (back end).
(imported from commit 34833b61b935f4eec2b23abbb3532aaa58e13fb6)
2013-06-19 10:21:20 -04:00
Zev Benjamin 80702ccaa0 Add metrics variables to the template context via a context processor
Wrapping render_to_response never actually worked correctly.  On the
login page, mixpanel_token would be missing, but we wouldn't get an
error because it is surrounded by double quotes, which meant that it
was still valid Javascript.

(imported from commit 820ee42fab8f679983e5a3a4309a2feaf690f20f)
2013-06-18 17:07:36 -04:00
Leo Franchi 625f8427e6 Return both subscribed and unsubscribed stream information when listing streams
(imported from commit 0aee84712eefd93aebc1041b371e471182eb7e9b)
2013-06-13 10:06:34 -04:00
Steve Howell d740d7c082 Show user-uploaded avatars on the website.
Show user-uploaded avatars on the website for users who have
UserProfile.avatar_source == 'U'.  (Continue to show gravatars
for other users.)  This includes the home page, the visible-phone
div, and the settings page.

This fix does NOT address a few things:
* There is no GUI to actually upload user images yet on the website.
* The !gravatar syntax in bugdown will continue to show gravatar images
  only.
* We are not changing identicon behavior.

(imported from commit 9f5ac0bbe21ba56528048233aab2430e4dd431aa)
2013-06-12 15:34:51 -04:00
Leo Franchi 76c9e27a76 Disable composebox experiments on prod
(imported from commit a553320e7d775978ee31af0f8920cbfeb705f5cb)
2013-06-11 11:41:34 -04:00
Leo Franchi 3cb34cf246 Rate limit jira and beanstalk API endpoints
(imported from commit ea299df983d53ee3f917f3c7314e78e813fe95a2)
2013-06-07 10:32:41 -04:00
Leo Franchi 0b5b1dafc4 Add a rate limiting system to our backend
(imported from commit a1218618918b4dedc77307e2f277665e7dd8fa22)
2013-06-04 09:43:09 -04:00
Jessica McKellar 088984b31a Don't let CUSTOMER4 users invite new users to the realm.
As requested by the facilitators: only they should be able to invite
new people.

(imported from commit 636e332759b9ad56a8d45115d92326a929472c14)
2013-06-02 13:23:04 -04:00
Steve Howell 3f1b3af002 Add "Mentioning messages" to the upper left sidebar.
Treat "mentioned" messages like "starred" messages for narrowing.

Lots of ugly copy/paste here.  There might be opportunity for
some cleanup in places.

(imported from commit e7629890d42643c0000e1cc85422b2a0690f2cc4)
2013-05-30 14:45:01 -04:00
Keegan McAllister 52e0aa59a6 Minify third-party JavaScript and CSS in production
(imported from commit 943d712bc460640d7a689ac678922d9c5bf7aa9c)
2013-05-30 13:51:47 -04:00
Leo Franchi 81058f5f9b Reset our 24hr email blackout when a user logs in
(imported from commit 93bed7c4d049ba4d7b30d2e02fbbe0d2debca6f8)
2013-05-24 21:23:59 -04:00
acrefoot 9454683108 [manual] Send new-stream invitations using a bulk database query
Messages that get sent out when someone subscribes many people to a new stream each
cause individual database queries (and their associated transactions). With the patched
bulk_create (which sets the .id on created objects), we can reduce this query down to a constant
number of queries on the Message and UserMessage tables.

Note for deployment (local dev, staging and prod):
you must be running a patched django, found here: https://github.com/acrefoot/django/branches
use this branch: acrefoot-bulk_create_with_id-1.5.1
on acrefoot-bulk_create_with_id-1.5.1
relevant sha1: ac6d885b811f7e2e34f0db0da217983f7dfd357f

(imported from commit b0dab9dac784d3ff47751e65bf22c2dddc22edf5)
2013-05-24 21:23:57 -04:00
Leo Franchi 4fc7c7c797 Support JIRA workflow post-function web hooks
(imported from commit cf70730f4c5a847835f07f0048559269f3afd06e)
2013-05-24 21:23:56 -04:00
Zev Benjamin ae9be7298d Wrap render_to_response
(imported from commit d23aa3e5ad4c5243e83df098953ea4b1f7b3c294)
2013-05-21 17:56:49 -04:00
Leo Franchi 813073ec32 Hide known warnings in unit test output
(imported from commit 484b383b7466f4428bbde55344775687149406b9)
2013-05-21 14:05:48 -04:00
Tim Abbott 2bdecd130a Add user interface frontend for editing messages.
The only known outstanding bug with this is that it doesn't properly
handle the updating of a message's highlighting/presence in a narrowed
view (e.g. in theory, a message should disappear if it is edited such
that its subject doesn't match your narrow or it no longer matches
your search).  I think I'll just open a trac ticket about that once
this is merged, since it's a little hairy to deal with and kinda a
marginal use case.

Also it's not pretty, but that should be easy to tweak once we get the
framework merged.

Conflicts:
	tools/jslint/check-all.js

(imported from commit 2d0e3a440bcd885546bd8e28aff97bf379649950)
2013-05-20 23:40:57 -04:00
Tim Abbott d467a93877 Add support for updating messages after they've been received.
Currently the interface for editing messages is limited to a
command-line API tool; it's great for testing with e.g.:

./api/examples/edit-message --message=348135 --content="test $(date +%s)" --site=http://localhost:9991 --subject="test"

The next commit will add a user interface for actually doing the editing.

(imported from commit bdd408cec2946f31c2292e44f724f96ed5938791)
2013-05-20 23:40:26 -04:00
Leo Franchi 0846ebd4b5 Revert use of rest_dispatch for beanstalk
For beanstalk we need to provide a decorator that converts %40 to @ in the
http basic auth part of the URL. However, if we put our own wrapper around
rest_dispatch, the Django CSRF protection jumps in. This requires us to put
@csrf_exempt on our extra dispatch function, at which point we might as well
have avoided rest_dispatch in the first place and put a @csrf_exempt decorator
on our api_beanstalk_webhook.

(imported from commit b1f459aad26a5b80cce93f6c859240a53c11cc22)
2013-05-20 23:37:58 -04:00
Leo Franchi cf3f62185c Handle unknown JIRA event types
(imported from commit 3760002996bac0a4c2b7b4cc8bff2026fb11978a)
2013-05-20 23:37:57 -04:00
Leo Franchi 3197a7fb89 Use rest_dispatch for beanstalk API
(imported from commit 9c261f648b39bb472718bbc763fd15883cbda4e9)
2013-05-20 23:37:57 -04:00
Waseem Daher 4480693f1a Signup page to collect beta customer info.
(imported from commit ce4e860aa6781aa74ca954c79ae133aa50a057f1)
2013-05-20 23:29:55 -04:00
Tim Abbott 56949b4788 Create subscription objects in bulk by user_profile.
This, combined with acrefoot's work on sending the notifications in
bulk, resolves trac #1142 -- we do only 10 database queries and the
whole operation completes in about 300ms on my laptop.

(imported from commit 36b5bb836bc6c713903d1ca72e39af87775dc469)
2013-05-20 23:29:54 -04:00
Zev Benjamin 0f6c9e7b6f search: Handle quoted, multi-word queries
This does the simple thing, which will work as long as the phrase
doesn't have any punctuation and contains the exact text being
searched for.  We really want phrase search (check if the lexemes in
the query occur in sequence in the input lexeme string), but Postgres
doesn't support that natively.

(imported from commit 67bf36883ed21743fcad3f02ad5b319ab188f816)
2013-05-17 01:02:35 -04:00
Leo Franchi 1902f6f149 Handle any malformed JSON input instead of just an empty body
(imported from commit a8a99173697ab6fb1ec60cf499e40cde8b8549d5)
2013-05-17 01:02:33 -04:00
Leo Franchi 9ffbc6d4ab Gracefully handle a jira POST request with no content
(imported from commit d11eb4462216c5344f1231bf92159bad84a8a583)
2013-05-17 01:02:33 -04:00
Tim Abbott c7f44f97d6 rest_dispatch: Apply process_as_post automatically.
(imported from commit 35a4710e2050efe268ed6d2e63a41eea1ebc1d24)
2013-05-17 01:02:33 -04:00
Luke Faraone 96048ca140 Record the realm of users in Mailchimp
THE CENSUS OF HUMBUG

Now it happened that at this time Waseem Daher issued a decree that
a census should be made of the whole users of Humbug.

This census -- the first -- took place while Faraone was governor of
MailChimp, and everyone went to be registered, each to his own realm.

So Alice Humbugger set out from the town of MIT for MailChimp in order to
be registered.

(imported from commit fca7714ebffd0b39b9b1337058f67975985f4039)
2013-05-17 01:02:32 -04:00
Tim Abbott b8e1809f94 Fix is_super_user_api for REST API.
(imported from commit 94ba18656ca3b0636da9d5ca7969872b31ae970b)
2013-05-14 15:18:21 -04:00
Jessica McKellar f37540bbda Add onboarding UI functions for displaying and completing setup items.
(imported from commit 9ba9cb09d5ad2845ceeda436f89f7d22a19c3fbc)
2013-05-14 10:27:40 -04:00
Jessica McKellar c6da73ade9 onboarding: add endpoint for updating your onboarding steps.
(imported from commit 30c326b50cd2273099aa464f2d9502f929a3d48f)
2013-05-14 10:27:39 -04:00
Zev Benjamin c9114eef9d Add json queries for creating and fetching user bots
(imported from commit f745a705dedca66cf671ef19d7bc5f46ce70a306)
2013-05-11 02:38:32 -04:00
Luke Faraone e18d76f4dd Readd a default for enable_sounds in json_change_settings.
Previously a default was missing from this function, which resulted in
users being unable to change their settings if they tried to disable
sounds.

(imported from commit 2dae67dcb2e8cb986abb6dee9659be2192993dd9)
2013-05-10 15:15:57 -07:00
Tim Abbott f1b5d69622 decorators: Replace POST with REQ everywhere.
It's strictly more functional, and having a single arguments
extraction decorator makes our codebase less confusing.

(imported from commit 2a5618c04b486268a462a24a1481ac030f15eac4)
2013-05-09 10:35:49 -04:00
Leo Franchi 4173862833 Send notification with missed message to users if they received a PM while offline
This is configurable in the user's settings on Humbug

(imported from commit 80bf6d7a6f0dc3811117548e2225865db8b533d9)
2013-05-09 10:35:48 -04:00
Tim Abbott 74148518b4 events: Fix the requesting client type being always internal.
(imported from commit b03bee006547ee811c2f0af66d82dfe6bc4331fc)
2013-05-09 10:35:47 -04:00
Leo Franchi 0da2f51ddb Calculate presence information with delta between server timestamp
(imported from commit b4b367ed620878e6d01287cb1aaae0730c7475c8)
2013-05-06 13:52:23 -04:00
Luke Faraone 6bc2d21b87 Make audible notifications a tunable.
This decouples from Chrome notifications, which gives us cross-platform
support in at least modern browsers.

We log this action so its replayable in our message logs.

This implements the model change indicated by the previous schema commit.

(imported from commit b21213cdde54f43670bbb0bf1f607147fc732b38)
2013-05-03 15:08:49 -07:00
Leo Franchi 33eef54c5b Re-send unread message counts if XHR fails
(imported from commit 062e76ca7db177540ed4e9ab0d331b9ecc2ee5f1)
2013-05-03 11:14:46 -04:00
Tim Abbott bfaa698ea6 get_old_messages: Don't fetch messages from database unless we have to.
Previously, we were fetching Message.objects.select_related() from the
database, even if we actually ended up fetching the message dicts from
memcached and thus not actually using them.  Especially in the cached
case, this resulted in a lot of overhead where the Django ORM put
together Message objects with lots of data in them that were never
used.  This commit switches the model to only fetch the full message
objects from the database for those messages which are not found in
the memcached caches.

Here are the timings for get_old_messages before this patch was applied:

(cached)
127ms (db: 42ms/2q) /json/get_old_messages (starnine@mit.edu via website)
385ms (db: 105ms/1q) /json/get_old_messages (starnine@mit.edu via website)

(uncached)
315ms (mem: 6ms/41) (db: 90ms/22q) /json/get_old_messages (starnine@mit.edu via website)
507ms (db: 94ms/14q) /json/get_old_messages (starnine@mit.edu via website)

Here are the timings for get_old_messages after this patch was applied:

(cached)
 80ms (db: 9ms/2q) /json/get_old_messages (starnine@mit.edu via website)
133ms (db: 4ms/1q) /json/get_old_messages (starnine@mit.edu via website)

(uncached)
230ms (mem: 9ms/41) (db: 48ms/23q) /json/get_old_messages (starnine@mit.edu via website)
385ms (db: 55ms/15q) /json/get_old_messages (starnine@mit.edu via website)

(imported from commit c4748513392a906393314aa7cd41d98a69865411)
2013-05-02 15:32:23 -04:00
Zev Benjamin e1c8d2f50f Return match_subject and match_content from messages_in_narrow()
This fixes a bug where if you were narrowed to a search and received
a new message that belonged in that search, the message would appear
to have an empty subject and content.

(imported from commit fe1dbf584d3659d57c5b70c7eb45cb22bbc9732f)
2013-05-01 21:52:04 -04:00
Steve Howell 7dd64eb157 Handle github sending empty string for the stream.
(imported from commit 2fd85db1828be44ef63920d5df347b5f85acb573)
2013-05-01 17:39:54 -04:00
Steve Howell be1e18f864 Support branches whitelist for github
(imported from commit 066bb8ee028778cb39b43afc9737fd2117c91928)
2013-05-01 17:19:53 -04:00
Steve Howell b645c67994 Use stream from github webhook call (if supplied).
(imported from commit 4f57c4dec8ab5e833583a2b5912a92e8a2bd34c0)
2013-05-01 17:19:53 -04:00
Tim Abbott 9f0fc7c031 blueslip: Include window.location.href in error reports.
This can be useful for debugging what sort of narrow is happening in
addition to the URI decoding bug we're currently experiencing.

(imported from commit 0cb55fec4ac1afa986c747eb79236b4300c9e636)
2013-05-01 16:10:35 -04:00