Commit Graph

6953 Commits

Author SHA1 Message Date
Steve Howell 3b59952ea3 Extract gather_subscriptions_helper().
The gather_subscriptions_helper() does a separate query to
get emails from user_ids, and it returns an email_dict to its
caller.

This may seem like a step backward, since gather_subscriptions()
now needs to do an additional query, but there is some benefit
in passing fewer redundant emails over the wire from the DB.
The real payoff, though, will come in subsequent commits, where
we will reduce the amount of data going over the wire to the browser,
which will benefit users with slow connections.

(imported from commit bf1cc5828a4c5f68cafd052ea29a177837970206)
2013-10-22 15:51:18 -04:00
Steve Howell 58acef4098 Add get_emails_from_user_ids() action.
(imported from commit 887090de16f685373bd2f3548bd1ec94a7ad4a9e)
2013-10-22 15:51:18 -04:00
Steve Howell 4a53a6680e Test external API for listing subscriptions.
I am about to change the behavior of the internal API, and it's really more
important to have test coverage on the external API anyway.

(imported from commit 8a0723cbcb4ac1819a63397584aa40e69ceb827d)
2013-10-22 15:51:18 -04:00
Zev Benjamin c665139012 blueslip: Send the log back to the server when reporting errors
(imported from commit 013057a8ddc2ddb73b03b0de5c139052b22f5319)
2013-10-22 15:39:17 -04:00
Zev Benjamin 3276f8a4d0 blueslip: Record calls to log, info, warn, and error methods in an in-memory log
(imported from commit 556a92725c492de558269c0760a96783e2a3fc18)
2013-10-22 15:39:17 -04:00
Zev Benjamin 1c841e4454 blueslip: Refactor log, info, warn, and error methods
(imported from commit 4b1eb94a7de0c2b25bde19c3c3a88a13ecb4d1c0)
2013-10-22 15:39:17 -04:00
Zev Benjamin 06390de20a Load underscore before blueslip
blueslip depends on underscore.

(imported from commit 13a379d62bdb9824c052d8695ec030c69f41a5db)
2013-10-22 15:39:17 -04:00
Steve Howell cf0331018a Log client/email in zulip_internal decorator.
(imported from commit 43b7ae75bd5cd3e8a086f82b31507079d999a42b)
2013-10-22 15:03:34 -04:00
Tim Abbott b5fbf67511 bugdown: Fix support for python-markdown >= 3.2.1.
(imported from commit c3c61ad3f75ef0019517084278e34641998a7e22)
2013-10-22 14:44:46 -04:00
Steve Howell c841c0abc0 Remove unused /activity tabs.
The Mirror and iPhone tabs were either unused or misleading
for realm-specific pages of the /activity report.

(imported from commit 8d0a99eac6657fbfd9e6a32f22739eed66e03fbf)
2013-10-22 14:05:12 -04:00
Steve Howell 8711f7450d Add History tab to /activity for realm pages.
(imported from commit 8d51da01ff8a9f4668aca7408b3ccbf9d862b81c)
2013-10-22 14:05:12 -04:00
Tim Abbott b340add1aa bugdown: Disable linebreaks from two spaces at end-of-line.
Arguably the nl2br extension should be doing this for us.  Given that
we're using nl2br, the "two spaces at the end of a line makes a line
break" rule doesn't make any sense (since every newline leads to a
linebreak), so we disable it.

(imported from commit 5ffa2ac8a825642ad31e085c532091e076665710)
2013-10-22 14:04:11 -04:00
Kevin Mehall db71931dab Include is_bot in new user event
(imported from commit 4ae4daaa3ce9b2c2546e1469cc179d209a02c313)
2013-10-22 13:42:22 -04:00
Kevin Mehall a32f15aa2f Add Hubot to /integrations.
(imported from commit 1adc564a50ac473a6a117de24283154fc4222cc3)
2013-10-22 13:42:22 -04:00
Tim Abbott d7a887afe9 nagios: Use latest names for check intervals.
(imported from commit 8fe40c7e45db3c4334716381b0de82364ed670b8)
2013-10-22 13:34:14 -04:00
Zev Benjamin 16a8bce60c Remove redundant return statement
(imported from commit eac3298f3004d2dd519c5444755e729111d13482)
2013-10-22 13:19:00 -04:00
Steve Howell 3be5b9ba0a Fix Activity Test to account for more queries.
(imported from commit f8fa6a1054b2248104e1a4941e9c45f6edd06269)
2013-10-22 12:05:12 -04:00
Steve Howell 124292e556 Remove stray print
(imported from commit 88911bf8ce610de72947e7b4bf0f2eccffa86bd7)
2013-10-22 12:04:05 -04:00
Steve Howell 760e6483c4 Report on Hubot and friends on /activity.
This fixes the following two closely related tabs:

    Integrations by domain
    Integrations by client

They now blacklist clients instead of whitelisting them, so
we can see newcomers like Hubot and Giphy bot.  Our naming
convention still leaves a lot to be desired.

(imported from commit 66cbd07160d93e4b745a1439261330d854700a5c)
2013-10-22 11:59:27 -04:00
Steve Howell 3be4641625 Subsume /queries into the main /activity report.
This moves the reports from /queries into six new tabs on the
main /queries report.

(imported from commit e4ccf6e7edfc900d929e85613f21437b40f046ae)
2013-10-22 11:11:54 -04:00
Steve Howell 5562f09d99 Add zulip_internal decorator for internal Zulip reports.
(This also ensures that /queries is viewable only from inside
Zulip.)

(imported from commit 697da768889943ab6cea62b3e922cc43afa04759)
2013-10-22 10:15:08 -04:00
Steve Howell 1f4b70938f Add /sent_messages_report to show sent messages per realm per day.
This shows the number of messages sent by users in a realm going
back two weeks.

(imported from commit 9bf677b908f947efef4e00a43d323e1049a9157a)
2013-10-22 10:15:08 -04:00
Tim Abbott cc2284c531 Fix auth checks for IRC mirroring.
There were a couple of bugs in the security checks that resulted in
IRC mirroring of stream messages not working.

(imported from commit 31ac732461a733c1c993f77356053d4f88c67177)
2013-10-21 16:47:40 -04:00
Kevin Mehall d92939d53e [important] Fix regression in 9259a24
Use the new count_full_messages_between instead of subtraction in
message_list_view.append. By finding a count higher than it should be
when summarized messages are present, it didn't add new messages until
the pointer moved under certain conditions.

(imported from commit c10d9c1a0d23891acce88bf8d79866c08cb75681)
2013-10-21 16:01:18 -04:00
Tim Abbott 1f3278888e get_old_messages: Fix query for the sender narrow operator.
Previously we were having the database do the matching on sender email
address, which resulted in an unnecessary join.

(imported from commit 70bf791a00b7d5965ef977e45b4a0eccbd3402a0)
2013-10-21 16:00:24 -04:00
Tim Abbott 3846494f9e Decrease font size for block code blocks to match other text.
Currently, code blocks end up with scrollbars annoyingly frequently --
even with a maximum width window, you can't fit a standard 80
character terminal worth without needing a scrollbar.  This change
causes our code block text to be the same size as normal text and
inline code blocks.

(imported from commit c2fc7e008cc514e90387f8f0db2b49e357cf4f62)
2013-10-21 14:59:19 -04:00
Tim Abbott 8f1fc7c968 Update mirroring backend to support IRC mirrors.
(imported from commit 771aa59b780da0aed2fc7e43d20229e7f42ad06d)
2013-10-21 14:39:21 -04:00
Tim Abbott c34be3a91f Make the forged_timestamp field optional for mirror messages.
(imported from commit 6d03d374bce0d59b0e13c944af7b620a7336a86f)
2013-10-21 14:37:36 -04:00
Tim Abbott d58b4e92dd Add irc-bot@zulip.com as an API superuser.
(imported from commit 36aa0faf8c3ccd8454f214986f32da4f37236921)
2013-10-21 14:37:36 -04:00
Tim Abbott 924c5fea24 api: Add support for specifying client using zulip.init_from_options.
(imported from commit f92db44af606d67d5a1dcc9c978cee0d079d466d)
2013-10-21 14:37:36 -04:00
Tim Abbott 080f5922e1 lint-all: Fix gotcha regexps to not misparse certain quoting cases.
(imported from commit fed305fce9cf6f88e05f4d7310e25928ae6add4b)
2013-10-21 14:37:36 -04:00
Tim Abbott bd107dbb4e logging: Properly log the client for / as website.
(imported from commit 5d3cbbd26994dc5dd6d605a056947dbae19810a8)
2013-10-21 14:33:24 -04:00
Tim Abbott 5806a6e508 logging: Log the type of the narrow for get_old_messages.
(imported from commit 9e6471c10602242c924f29d29bc780667ac17672)
2013-10-21 14:33:24 -04:00
Tim Abbott 1d4f39f55a logging: Update slow query logger to not display client string.
I believe with this change the log lines will fit much better into
Zulip, and the Client string was I suspect rarely important for
responding to slow queries (and is always available in the main log
anyway).

(imported from commit ad56f446bf3fb96a14a56b825f46c1dad9b6babe)
2013-10-21 14:33:24 -04:00
Tim Abbott f3fee40d1d logging: Don't log query parameters for GET requests.
(imported from commit 4f764ae0168f6b0ad73d13a15ca7e0895514951c)
2013-10-21 14:33:24 -04:00
Kevin Mehall bd58861b09 Ignore summarized messages when calculating rendering windows.
Summary blocks can contain hundreds of messages. When the rendering window
code didn't take this into account, it would lead to all kinds of
unpleasant behavior when you scroll.

Trac #1888

Unfortunately, this replaces a subtraction with a function that iterates
through all the messages.

(imported from commit 9259a246946cd968a8725c38ff5ef2d4b4793717)
2013-10-21 11:48:57 -04:00
Kevin Mehall ba87ebc246 Fix duplicated summary blocks when scrolling up.
Make prepend re-render the whole render window instead of just the added
messages.

(imported from commit 6270a33ff0fe98fc901b687ca533ef0ea127d052)
2013-10-21 11:48:56 -04:00
Kevin Mehall a528b7134c Move summary_adjective to its own method
(imported from commit d451ffcf3ff460ffe030e265ca83fec1094c6217)
2013-10-21 11:48:56 -04:00
Kevin Mehall 463b10cf0e Enable summarization only for the right narrows.
* Disable for search-like narrows (whitelist stream and home instead of
    blacklisting topics and PMs)
  * Use home view summarization flag for All Messages

(imported from commit 48bd10ae5da7c7564c2efe86a40078f1a7e96e20)
2013-10-21 11:48:56 -04:00
acrefoot e35e2d62b4 In invitation reminders, take advantage of realm names
(imported from commit 68607b015c640529d4d65065ace82a18d57610a3)
2013-10-21 11:33:34 -04:00
acrefoot 1d6e841964 Queue invitation reminder email
The queued email gets deleted if the user signs up before it gets sent.
Otherwise, they are reminded in 2 days that they still haven't signed up.

This addressses Trac #1812

(imported from commit c1bdc09c03ac576b08986e56994de72d52fd293b)
2013-10-21 11:08:38 -04:00
acrefoot 776feb84e9 Make mandrill actions better
clear_followup_emails_queue now filters by from_email too
send_local_email_template_with_delay passes the template_payload into the subject template

(imported from commit 8044fe2ebad90a9d6d5c67cdfdd08801760fd7f7)
2013-10-21 11:08:38 -04:00
Steve Howell 03c856ce10 Add create-stream management command.
The current version should only be used for testing; for example,
if you want to create a bunch of streams for stress testing, you
can run this in a loop.

(imported from commit ec51a431fb9679fc18379e4c6ecdba66bc75a395)
2013-10-19 09:28:59 -04:00
Steve Howell e0fa6e427b Tone down postgres lock warnings
(imported from commit 11cad022a15b3269294c59b9acd2a8fab2a52a5f)
2013-10-18 17:05:45 -04:00
Tim Abbott eaaf0fec04 [schema] Add case-insensitive index on stream names.
We need to run the schema migration manually using

"CREATE INDEX CONCURRENTLY upper_stream_name_idx ON zerver_stream ((upper(name)));"

since we need CONCURRENTLY and I seem to recall that doesn't work with South.

This significantly improves the uncached performance of get_stream()
(e.g. from 32ms to 9ms).  At present, this codepath is not used
particularly heavily since we do cache the stream names and do most of
our filtering by recipient ID, but the index isn't expensive and does
provide a significant improvement in the uncached case.

(imported from commit 4d28dc2e9a02d0602861b165393d90ed18f5f4c8)
2013-10-18 16:38:31 -04:00
Tim Abbott 4d94d4d6f6 [schema] Add case-insensitive index on message subject field.
We need to run the schema migration manually using

"CREATE INDEX CONCURRENTLY upper_subject_idx ON zerver_message ((upper(subject)));"

since we need CONCURRENTLY and I seem to recall that doesn't work with South.

Apparently our existing indexes on subject/topic weren't being used in
our narrowing queries, because we do case-insensitive search.

This substantially improves our database performance around
stream+topic narrows.  See before and after query plans below from my
test instance.

humbug=# explain analyze SELECT "zerver_message"."id" FROM "zerver_message" WHERE ("zerver_message"."recipient_id" = 38  AND UPPER(zerver_message.subject) = 'TEST'  AND "zerver_message"."id" <= 348495 ) ORDER BY "zerver_message"."id" DESC LIMIT 50;
                                                                       QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------
 Limit  (cost=13510.61..13510.71 rows=41 width=4) (actual time=32.952..32.958 rows=2 loops=1)
   ->  Sort  (cost=13510.61..13510.71 rows=41 width=4) (actual time=32.946..32.947 rows=2 loops=1)
         Sort Key: id
         Sort Method: quicksort  Memory: 25kB
         ->  Bitmap Heap Scan on zerver_message  (cost=237.99..13509.51 rows=41 width=4) (actual time=2.357..32.912 rows=2 loops=1)
               Recheck Cond: (recipient_id = 38)
               Filter: ((id <= 348495) AND (upper((subject)::text) = 'TEST'::text))
               ->  Bitmap Index Scan on zephyr_message_recipient_id  (cost=0.00..237.98 rows=8221 width=0) (actual time=1.178..1.178 rows=10354 loops=1)
                     Index Cond: (recipient_id = 38)
 Total runtime: 33.049 ms
(10 rows)

humbug=# explain analyze SELECT "zerver_message"."id" FROM "zerver_message" WHERE ("zerver_message"."recipient_id" = 38  AND UPPER(zerver_message.subject) = 'TEST'  AND "zerver_message"."id" <= 348495 ) ORDER BY "zerver_message"."id" DESC LIMIT 50;
                                                                          QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------
 Limit  (cost=435.11..435.22 rows=41 width=4) (actual time=4.998..4.999 rows=2 loops=1)
   ->  Sort  (cost=435.11..435.22 rows=41 width=4) (actual time=4.997..4.997 rows=2 loops=1)
         Sort Key: id
         Sort Method: quicksort  Memory: 25kB
         ->  Bitmap Heap Scan on zerver_message  (cost=275.63..434.02 rows=41 width=4) (actual time=4.981..4.984 rows=2 loops=1)
               Recheck Cond: ((upper((subject)::text) = 'TEST'::text) AND (recipient_id = 38))
               Filter: (id <= 348495)
               ->  BitmapAnd  (cost=275.63..275.63 rows=41 width=0) (actual time=4.954..4.954 rows=0 loops=1)
                     ->  Bitmap Index Scan on upper_subject_idx  (cost=0.00..37.38 rows=1744 width=0) (actual time=2.972..2.972 rows=27457 loops=1)
                           Index Cond: (upper((subject)::text) = 'TEST'::text)
                     ->  Bitmap Index Scan on zephyr_message_recipient_id  (cost=0.00..237.98 rows=8221 width=0) (actual time=0.855..0.855 rows=10354 loops=1)
                           Index Cond: (recipient_id = 38)
 Total runtime: 5.049 ms
(13 rows)

(imported from commit 1f4815ccb0691053ff8d505149482dbc74153fb3)
2013-10-18 16:38:31 -04:00
Kevin Mehall 89d149c6f7 Fix @-mention "not subscribed" warning for all_public_streams bots.
Don't warn when @-mentioning a bot on a public stream that it does
not appear to be subscribed to. It may be receiving those messages
anyway.

(imported from commit 4a00694942a721897a01736f48033c71048e0b16)
2013-10-18 14:55:32 -04:00
Kevin Mehall 7b8dea3d54 Add all_public_streams parameter to register API.
It makes the event queue return all messages on public streams, rather
than only the user's subscriptions. It's meant for use with chat bots.

(imported from commit 12d7e9e9586369efa7e7ff9eb060f25360327f71)
2013-10-18 14:55:32 -04:00
Jessica McKellar 06566b3776 Don't receive notifications for messages on muted topics.
This doesn't address the more complicated case of someone @-mentioning
you on a muted topic, which consensus is you do want to get
information for, but we need to develop some infrastructure to present
that case to users clearly.

(imported from commit a4bc1e89c108fa8ba6eccc0a198eabf2231326ab)
2013-10-18 14:38:31 -04:00
Jessica McKellar efda426b86 notifications: split message_is_notifiable into multiple ifs for clarity.
(imported from commit 33d1e2135a87192cc4d964db534b31ae9335595a)
2013-10-18 14:38:31 -04:00