Commit Graph

123 Commits

Author SHA1 Message Date
Jessica McKellar 1b068d5433 [schema] add boolean field enable_digest_emails to UserProfile.
We'll use this to track the user preference for receiving digest
e-mails.

(imported from commit a56644b1a359444ded45f9437c954194b9ae47a1)
2013-12-02 18:58:03 -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
Zev Benjamin d2d695dcb6 Add an in-memory Client object cache
Client objects are immutable and there are very few of them, so caching them in
memory is cheap and saves a trip to memcached.

(imported from commit 300b9b402f4e509f86a7fd86b5f898dc3f43738f)
2013-11-20 16:55:10 -05:00
Jessica McKellar d1619b3f3c Use a more accurate "is admin?" check.
UserProfile.show_admin was intended to be a check for users that have
administrative rights in other realms, which we've harmlessly but
erroneously been using to check if they are an admin in their realm.

Use the more straightforward check instead, with a more intuitive
name.

(imported from commit d81050c7dbbb19e59c5e31750be303a4630e1456)
2013-11-19 14:31:02 -05:00
Steve Howell 220678ae40 Support emojis/bolding/etc. in single-line /me messages.
(imported from commit c62ae8cf26117e30a029e025021cc4a3a67f4a83)
2013-11-15 14:34:38 -05:00
Steve Howell ee28e5e2f6 Relax 80-char limit on status messages (/me).
(imported from commit e9de2cb6c394f5b764e988e279f0fb3cfd38c6e8)
2013-11-14 13:51:07 -08:00
acrefoot f7b5a10da0 [schema] Add ScheduledJob table, and update mandrill related code
ScheduledJobs with type Email displace the usual mandrill codepaths
in the Zulip Enterprise deploys

* Email-specific helper functions will appear in deliver_email.py
* 0058_auto__add_scheduledjob.py

(imported from commit 8db08d8a279600322acfdbed792dc1a676f7a0ab)
2013-11-13 16:41:36 -05:00
Leo Franchi 62ba16a829 [schema] Allow a realm to have aliases for multiple other domains
(imported from commit 5d0340afd4c77f50db63550a3ec8d81e885c285c)
2013-11-13 14:17:43 -05:00
Tim Abbott e18a08c69e settings: Move hardcoded API super users into local_settings.py.
(imported from commit fea7550a771c837db0fb948238488f778bedf73a)
2013-11-13 12:02:49 -05:00
Tim Abbott 5293cdebe8 Rename LOCAL_SERVER to ENTERPRISE.
(imported from commit 7edf353eefe6c9e7aac74b7bbc37b923cac1b913)
2013-11-12 15:57:01 -05:00
Steve Howell 56c39728ba Support /me syntax.
If a user types "/me runs to the store", we put "runs to the store"
in bold after their name.

(imported from commit fbc11e99244e1c8fa1c03e4753e706957fcd449e)
2013-11-12 10:49:10 -05:00
Luke Faraone 3daca0ca9c Fix rebasing errors that rightfully made the linter sad
(imported from commit fbed798c7d752ea2b058aeebb5ae31a620684a3a)
2013-11-05 17:52:53 -05:00
Luke Faraone c11b65590b SSO / REMOTE_USER support
(imported from commit 4f4fad7af5d3c6099cac95d7708338c182626d72)
2013-11-05 16:14:13 -05:00
Tim Abbott 68dcc760c3 Clean up some unused imports.
(imported from commit 0c5d8e2a55ba1b8909ba807fee3afe863dcdc226)
2013-11-04 11:51:17 -05:00
Tim Abbott 0ae03eb655 Remove transaction management hacks in get_client.
I'm pretty sure this code was a hack to workaround the fact that
without database-level autocommit, .get_or_create is racy.

(imported from commit bfdd476a354aee439feeaa0030ae59cc43c165b9)
2013-11-04 07:31:39 -05:00
Tim Abbott 2de31ee287 [schema] Remove the UserMessage.archived field.
This was a precursor to UserMessage.flags.read that never got used
because we decided to use django-bitfield.

(imported from commit 868754723c07ee9b85ae951aee785e571ccfef97)
2013-11-04 07:31:11 -05:00
Steve Howell 406c4f172a Add realm.get_admin_users() method.
(imported from commit b1cb465f0c81eb9f56ad1486b92cd39a8d001474)
2013-11-02 11:37:27 -04:00
Tim Abbott 1292c5dbfe Add backend support for Jabber mirroring.
(imported from commit 12f5c708a6961aded4f4e166af84e87720be4ddc)
2013-10-29 16:49:42 -04:00
Leo Franchi e1557bef73 Cache realm user basic info dict that is used in bugdown
(imported from commit 688c47daceb73534be90bd98a031c7b4edb5546e)
2013-10-28 12:59:36 -04:00
Waseem Daher 66f48288b4 Rename LOCALSERVER -> LOCAL_SERVER.
(imported from commit b3abdd10d54d2ad7a9c463af9a291d2e2127707f)
2013-10-25 17:37:06 -04:00
Luke Faraone 81d7dd1fda [schema] Support for authenticating Deployments via the API.
Here we introduce a new Django app, zilencer. The intent is to not have
this app enabled on LOCALSERVER instances, and for it to grow to include
all the functionality we want to have in our central server that isn't
relevant for local deployments.

Currently we have to modify functions in zerver/* to match; in the
future, it would be cool to have the relevant shared code broken out
into a separate library.

This commit inclues both the migration to create the models as well as a
data migration that (for non-LOCALSERVER) creates a single default
Deployment for zulip.com.

To apply this migration to your system, run:
   ./manage.py migrate zilencer

(imported from commit 86d5497ac120e03fa7f298a9cc08b192d5939b43)
2013-10-25 14:13:30 -04:00
Leo Franchi 05564ec0e2 [schema] Add a config option for enabling/disabling push notifications
(imported from commit 5649188cd5e0e4edb6e71559ec7d7fc5e92efaf8)
2013-10-24 14:54:30 -04:00
Leo Franchi 1d82704b8d [schema] Add a last_updated field to AppleDeviceToken
(imported from commit 2ea91e462773c50591585a610b0de63625ad2b7e)
2013-10-24 14:54:30 -04:00
Tim Abbott 1b381b343d Allow starring historical messages.
This has a small bug where we don't actually filter the message out of
the home view; fixing that requires adding an index on the "flags"
field of UserMessage.

(imported from commit 492c99d0a8e87b253e577be6564bec12099bd8e9)
2013-10-23 18:51:47 -04:00
Steve Howell 58acef4098 Add get_emails_from_user_ids() action.
(imported from commit 887090de16f685373bd2f3548bd1ec94a7ad4a9e)
2013-10-22 15:51:18 -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
Jessica McKellar 5c5ffd6ea3 [schema] Add a name field to zerver_realm.
(imported from commit 5b5d7a40d5dff11fe9ca6624b3794cb9c8a3520a)
2013-10-17 13:47:51 -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
Tim Abbott 32861af323 [schema] Increase maximum stream name length to 60.
(imported from commit 83e9434178909d18481692a9e7fe3b8e1802bd7e)
2013-10-15 09:13:35 -04:00
Luke Faraone 1d9391e867 Initial local server configuration.
(imported from commit ac9b9896b74b78c6ca03af7f411d0788ae402cff)
2013-10-10 14:14:14 -04:00
Jessica McKellar 836f3894fb Add a comment to UserProfile that pointer is a Message.id.
And NOT a UserMessage.id. I kept having to trace the code and convince
myself of this.

(imported from commit 720a982a888dd525e63c37ddfedd28b71492d32e)
2013-10-08 10:46:52 -04:00
Leo Franchi 72c7c5b836 [schema] Give new realms a default notifications stream, and send signups/creations to it
(imported from commit 19ad761f7d9eabb865ac3526bf66dff8b7ed0224)
2013-10-07 15:46:13 -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 eb299bf5c8 Extract Message.build_message_dict()
(imported from commit 03395ea8fbffd0a52f85127c9a24f0cc3f4a6969)
2013-09-30 18:22:07 -04:00
Steve Howell 2a3747e21f Isolate message side effects in Message.to_dict_uncached().
Only call a function on the message object in the unfortunate
situation that we are rendering new content in to_dict_uncached().
Long term, it would be nice if this function didn't have side
effects, and we had a better strategy for upgrading rendered
content when bugdown versions change.

(imported from commit 2a323f52af37a6d651c171cb8234fbfa3d25d561)
2013-09-30 18:22:07 -04:00
Steve Howell f65462c891 Extract Message.need_to_render_content()
(imported from commit 466fa133ed1e8fb13b7222ba3bdcd5773d63de14)
2013-09-30 18:22:07 -04:00
Steve Howell 95254398f2 Extract get_avatar_url().
This function doesn't require the whole UserProfile object to
create the avatar url, and we call it from Message.to_dict_uncached().

(imported from commit e814caab101c4fedd1ba66df041a3408014e4085)
2013-09-30 18:22:06 -04:00
Steve Howell e4fb66fdf8 Isolate self-dot use in Message.to_dict_uncached().
For a bunch of self-dot references, move them to the top.  (This
is kind of funny out of context, but it sets us up for future
refactorings.)

(imported from commit 4ebc1c44a633d86772df1828c51180707769c3dc)
2013-09-30 18:20:55 -04:00
Steve Howell 005ad9c8e0 Kill off dead code in Message.to_dict_uncached().
If this line of code were ever called, it would crash anyway,
because it would be an unknown type, and Recipient.type_name()
would raise a KeyError.

(imported from commit db38c5f71fb2f0b044a832eb88e53fceb0d8a9cf)
2013-09-30 18:14:12 -04:00
Steve Howell dc077a708f Call get_display_recipient_by_id() in Message.to_dict_uncached().
This starts to make us less dependent on having full objects.

(imported from commit 5fb9504b077b676ecb697a909f4a0d2737f51efb)
2013-09-30 18:13:53 -04:00
Steve Howell a9fd6ddfce Extract get_display_recipient_by_id().
This is a variation of get_display_recipient that takes
values instead of an object, so that it is decoupled from
the Django object system.

(imported from commit 25bed43ecd62f1fe0176d517b7003e7f4c78bc37)
2013-09-30 18:11:29 -04:00
Steve Howell 515130396c Remove TEST_SUITE exception for get_display_recipient().
If it's ok for the tests to use memcached, it should be ok
for them to use the in-process cache too.

(imported from commit be43879c3c48f3780317fd5b4139b44d4a1f0ed3)
2013-09-30 18:08:31 -04:00
Steve Howell 826dffbbb4 Extracted Message.save_rendered_content().
This is a harmless extraction designed to allow subclasses override
the behavior of how rendered content gets saved.

(imported from commit 9df4ed9f86c857897fcb5f2b6781bfc5a0813766)
2013-09-30 18:08:31 -04:00
Steve Howell f36938c2f5 Extract Message.extractor
(imported from commit e6ee015cacdb0f6e1f725b7113f750e8b33d316b)
2013-09-30 18:08:29 -04:00
Jessica McKellar ed0fd51160 [schema] Add a date_created field to zerver_stream.
(imported from commit 1360da91b81fad59d49068fdf05205eef982e64a)
2013-09-27 16:23:56 -04:00
Jessica McKellar f22023d4cb [schema] Add a date_created field to Realm.
(imported from commit 1953f7c1f8af7f81d50d7362c704f6a81637d72e)
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
Leo Franchi d88266b41d Warn bot owners when a bot sends a message to a nonexistent stream
(imported from commit 2499d7bd9d176a7ab43f751eb855813d0a479bd4)
2013-09-18 15:54:13 -04:00
Steve Howell 30b6f54a36 Don't cache UserPresence info.
(imported from commit ff590bdf5d84bb9b3cedc561c2f2fbf7f7592a66)
2013-09-17 14:51:56 -04:00
Steve Howell 1e912c7e22 Exclude bots in the user presence query.
(imported from commit 02668ba5db85e12ac0aefc0fa2480d38ffed4921)
2013-09-16 16:27:16 -04:00
Steve Howell 85f9b6695f Optimize user presence/activity query.
The get_status_dict_by_realm helper gets called whenever our
 realm user_presences cache expires, and it used to query these fields:

    "zerver_userpresence"."id", "zerver_userpresence"."user_profile_id", "zerver_userpresence"."client_id", "zerver_userpresence"."timestamp", "zerver_userpresence"."status", "zerver_userprofile"."id", "zerver_userprofile"."password", "zerver_userprofile"."last_login", "zerver_userprofile"."is_superuser", "zerver_userprofile"."email", "zerver_userprofile"."is_staff", "zerver_userprofile"."is_active", "zerver_userprofile"."is_bot", "zerver_userprofile"."date_joined", "zerver_userprofile"."bot_owner_id", "zerver_userprofile"."full_name", "zerver_userprofile"."short_name", "zerver_userprofile"."pointer", "zerver_userprofile"."last_pointer_updater", "zerver_userprofile"."realm_id", "zerver_userprofile"."api_key", "zerver_userprofile"."enable_desktop_notifications", "zerver_userprofile"."enable_sounds", "zerver_userprofile"."enter_sends", "zerver_userprofile"."enable_offline_email_notifications", "zerver_userprofile"."last_reminder", "zerver_userprofile"."rate_limits", "zerver_userprofile"."avatar_source", "zerver_userprofile"."tutorial_status", "zerver_userprofile"."onboarding_steps", "zerver_userprofile"."invites_granted", "zerver_userprofile"."invites_used", "zerver_userprofile"."alert_words", "zerver_userprofile"."muted_topics", "zerver_client"."id", "zerver_client"."name"

Now it queries just the fields it needs:

  "zerver_client"."name", "zerver_userpresence"."status", "zerver_userpresence"."timestamp", "zerver_userprofile"."email" FROM "zerver_userpresence"

Also, get_status_dict_by_realm is now namespaced under UserPresence as a static method.

(imported from commit be1266844b6bd28b6c615594796713c026a850a1)
2013-09-16 11:29:10 -04:00
Leo Franchi 6e56342cf6 Send missedmessage notifications if user is idle for >1hr
(imported from commit 573f46a77497cb2f73eae3b4a648e466977e6247)
2013-09-13 17:33:34 -04:00
Steve Howell 21456091e4 [schema] Add muted_topics to UserProfile
(imported from commit 5d804259be94ba83dc4f7541e50443dd1a42cc6b)
2013-09-11 16:47:37 -04:00
Tim Abbott 9fcca3df4e [schema] Collect data on when users are active on site.
These engagement data will be useful both for making pretty graphs of
how addicted our users are as well as for allowing us to check whether
a new deployment is actually using the product or not.

This measures "number of minutes during which each user had checked
the app within the previous 15 minutes".  It should correctly not
count server-initiated reloads.

It's possible that we should use something less aggressive than
mousemove; I'm a little torn on that because you really can check the
app for new messages without doing anything active.

This is somewhat tested but there are a few outstanding issues:

* Mobile apps don't report these data.  It should be as easy as having
  them send in update_active_status queries with new_user_input=true.

* The semantics of this should be better documented (e.g. the
  management script should print out the spec above)x.

(imported from commit ec8b2dc96b180e1951df00490707ae916887178e)
2013-09-10 13:25:59 -04:00
acrefoot 592e1ead6b Actually use the realm specified by the email mirror when doing the markdown
(imported from commit 00b909b1d0c70a3523ab53d2f91815ab14ba2a6f)
2013-09-05 18:24:55 -04:00
Kevin Mehall e58e6f1b7d Check admin permissions on the target realm, not on their own realm.
Trac #1772

Also abstracts this into a method.

(imported from commit f435b3379fb5387f8b3fdf7ca728ab760eadbf95)
2013-09-05 15:36:59 -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
Scott Feeney e3247de572 Factor out get_active_user_profiles_by_realm()
(imported from commit 634ebf265b02303a938f7595de3622e25bc22b49)
2013-08-29 10:28:20 -04:00
Jessica McKellar f67f5b7619 Allow superusers to send messages to even private streams.
(imported from commit b7253174fa25d61b5bda056a5e5353e3b8ea918b)
2013-08-28 16:43:40 -04:00
Jessica McKellar 2be988e6b7 Give recipient_cache and associated functions a clearer name.
(imported from commit 14b12b196e33dfc4eeca5ab0f12c130ddaef1065)
2013-08-28 10:23:40 -04:00
Jessica McKellar 1f4f799030 Flush the per-process recipient cache after every request.
This cache was created to make recipient lookups within a single
request (e.g. when fetching old messages) cheaper. To support stream
name changes, we need to invalidate this cache on every request so
that users get a consistent view of the name change.

(imported from commit 801051b9f6a108c1f50be7eca9a1242d661919b1)
2013-08-28 10:23:39 -04:00
Jessica McKellar cd4daaa41f Factor the display_recipient cache key into a function.
(imported from commit 4a80c4db6ddcf8104f45b6b068e598378e655bc0)
2013-08-28 10:23:37 -04:00
Kevin Mehall 32aa0bb72d [migration] Add RealmEmoji model for realm-specific emoji.
(imported from commit d0a08b748f458c0ab68985b4cf00c78950ab40c4)
2013-08-23 21:39:29 -04:00
Steve Howell 4a7bab9a6f Allow collapsing of recipient sections.
This is experimental, for staging only.  There might be a better
way to model this than dueling force_expand/force_collapse flags,
but it works for now.  The code in collapse_recipient_group()
could also be DRYed up relative to expand_summary_row().

(imported from commit 107151d1ecd640970fb7700d41278a003bd1abaa)
2013-08-23 15:57:31 -04:00
Steve Howell 795248a1d0 Mute any topic named "muted" on zulip.com.
This change will allow us to test the muting feature on
staging.  Any topic named "muted" will automatically be
muted.  You can also mute any other topic on the console:

    muting.mute_topic('devel', 'ios');
    current_msg_list.rerender();

More UI around this experiment will be coming soon, as well
as support for muting entire streams.

The muting module keeps track of which topics are muted, but a
user can expand muted messages, and once that happens, the
messages are marked with the "force_expand" flag that gets
persisted to the back end.

Muted messages are rendered in similar fashion to the summarized
rows, and as part of unifying some of that code, we have
made it so that expanding a summarized section doesn't remove
individual flags related to summaries; instead, the messages
get the force_expand flag set.

(imported from commit acee4190e63813d46850415c41ff8ebfae4a6953)
2013-08-23 12:10:27 -04:00
Tim Abbott c2be5ca1ef Disable public streams for a CUSTOMER5 contractor.
(imported from commit bb7997cd831b9df9c951e3ecefe8a65b06bf6732)
2013-08-22 13:57:19 -04:00
Luke Faraone 078aea862c Always convert emails to lowercase in helper functions.
(imported from commit 834be7d682167c0d428c9b8a5ab8d3ae0c0d51a7)
2013-08-15 13:17:46 -04:00
Jessica McKellar befd34d111 [schema][manual] Make Stream.email_token required.
This commit CANNOT be deployed until the previous schema change
([schema] models: add an email_token field to Streams) is on prod.

Before applying this schema change, run the populate-stream-tokens
management command to generate tokens for streams that need them.

(imported from commit 7adc81c8c317ec5d59dd59ba42a4dc1a46174007)
2013-08-13 14:28:47 -04:00
Luke Faraone ecc42bc9f8 Add administrative panel to allow for user deactivations etc.
We now show a list of users and allow you to deactivate a user using the
same process as `python manage.py deactivate_user`.

We add a new menu item accessible from the gear icon which will eventually
have much more than just this, but we have a good start here.

Here we also add a property to UserProfile which determines whether you're
eligible to access the administration panel, and then have code which shows
the menu option if so.

This introduces a new JS file, admin.js.

(imported from commit 52296fdedb46b4f32d541df43022ffccfb277297)
2013-08-13 14:20:18 -04:00
Jessica McKellar c020545e02 [schema] models: add an email_token field to Streams.
The e-mail forwarder will use this. Set it to nullable temporarily to
accomodate existing streams; later commits will a) provide a script to
give all streams a token, and b) make the field non-null.

Realm administrators will eventually have a UI to regenerate stream
tokens.

(imported from commit a084d0a7012eb9665e4da095cbc46aa9ef354eaa)
2013-08-09 14:59:26 -04:00
Jessica McKellar 99b2a90440 Move completely_open to models.py.
It will have new callers soon and that's as fine a place as any to
avoid circular imports.

(imported from commit 089a724e9ad06cb5a51ffe80f1729d789238e5f6)
2013-08-08 10:12:22 -04:00
Kevin Mehall eac6463031 Implement message summarization experiment.
When you read messages in a narrow and then un-narrow, collapse
adjacent messages read in the narrow into a summary row that can
be clicked to expand those messages.

Scoped to staging with feature flags.

The implementation of this within our current MessageList is rather ugly.

(imported from commit bcb3a39d8c0c334136fe86318f18ead03f0f50bf)
2013-08-07 10:24:03 -04:00
Tim Abbott e111a2f9a5 [manual] Rename Django app from zephyr to zerver.
This needs to be deployed to both staging and prod at the same
off-peak time (and the schema migration run).

At the time it is deployed, we need to make a few changes directly in
the database:

(1) UPDATE django_content_type set app_label='zerver' where app_label='zephyr';
(2) UPDATE south_migrationhistory set app_name='zerver' where app_name='zephyr';

(imported from commit eb3fd719571740189514ef0b884738cb30df1320)
2013-08-06 07:39:36 -04:00