Commit Graph

259 Commits

Author SHA1 Message Date
Tim Abbott e77b34ed82 api: Extract client strings from UserAgent.
(imported from commit 22468dd0eb06bb52ed7273f3067ae3e2461ee0a5)
2013-12-19 17:20:43 -05:00
Tim Abbott 8c8c5337ef UserPresenceTests: Fix use of API auth with json view.
While it does work, it's more an accident than intentional behavior
and not something we want to be encouraging (and it's messier code).

(imported from commit 3797147fc21836135a6304412bd3f958873a0576)
2013-12-19 17:20:43 -05:00
Steve Howell 7cded2a956 Show realm history on the main activity page.
This shows the number of messages sent by humans for the last
eight 24-hour periods, for each realm.  "Messages sent" isn't a
perfect metric of activity, but it's easier to query with our
current data model than certain other statistics.

(imported from commit 9de3c479640a0b9dbc017b245dda21d951f4efa4)
2013-12-18 16:01:44 -05:00
Steve Howell 6f573feaeb Add "length" option to check_list validator.
(imported from commit 4f8e203f964d1c936fe548b2f77a2e4aae745ae9)
2013-12-18 12:45:29 -05:00
Steve Howell e7a42ffd02 Add test for /json/set_alert_words.
(imported from commit 307d87331870a89713030e8178b1aa14a31cfdfd)
2013-12-18 12:45:28 -05:00
Steve Howell 94e3c02649 Add test_bulk_invite_users().
(imported from commit bc8ab756dae0fd82e73b5b2a9655974c5fc839b0)
2013-12-17 16:24:59 -05:00
Steve Howell bfb54b5a4d Add validator support to REQ and has_request_variables.
Validators are similar to converters, but they don't have
to parse JSON, and they are told the name of the request
variable to help format error messages.

(imported from commit 3c33e301892519c67e70675006d5686d9f013353)
2013-12-13 18:19:10 -05:00
Steve Howell 60917c83d6 Add test_REQ_converter.
(imported from commit 4425c68a532dc8a6db3b76397156c4e9d92a5b44)
2013-12-13 18:19:10 -05:00
Steve Howell 668c0ab529 Validate principals in add_subscriptions_backend.
Make sure that principles is a list a of strings (unless it
is None).  This includes a unit test.

(imported from commit c2e3f1c0cafc207ceca67d5a174ef4e29a32c6ca)
2013-12-13 18:19:10 -05:00
Steve Howell 0cdcf102a0 Validate parameters in update_subscriptions_backend.
w/unit tests added

(imported from commit a0c0d779279b35ffc5bf1fbe4c5c5a25af263c10)
2013-12-13 18:19:08 -05:00
Steve Howell 6b70e9ddb7 Add SubscriptionRestApiTest.test_basic_add_delete.
(imported from commit 735d6a0657952790de1d58c62cc983320ec402e8)
2013-12-13 18:19:08 -05:00
Steve Howell 4184b9d56f Add validators.py (with tests).
This sets up a scheme to validate complex data structures and
give specific error messages for improperly typed parameters.

(imported from commit 33b2f070d993da4ee929119dd41503bd0128c8eb)
2013-12-13 18:19:07 -05:00
Waseem Daher 14a5c6bf66 twitter: Detect link styles more robustly.
* Deal with shorter tweet IDs
  (some old tweets don't have a full 18-character ID)
* Allow trailing slash
* Deal with old-style #! syntax
* Deal with links that link to a photo

(imported from commit 008a98c806f3b8dddd9e2f18a8f002af6932766f)
2013-12-13 18:13:23 -05:00
Kevin Mehall ebab4a59c9 Don't proxy https images through Camo on MIT
These images at least load now, but that's because Camo redirects
the browser to the origin server, so the only effect is an extra
round-trip time.

(imported from commit 0d6b9c888a5cdfaa9299272d74a085e872dfa434)
2013-12-13 17:27:01 -05:00
acrefoot 1bd420f12c Show auto-scroll forever setting in /#settings
(imported from commit fa66cbe52836f230e551f25c47bd755b705387d2)
2013-12-13 11:50:11 -05:00
Tim Abbott 2e62cd5a74 Add tests for the events_register event application system.
(imported from commit 6c3dbe55d43f528b6a980bba3598ac30c0307a69)
2013-12-12 17:36:41 -05:00
Tim Abbott 71ad82b6aa Add support for event queues with an included narrow.
This will allow us to substantially decrease the server-side work that
we do to support our Mirroring systems (since the personal mirrors can
request only messages that user sent) and also is what we need to
support a single-stream Zulip widget that we embed in webpages.

(imported from commit 055f2e9a523920719815181f8fdb44d3384e4a34)
2013-12-12 17:36:39 -05:00
Tim Abbott bd977e9e5c Add a basic test for the get_events API backend.
(imported from commit 6f5351947f2b30f13c3309720c8c7c2187d16d51)
2013-12-12 17:36:38 -05:00
Tim Abbott 0a7c6ac261 Remove legacy /api/v1/update_pointer endpoint.
(imported from commit 4e2d111cf00ab2064291b282795c4b89835d1c17)
2013-12-12 10:31:05 -05:00
Tim Abbott 0c79465950 Remove legacy /api/v1/get_profile endpoint.
(imported from commit c8e78be4c8549022556099cc13342627323c0b01)
2013-12-12 10:31:05 -05:00
Tim Abbott 01428e5076 Remove legacy /api/v1/get_old_messages endpoint.
(imported from commit 2ca426f08f9f862e756a1fda55bb2764997aeb76)
2013-12-12 10:31:04 -05:00
Tim Abbott 795f716daf Remove legacy /api/v1/get_public_streams endpoint.
(imported from commit 49db0232e7f655308847f3ccef2b73368ab9b774)
2013-12-12 10:31:04 -05:00
Tim Abbott 2f1382d0b8 Change test names in running printout to be what test-backend takes.
(imported from commit 330aa6ca4ad5f8ebfe30042039d4a04d78f1691f)
2013-12-12 10:31:04 -05:00
Tim Abbott 0a952b1a66 Fix abuse of bugging login behavior with API URLs.
(imported from commit 3009cd094dff8891da415e1bfcf596ea6cb38abc)
2013-12-12 10:31:04 -05:00
Tim Abbott 33cdf0d019 Remove obsolete /api/v1/subscriptions/add endpoint.
(imported from commit 838e3a29219acf157f16258a46b0719d97ae46de)
2013-12-12 10:31:04 -05:00
Tim Abbott 664270a1c4 tests: Add put/delete helpers to avoid manually urlencoding.
(imported from commit 120b564b27ffd711e0f4e63279971433fb4aaa9b)
2013-12-12 10:31:04 -05:00
Tim Abbott 752e7aa84a Remove obsolete /api/v1/subscriptions/remove endpoint.
(imported from commit 9fc6bdb4cc288aa7499399d1d281fb752ea3a52e)
2013-12-12 10:31:03 -05:00
Tim Abbott 23a3b078d6 Remove legacy /api/v1/get_subscribers endpoint.
(imported from commit 52ab7b1200c2a62d1f8c251ab8d2f187cd2eb50b)
2013-12-12 10:31:03 -05:00
Tim Abbott cacd60860a Remove legacy /api/v1/subscriptions/list endpoint.
(imported from commit 457ceec760488815a24b5695362a42f4a94aabdc)
2013-12-12 10:31:03 -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
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
Leo Franchi 2c39e28ff6 Use realm filters from the database in bugdown
(imported from commit 8e12bfb1b1fe9cad694f80a189efa64b0f102e81)
2013-12-11 14:39:10 -05:00
Leo Franchi 1e7a22f14e Replace other non-zerver uses of iPhone client
(imported from commit 0988e2c9bd0499a0711daed97f89aa672776f085)
2013-12-03 14:35:24 -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 0156e72352 Add tests for our event queues data structure.
(imported from commit 5c00251998d25cf2283737173e5af0b26ccbdad4)
2013-12-03 12:20:28 -05:00
Jessica McKellar 11d5f8bbc5 Add a test for unsubscribing from digest emails.
(imported from commit 145c25ae99cf66b9a447b2e3a44a3b7344dc9f59)
2013-12-02 18:58:04 -05:00
Tim Abbott 2a0c2207d2 Revert "Add tests for our event queues data structure."
This reverts commit 5be116d6cc983edaac240e83d1b950faa08d164c.

(imported from commit bc47f42235e9800906270a5776167f5ea001d9a2)
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
Jessica McKellar 848c9ec7be Add a test for unsubscribing from welcome emails.
(imported from commit c206bd9283e6be22b285abd583c6e80719260448)
2013-11-27 09:30:00 -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 5a4df81202 Add tests for our event queues data structure.
(imported from commit 5be116d6cc983edaac240e83d1b950faa08d164c)
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
Kevin Mehall ca182ec062 Link to streams in notification bot messages.
It's a little weird that these still open in a new tab, but it might
be best to keep them consistent with all other links?

This is a first pass on Trac #1927.

(imported from commit 390bdef790a83af4240ad5f5a82e572ef5824756)
2013-11-25 16:12:57 -05:00
Jessica McKellar cbdb7152de Add a test for one-click unsubscribes from missed message emails.
(imported from commit cb7c3ff0b24ed49e543b6a94b53bd709bd141318)
2013-11-25 15:18:40 -05:00
Jessica McKellar d250373802 Add tests for long messages and topics.
(imported from commit f0455d9462bf3eae498258420069c48fcd1e2f43)
2013-11-22 13:53:03 -05:00
Steve Howell 8f636bccf6 Triple-quote string in test_dangerous_block() for readability.
(imported from commit f8fdbff9cc992310907957ca0632bb646c726b9f)
2013-11-21 18:10:33 -05:00
Steve Howell ace12bcab6 Support arbitrarily nested fenced quote/code blocks.
Now we can nest fenced code/quote blocks inside of quote
blocks down to arbitrary depths.  Code blocks are always leafs.
Fenced blocks start with at least three tildes or backticks,
and the clump of punctuation then becomes the terminator for
the block.  If the user ends their message without terminators,
all blocks are automatically closed.

When inside a quote block, you can start another fenced block
with any header that doesn't match the end-string of the outer
block.  (If you don't want to specify a language, then you
can change the number of backticks/tildes to avoid amiguity.)

Most of the heavy lifting happens in FencedBlockPreprocessor.run().
The parser works by pushing handlers on to a stack and popping
them off when the ends of blocks are encountered. Parents communicate
with their children by passing in a simple Python list of strings
for the child to append to.  Handlers also maintain their own
lists for their own content, and when their done() method is called,
they render their data as needed.

The handlers are objects returned by functions, and the handler
functions close on variables push, pop, and processor.  The closure
style here makes the handlers pretty tightly coupled to the outer
run() method.  If we wanted to move to a class-based style, the
tradeoff would be that the class instances would have to marshall
push/pop/processor etc., but we could test the components more
easily in isolation.

Dealing with blank lines is very fiddly inside of bugdown.

The new functionality here is captured in the test
BugdownTest.test_complexly_nested_quote().

(imported from commit 53886c8de74bdf2bbd3cef8be9de25f05bddb93c)
2013-11-21 17:13:17 -05:00
Steve Howell 792e0c5976 Add FencedBlockPreprocessorTest.
(imported from commit a7f73f04408288192b33f688bd5baadd362f9458)
2013-11-20 16:06:54 -05:00
Tim Abbott f3fa78d30c Rename do_[rd]activate to do_[rd]activate_user.
For similarity with do_activate_user.

(imported from commit 2874af84dbe1ce666de10e0d8ffe2daa8bad9731)
2013-11-16 11:35:26 -05:00
Steve Howell 0b16dfc999 Add /json/users/<email>/reactivate endpoint.
(imported from commit 7afa29f7718430ea2df7c489ab2af4d93d4ce497)
2013-11-16 11:35:25 -05:00
Steve Howell bdfd3ed9c2 Add do_reactivate() action.
(imported from commit fc73d0fdd3a6125b3b31a75c3b108ceb266e528b)
2013-11-16 11:35:25 -05:00
Jessica McKellar 545e2539f8 Use non-ASCII characters in Freshdesk tests, to catch encoding bugs.
(imported from commit 0cc3ebf3548b28c018d75d51e7e66de5dbb59a0b)
2013-11-15 12:28:30 -05:00
Steve Howell 6ddfa35a49 Remove detailed "At risk users" tab
(imported from commit d5630fa3ae5a35d238e3c947a01e1a648668817f)
2013-11-14 14:07:24 -05:00
Kevin Mehall 4a6b7cb20b Disable password change when SSO is the only login option
(imported from commit fd1a14237e2d6ea574331ed178bfc0db5beb18c6)
2013-11-12 10:37:33 -05:00
Jessica McKellar 59117f0e03 Display Freshdesk's inline images in notifications.
(imported from commit b40de8282ac26e7b77e6d9de439b521bbe7adbe2)
2013-11-12 10:24:26 -05:00
Jessica McKellar 30151eff92 Add tests for the Freshdesk webhook.
(imported from commit 5b745ef1a590812d4b3c1adbba7d43d25983c4ad)
2013-11-12 10:24:26 -05:00
Tim Abbott 2e833613c3 [Django 1.6] update monkeypatching for CursorDebugWrapper.
(imported from commit cb4b44a2bb6ba6efbd1fb5710da2df7c1dec7f81)
2013-11-08 08:22:04 -05:00
Jessica McKellar d51ac058e2 alert words: add multi-word and non-ascii words to tests.
(imported from commit 9c9c7b6ec255970e7e396cf6185af07c7677753c)
2013-11-06 11:43:35 -05:00
Tim Abbott e06722657a [manual] Remove /messages/latest API and related legacy code.
This requires doing a puppet apply on our servers to take effect
properly.

(imported from commit 19dc56f071f07a5d2571eef49dd835121b2e82b6)
2013-11-05 14:19:40 -05:00
Steve Howell 406c4f172a Add realm.get_admin_users() method.
(imported from commit b1cb465f0c81eb9f56ad1486b92cd39a8d001474)
2013-11-02 11:37:27 -04:00
Jessica McKellar 35e764e7d1 integration: add branch name to Stash messages.
(imported from commit 3421717acd0e85cb2a1b1f0bd15438f70fd3d82e)
2013-11-01 10:10:17 -04:00
Steve Howell 70c1c31b3a Simplify callback protocol for register_json_consumer().
The register_json_consumer() function now expects its callback
function to accept a single argument, which is the payload, as
none of the callbacks cared about channel, method, and properties.

This change breaks down as follows:

    * A couple test stubs and subclasses were simplified.
    * All the consume() and consume_wrapper() functions in
      queue_processors.py were simplified.
    * Two callbacks via runtornado.py were simplified.  One
      of the callbacks was socket.respond_send_message, which
      had an additional caller, i.e. not register_json_consumer()
      calling back to it, and the caller was simplified not
      to pass None for the three removed arguments.

(imported from commit 792316e20be619458dd5036745233f37e6ffcf43)
2013-10-31 13:18:11 -04:00
Jessica McKellar 9bf282386d tests: add a Stash test based on the sample JSON.
(imported from commit 8761e4742167197f472c78e6546e8934fdd5ae33)
2013-10-29 22:45:50 -04:00
Jessica McKellar 54977707cf tests: remove redundant http_auth method.
(imported from commit 7fc425ce0e61e68c2fc033c02997ec0786e118fb)
2013-10-29 22:45:29 -04:00
Steve Howell 884e602185 [puppet] Handle exceptions from queue workers.
Subclasses of QueueProcessingWorker that don't override start() will
have their consume() functions wrapped by consume_wrapper(), which
will catch exceptions and log data from troublesome events to a log
file.

We need to do a puppet apply to create /var/log/zulip/queue_error.

(imported from commit 3bd7751da5fdef449eeec3f7dd29977df11e2b9c)
2013-10-29 17:45:31 -04:00
Steve Howell 68942a8f3a Properly split up "Your Account" and "Notifications".
The "Your Account" and "Notifications" boxes on the Settings
page each had their own border and their own "Save changes"
button, but they were within the same form and sending to the
same back end point.

This commit creates a separate form and endpoint for each
of the two boxes.

(imported from commit 04d4d16938f20749a18d2c6887da3ed3cf21ef74)
2013-10-29 10:59:41 -04:00
Kevin Mehall 0a3a22cb3d Support authenticated upload URLs.
Trac #1734

This is implemented by bouncing uploaded file links through a view
that checks authentication and redirects to an expiring S3 URL.

This makes file uploads return a domain-relative URI. The client converts
this to an absolute URI when it's in the composebox, then back to relative
when it's submitted to the server.

We need the relative URI because the same message may be viewed across
{staging,www,zephyr}.zulip.com, which have different cookies.

(imported from commit 33acb2abaa3002325f389d5198fb20ee1b30f5fa)
2013-10-24 17:01:06 -04:00
Tim Abbott 4b45c8bf96 Fix update_message_flags tests to test with real messages.
As it turns out, some of these tests used message IDs 1 and 2, which
Hamlet didn't even necessarily receive as the messages to update --
which meant that they previously updated 0 messages and returned
success.  So those tests started failing when I added a check for not
updating anything in the update_message_flags backend -- and this
commit fixes the tests to actually update a nonempty set of messages.

(imported from commit 9034b415d4862216a266416a8e509d987050ffd7)
2013-10-24 15:44:17 -04:00
Leo Franchi 13b452ddf8 Add a method=? parameter rest_dispatch to support PATCH-via-POST
(imported from commit 66f7011d6920639abc307ca85708bc958f3bb0e3)
2013-10-24 10:22:06 -04:00
Steve Howell 0662300e9e Remove /json/subscriptions/list endpoint.
(imported from commit db2c38f6b12ebee5250737a6cdd193863a4605af)
2013-10-22 15:51:19 -04:00
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
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
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 60dfd4b1b4 Test UserActivityWorker.
This commit also introduces a mechanism to stub out
SimpleQueueClient.

(imported from commit b88f963926b469c6eeec1f84323c1b520979b0e2)
2013-10-17 15:36:39 -04:00
Leo Franchi f7386c3f58 [schema] Add support for keeping track of iOS APNS device tokens
In order to support iOS Push Notifications, we need to keep track
of a device's unique APNS Token. These are delivered to our iOS
code after registering for remote notifications

(imported from commit bbe34483e1380dc20a1c93e3ffa1fcfdb9087e67)
2013-10-16 12:54:28 -04:00
Kevin Mehall 71decdbe7a Fix code block auto-closing.
Trac #1162

The process_fence method replaces code blocks with placeholders, so
indexes stored before the replacement are incorrect. However, because
the closed code blocks have been replaced, we can simply search the
whole string for any remaining opening code block markers.

(imported from commit 6a9e6924840f8f3ca5175da7c52a905e27c1fabd)
2013-10-16 10:12:33 -04:00
Kevin Mehall b134c90b6b Enable backtick fenced code blocks.
Trac #1900

(imported from commit 47b3a76488a4285641fd1eb3e68bc72047a8d738)
2013-10-16 10:12:33 -04:00
Leo Franchi 6e1bc06323 Fix test to check for new 60-char stream name length limit
(imported from commit 16474a9befc7466ee69f9aef37ec6e52758b5d76)
2013-10-15 10:24:07 -04:00
Zev Benjamin 4921166b56 Remove rogue print statement
(imported from commit ef0b8855e94cd5e3ec9c80bac8cd82be0ca7911e)
2013-10-11 22:19:35 -04:00
Leo Franchi 1f89bf386f Parse markdown tables and show them with some styling
(imported from commit fb3c599b1dbaed2447f1e710ed7202486000ca2a)
2013-10-10 16:39:11 -04:00
Leo Franchi 6e188fb067 Tweak alert_word matches and add some more tests
(imported from commit 63dc4064c15d5d33a7ec0c992b183bf323dd4ee8)
2013-10-10 10:58:21 -04:00
Leo Franchi 08ae641dd2 Pre-fetch data from the DB and hand to markdown thread
We want to avoid opening a DB connection in the markdown thread
as its DB connection might live for a long time

(imported from commit 7700b2ca793ee5e9add7f071b92f22a4bf576b3d)
2013-10-10 10:58:21 -04:00
Leo Franchi f0f4ff61f0 Attempt to convert JIRA mentions to Zulip mentions
(imported from commit 0d763c8fdefd8cc2c2ae527fdb80e66635ded3d6)
2013-10-07 13:59:36 -04:00
Leo Franchi 02a48e94f0 Turn JIRA users into mentions where possible
(imported from commit faddc2127fe3fdb95e278df06a834cda700b97f4)
2013-10-07 13:59:36 -04:00
Zev Benjamin 4129541206 github: Add support for commit comments
(imported from commit 43abd740e563952d1291939e6a530b8366232eb3)
2013-10-04 15:53:21 -04:00
Steve Howell 95321a9845 Clean up a few @slow decorators in tests.py.
A few "slow" tests aren't as slow any more, for whatever reason,
so we're setting a higher bar going forward.

(imported from commit 642137cebb7826f4512b5635da9d7b75bd5c35f4)
2013-10-04 00:25:49 -04:00
Kevin Mehall 72a0b67c80 Prevent other markdown operators from touching URLs.
The text of manual links are already AtomicStrings, so linkified strings
should be too.

Moves emoji detection to happen after linkification, so the emoji rule
won't look at links.

(imported from commit 9c56bce6a0e873b398255e0762dfb312a4a9a64e)
2013-10-03 17:26:47 -04:00
Kevin Mehall 8842349629 Fix links with invalid emoji in them.
InlinePatterns should return None on failure, not text that may
have placeholders in it.

(imported from commit f9d8d22b2b8cfa7a92ecf3e52a6c76b48e6f0175)
2013-10-03 17:26:47 -04:00
Steve Howell f6794ce849 Remove stray print statement in tests.py
(imported from commit 2be8ceb83664cfb9f3158e23894637ac513efa41)
2013-10-03 13:03:33 -04:00
Tim Abbott 3422b02e52 Add some unit tests for gather_subscriptions.
(imported from commit 10c362e36e2e9044918e22449b6d82acb9c867f3)
2013-10-02 16:37:56 -04:00
Steve Howell 00cf695af2 Add "Durations" tab to /activity.
This tab shows how long each user has been on during the last 24
hours, using data from UserActivityInterval.  Much of the code
is borrowed from analyze_user_activity.py, but in this version
we set the time interval to be the last 24 hours and sort by
realm and email.  I also ensure that it only executes one
query to get all the data (and there's test coverage for that).

(imported from commit 7a2b80f52679054b03c5f5f42b2cda07d5599432)
2013-10-02 11:27:23 -04:00
Steve Howell 786c2cf759 Remove client-specific tabs from activity overview page.
Waseem is ok with removing the client-specific tabs on the
main /activity page.  This reduces the number of queries from
25 to 1.  We might eventually restore some of that logic, but
we will do it more efficiently.  A lot of the data for
non-website clients is kind of unreliable, anyway.

The page looks kind of funny with only one tab, but that
will be fixed in the next commit.

(imported from commit 54f08f89d5242ad3e045d8ca0d97b86617c15380)
2013-10-02 11:27:23 -04:00
Steve Howell 374a64acf8 Add test for /activity page.
For now we just verify that we don't explode, and we count
the number of queries (25).

(imported from commit 145c3373e2f6d005827af743729e03e524167904)
2013-10-02 11:27:22 -04:00
Leo Franchi 028711baef Handle some JIRA formatting and make it like our own
(imported from commit 1e8369067668b0c375f226c1911814f496637d16)
2013-10-02 11:18:17 -04:00
Steve Howell c23ab96fb9 Add simulated_empty_cache() test decorator
(imported from commit 2dd03a522f9ee01a802c8e5ff4116db04763ed35)
2013-10-02 10:45:18 -04:00
Steve Howell 53b5768b14 Double speed of message fetching in get_old_messages_backend().
When we don't already have old messages in cache, we need to
fetch data from the database and create dictionaries for the
cache.  This commit makes that process work in 50ms, instead
of 130ms, for the data set in test_bulk_message_fetching(),
which is 602 records.  Before this commit we had about 132
microseconds of unnecessary churn per message, because we
were fetching DB fields we didn't need and incurring the cost
of the Django ORM.  Now we use values() to get only the columns
we need, and we take advantage of previous commits that make
our code less OO and more function-driven, so we can pass the
values directly to build_message_dict() without having to create
objects.

A couple caveats on this commit:

1) I haven't been able to get good measurements on the overall
effect on get_old_messages_backend().  If you kill the cache to
force DB queries, you introduce noise related to sessions and
user profiles.

2) Look at the long comment in this commit related to
re-rendering messages in this codepath.  The problem precedes
this commit.

(imported from commit dcb64aa9416f0e9583355ddd6dc3adfa746b9fc7)
2013-09-30 18:22:07 -04:00
Steve Howell 3c802e1b02 Add MessageExtractorTest.test_applying_markdown()
(imported from commit 0e88f999a871e93ae14d157e0087a75ae81d60a3)
2013-09-30 18:08:32 -04:00
Steve Howell 8ae789eaf8 Add test_message_extractor_basics().
(imported from commit 37e64cd4db1850e04bd9fdc37de1f38400436736)
2013-09-30 18:08:32 -04:00
Leo Franchi 4102b8e844 Add query count tests for bulk_add_subscriptions
(imported from commit 84a68e3e50178df383e66bb29008da6086709eda)
2013-09-27 10:26:11 -04:00
Steve Howell a99d2bebab Assert that registration involves <= 53 queries.
This isn't a very strong test, to be sure, but it's something.

(imported from commit 578dbc6601f38186fec9bfb061a8bbc322201ae7)
2013-09-26 09:55:43 -04:00
Steve Howell 6890c89936 Harden the queries_captured() test decorator.
Before, it was trying to use connection.queries, but Django
could pull the rug out from under us.  Now we monkeypatch
the CursorDebugWrapper methods instead.

(imported from commit 25d5bab47673f2b66a6325f48d33e66c31055ab3)
2013-09-26 09:55:42 -04:00
Zev Benjamin f6500d691e github: Make pull request comments go to the user-specified stream
(imported from commit dfce76bcba43dd4a0beba6b6af7642363193dcde)
2013-09-24 16:32:13 -04:00
Steve Howell 50641c3337 [perf] Reduce the number of DB queries in send_message.
For a 4-person stream, we were hitting the DB 8 times, and 4 of
those queries were to lazily get user.email for the 4 recipients
due to upstream code using only().  I added user_profile__email
to the only() call.

I believe this regression started 9/18, and after pushing this
to prod, we would should look at this graph:

https://stats1.zulip.net/graphs/8274cd84588

(imported from commit 70629cb69fe5955c674ba76482609dfe78e5faaf)
2013-09-24 16:19:52 -04:00
Steve Howell 63de50d6f0 Add StreamMessagesTest.test_not_too_many_queries
(imported from commit bc49d7a0f932aecb1be7cecd0f6c5a9c95b2767d)
2013-09-24 16:19:52 -04:00
Steve Howell 9ee2f186ca Add queries_captured() context manager for tests.
(imported from commit 14a9529aef057e79bc12c979d88b595828a8b3a3)
2013-09-24 16:19:52 -04:00
Steve Howell 4b75dd0d85 Add Stream.num_subscribers
(imported from commit 9b79ab84516c3634ef6795ef2d90db37553cc0d1)
2013-09-20 10:19:07 -04:00
Steve Howell a8f6c2fe55 Add CheckMessageTest.test_bot_pm_feature() test.
This tests that a bot's owner gets sent a message if the bot
sends a message to a stream with no subscribers. (Presumably
the message will be a PM; we could make the test more precise
in the future.)

(imported from commit 0aaf931a90cb9c7bc3fde8ac545c6b6ad0a55668)
2013-09-20 10:19:06 -04:00
Steve Howell 7b748fed7a Add CheckMessageTest class
(imported from commit 07c4ba895570853c923703b1332c4fc403cc858e)
2013-09-20 10:19:06 -04:00
Zev Benjamin 0394459f04 github: Put pull request comments on the 'commits' stream
(imported from commit d50c1f577737a07da1f08a1fbfc4242ca9d6d4a1)
2013-09-19 23:44:21 -04:00
Zev Benjamin 1c82a9ecfa github: Format pull request messages more like issue messages
(imported from commit cba3a84c3abb6f33495e5afbe8e03d1a7a7d046c)
2013-09-19 23:44:21 -04:00
Zev Benjamin f99cf15358 github: Add tests for pull requests
(imported from commit dd099cd0e630c09f490ecd5aac761ce131b0a8e2)
2013-09-19 23:44:21 -04:00
Zev Benjamin c5d4a640be tests: Refactor Github tests to reduce code duplication
(imported from commit 7c34bd2eefe706898479f96a03685f6e027bf43f)
2013-09-19 23:44:20 -04:00
Steve Howell 3c69a6dd26 Bulk-send peer_add events in bulk_add_subscriptions().
Send a single peer_add event per stream that has multiple users.

(imported from commit 1027b212557f848d437128a03698ecd54575c3fd)
2013-09-19 08:52:54 -04:00
Steve Howell c8c64984d3 Eliminate redundant peer_add notifications.
Don't send peer_add notifications to users who are already
getting add notifications, because they will already know
about subscribers.

(imported from commit 726b54ae0e30b71440b17d9c51b026872ea96218)
2013-09-19 08:52:54 -04:00
Steve Howell c58d366178 Optimize notifications from do_add_subscription().
Instead of sending one notification per user, bulk them up with
the users parameter.

(imported from commit c296f23599a214a63ef6f09406a9deaea469a7f3)
2013-09-19 08:52:54 -04:00
Steve Howell b2a7860d56 Add test_multi_user_subscription() to backend tests.
(imported from commit aa6849f7c01f083144acd3ecb72cf7e31794dad7)
2013-09-19 08:52:53 -04:00
Steve Howell b02770440a Add tornado_redirected_to_list() to tests.py
(imported from commit e515d3e4b9f04b5db56d4c9433bc9ba15fd3b4da)
2013-09-19 08:52:52 -04:00
Kevin Mehall 8c7f1ecffa bugdown: Don't generate garbage on invalid links.
LinkPattern returned a string which contained a placeholder if the URL was
considered invalid. AtomicLinkPattern wrapped this in an AtomicString,
where the placeholder doesn't get removed properly.

m.group(0) is always incorrect because python-markdown modifies your regex
to include more than you specified (this is why part of the message got
duplicated).

(imported from commit 576bdf09c2b677cf4bc56484c363eb05f2110158)
2013-09-18 16:22:13 -04:00
Leo Franchi c588c7938c Allow message topic changing to propagate backwards
(imported from commit 470178ef5f7aaf09d4528c88ae6e33f17538fcaf)
2013-09-18 13:27:58 -04:00
Zev Benjamin 3d11d0e420 github: Remove the issue title from message bodies
(imported from commit d7298696011c548c26cc4ec4d13c7f1d83efd785)
2013-09-17 13:55:39 -04:00
Zev Benjamin 4996eb1e61 tests: Add Github issues tests
(imported from commit 1aa7a2c78f148f5e6ea9c7551f25374cbfe32f15)
2013-09-17 13:55:39 -04:00
Zev Benjamin 067997287e tests: Use real data for testing Github pushes
(imported from commit 83b800a8711cf045ffc7da3305227f495819a5da)
2013-09-17 12:59:18 -04:00
Zev Benjamin e5cf24b2fd Fully quote payload body contents in integrations
(imported from commit 3cb03eabbd917f878b37aa226eb3f3ecda63d5e7)
2013-09-17 12:55:57 -04:00
Steve Howell b7ef86bc34 Added /json/set_muted_topics
(imported from commit e9072cd273fabf0e072b6a5e9ed80b07142f1013)
2013-09-11 16:47:37 -04:00
Scott Feeney 1c2479c807 Fix overly-tight coupling in set_stream_color test
The test will fail if a new attribute is added to the structure that
gather_subscriptions() returns. It should only be concerned with the
subscription's color.

(imported from commit fd5bad97bbce2544e0078ee029f54d4e45da9c15)
2013-09-06 23:13:47 -04:00
Leo Franchi 252045fe2e Fix assignee in JIRA created message
(imported from commit 5ebadd14dee58c20746c80dfd99ba70a3d772ab6)
2013-09-06 11:24:03 -04:00
Zev Benjamin cb78014eef bugdown: Allow block-level block quotes
It is triggered by specifying the "language" of a code block to
"quote" or "quoted":
    Hamlet said:
    ~~~ quote
    To be or **not** to be.

    That is the question
    ~~~

(imported from commit 847a0602e335e9f2955e32d9955adf8ac8de068c)
2013-09-05 17:34:28 -04:00
Zev Benjamin 5c81148839 Switch our trac realm filter to use trac.zulip.net
(imported from commit 19163f5be01a1d9370d9ed45c55bedd670772dac)
2013-09-05 15:43:07 -04:00
Tim Abbott ce710292ca Always use external-content.zulipcdn.net for mit.edu realm.
(imported from commit 21d1101185bf52f21fcc345e791217311e9c0a13)
2013-09-05 14:35:42 -04:00
Tim Abbott b557b94d0b bugdown: Rewrite image urls to avoid mixed-content warnings.
(imported from commit fc0a41befb04f2a8aad2937a856366ac3cadb192)
2013-09-05 14:35:29 -04:00
Tim Abbott cdfc6dc10a bugdown: Fetch youtube preview images over HTTPS.
(imported from commit 9dbf3c21083cbbcf1288789f400c33ec735d4416)
2013-09-05 14:35:29 -04:00
Leo Franchi b2ddd670e4 [schema] Add backend support for per-user alert words
(imported from commit 7a9c596a010cbedbddf594c5d9c68bb9ed46d122)
2013-09-05 10:18:40 -04:00
Kevin Mehall 6b820038ad Server side tests for message editing, including subject propagation.
(imported from commit 0a68bdc337eda1b04976fb41a50a29f9f626ef25)
2013-09-04 14:51:46 -04:00
Kevin Mehall be5c90c217 Add test for realm-specific emoji
(imported from commit 2148038b300b71afe0a7517709ed0404536b69fd)
2013-09-03 11:01:01 -04:00
Scott Feeney 09ff770435 Make invite-only stream invite notifications less confusing
Previously, when added to an invite-only stream, you got notifications
like this:

   Hi there! We thought you'd like to know that Some Person just subscribed
you to the invite-only stream 'Secret stuff'

   You can see historical content on a non-invite-only stream by narrowing
to it.

Note that the second line is irrelevant and confusing in light of the
first!

This commit leaves this out, and also, to make sure I didn't mess
anything up (and because I needed to change the tests anyway), adds a
test for invite-only stream notifications.

(imported from commit 49c333629c78fc06f6d2f1ec8a627c6d38e7716a)
2013-08-29 10:27:34 -04:00
Jessica McKellar cf0f205f75 tests: check that non-subscribers can't send messages to an invite-only stream.
(imported from commit 5ee0fb49e994c4d283348d89a25606ca6d314005)
2013-08-28 16:43:40 -04:00
Jessica McKellar 2cc06aafe1 tests: don't skip message sending restriction checks!
We were using the internal do_send_message, which does not do any
security checks.

(imported from commit 14a31a39a392dd2bc6b79f4345aa80217d5356f2)
2013-08-28 16:43:40 -04:00
Tim Abbott 9e372118a9 Simplify stream access denied error message.
Otherwise, we'll report that a stream is invite-only when it isn't.

(imported from commit 441db1c84fb19bdf564251a1bd80ace23151783d)
2013-08-22 12:29:04 -04:00
Tim Abbott f5f95e5f43 [manual] Extend /api/v1/streams API endpoint.
Previously it only provided the list of all public streams; now it
allows one to specify any union of some of the following:
* all public streams
* all streams the user subscribed to

(the most relevant being the union of those two, which is what we want
for the "streams" page).

Or:
* all streams in realm (superuser only)

The manual task required is that when this is pushed to prod, we need
to also deploy the new sync-public-streams version to zmirror.

(imported from commit 27848b8bd136e2777f399b7d05b2fdcec35e4e21)
2013-08-22 12:29:04 -04:00
Kevin Mehall 00fc004be2 Server-side check for empty (or all-whitespace) messages.
(imported from commit 49054dd7a8050705f579b4b7a1bda7eb7bfc25be)
2013-08-21 10:37:36 -04:00
Tim Abbott 517c98d56f add_subscriptions: add authorization_errors_fatal parameter.
For syncing streams between Zephyr and Zulip, we need to be able to
have the API client send the server a long list of streams, some of
which might be invite-only, and add the ones that it can add and not
the ones it cannot without a bunch of annoying round trips dropping
individual streams one is not authorized to one by one.  This argument
makes that possible.

We might find other applications as well.

(imported from commit 9236d185897c42218ab6cac3d8f3ddcb1bbc94e9)
2013-08-20 14:57:15 -04:00
Kevin Mehall 8a741ed3d4 Ensure that the pointer is valid before saving it.
Trac #1716

Fix the tests to use real message IDs for the pointer. One helper didn't
use the pointer ID it was passed at all, so the test didn't actually test
what it was supposed to before.

(imported from commit 457bcdb04a6c3873e224b68cd9d79c9a26612010)
2013-08-19 16:46:52 -04:00
Jessica McKellar f530e3b930 Display the email address for a stream in its stream page detail.
For now, only show it on staging.

(imported from commit fd07fad1c34578d8ddc2cddd1bb6bdcb72f354de)
2013-08-13 14:28:47 -04:00
Zev Benjamin 6843cc4479 Add test for zephyr mirror CC de-duplication
(imported from commit 1452c67818f8aa577a95a219fc6b86e9690033eb)
2013-08-13 13:49:09 -04:00