Commit Graph

115 Commits

Author SHA1 Message Date
Steve Howell 72964a2194 Recognize humbug-user-uploads-test for images/attachements.
(imported from commit 8596a5c4bad6e1adbfe97cbe057d1bd6d8e7f530)
2014-03-14 20:48:45 -04:00
Steve Howell 105c742e92 Correctly identify images/attachments on humbug-user-uploads.
(imported from commit 081d00d99672e6b938c60d9e13665e21d935d8ef)
2014-03-11 13:06:18 -04:00
Jason Michalski 3f6e53db6e Add bot_data module that updated with events
(imported from commit b0bd714258132fc81db763d316a15f5a81b1f4ff)
2014-03-05 14:16:20 -05:00
Jason Michalski c17ed8dc8c Add bots to page_params and send events on bot creation
(imported from commit ce418b4f056576d57f82d26af621473c730c12d8)
2014-03-05 14:16:19 -05:00
Jason Michalski f3180b774b [schema] Add default user_profile options for register events
Allow bot owners to set which streams their will receive events for
without needing to change a configuration file.

(imported from commit 2b69e519dbc12ffbdba072031a7f7196c9e50e33)
2014-03-05 14:16:18 -05:00
Jason Michalski de545d5fa0 [schema] Add a default to stream option to user profile
This allows bot owners to configure which streams messages are delivered
to without needing to change webhook URLs or configuration files.

(imported from commit 32a0c26657c145b001cd8cb3ce0a0364d48902ce)
2014-03-05 14:16:18 -05:00
Steve Howell eec12ff268 Calculate has_* fields before saving Messages
Before saving a Message object, call update_calculated_fields()
to set the has_attachment/has_image/has_link fields.

Note that the pre_save hook we added here does not get called
if you call bulk_create, hence the explicit call to
update_calculated_fields() in do_send_messages().

(imported from commit 1d60ae5908ef186aa5ff1e39277dbb2b765e60d4)
2014-03-04 11:00:26 -05:00
Zev Benjamin 814aed7cbe Send an event when a stream is created, is deleted, becomes occupied, or becomes vacant
A stream is vacant when it has no subscribers and occupied when it has at least
one subscriber.

We have a slightly odd model where stream creation is conflated with
subscription creation.  Streams are created by attempting to subscribe to a
stream that doesn't exist.  We also hide streams with no subscribers from users
to make it seem like they've gone away.  However, we can't actually remove those
streams because we want to preserve history.

This commit moves us towards a separation of these two concepts.  By sending
events for stream creation, occupation, vacancy, and deletion, we allow clients
to directly observe the global state of streams rather than indirectly observing
subscription information.  A more complete solution would involve adding a view
for explicitly creating streams without subscribing to them.

This commit does not handle the intricacies of invite-only streams.  We
currently simply do not send these events for invite-only streams.

(imported from commit 5430e5a5eecefafcdba4f5d4f9aa665556fcc559)
2014-03-03 17:30:58 -05:00
Jessica McKellar 600786983c [schema] Split Subscription notifications field into audible + desktop.
(imported from commit e160b9eb958fa5a06f990fccdeb25fa39e13e753)
2014-03-03 16:08:31 -05:00
Jessica McKellar df39a7bde2 [schema] Add separate notification settings for streams.
(imported from commit 2122a4cc35e9a1f019eea004cd27ce703ba5a55a)
2014-03-03 16:08:30 -05:00
Steve Howell 0f96f5064e [schema] Add has_attachment/has_image/has_link to Message.
We will need to run these commands manually when deploying to staging:

    CREATE INDEX CONCURRENTLY "zerver_message_has_attachment" ON "zerver_message" ("has_attachment");
    CREATE INDEX CONCURRENTLY "zerver_message_has_image" ON "zerver_message" ("has_image");
    CREATE INDEX CONCURRENTLY "zerver_message_has_link" ON "zerver_message" ("has_link");

(imported from commit 84808dc6b1af887ddf784cb8a875ae462f4df985)
2014-03-01 12:41:00 -05:00
Steve Howell a27610f560 Make Realm.get_admin_users not do O(N) queries.
This commit makes it so that we don't individually query
auth_permission for every user on the realm during calls
to Realm.get_admin_users().  This should speed up page loads.

To apply this commit, we had to upgrade all of our servers
with this patch to django-guardian:

 https://github.com/lukaszb/django-guardian/pull/178#issuecomment-31049062

(imported from commit a1604bf573a5005c9abc128a680a7da6a20cabef)
2014-02-28 16:27:12 -05:00
Luke Faraone 6a803a88c8 Return whether the user can be mobile-pushed in the presence endpoint
This allows clients to show an indication if users are on mobile or can
be reached via mobile.

(imported from commit 819c27a141f71dee32a97fd5c1ac405b039a5038)
2014-02-27 20:25:39 -05:00
Luke Faraone f30a62e33c Use keyword arguments in UserPresence.to_presence_dict()
Also rename the function, which was previously called to_presense_dict.

This will let us be more flexible about adding additional values.

(imported from commit 323b7d2df53918928190c9ee9544b4599a5e2df3)
2014-02-27 20:25:38 -05:00
Jessica McKellar 73fc65eb99 Make enter sends the default.
(imported from commit aa256772b381466f02210881214c9882b78b044d)
2014-02-05 13:35:41 -05:00
Jessica McKellar eeb8464f4d Don't expose deactivated streams to users through clients or API.
(imported from commit c32715255b3286f52fb313d35659f9357082603a)
2014-01-29 12:41:21 -05:00
Jessica McKellar 99d58fe8b5 [schema] at a `deactivated` field to Stream.
From a user's perpsective, the stream has been deleted. From the
database's perspective, the stream has been deactivated -- the stream
messages still exist.

(imported from commit b08b30b2a822663e17d64182af1fb160c2193344)
2014-01-29 12:41:20 -05:00
Steve Howell 34f6c705e9 Rename update_realm_filter() to flush_realm_filter().
(imported from commit f52b45b627f73ece8c7348451cea48f32142e94e)
2014-01-28 17:40:01 -05:00
Steve Howell 75555ff16c Rename update_realm_emoji_cache() to flush_realm_emoji().
(imported from commit fc97377113a3c2701addcc6fb0c5d1bc6f52933d)
2014-01-28 17:40:01 -05:00
Steve Howell 912f96e7ec Rename update_stream_cache() to flush_stream().
(imported from commit c67844ef7feb1924ec495c4451e33b56b237c88a)
2014-01-28 17:40:01 -05:00
Steve Howell c5edb58cd4 Turn flush_realm() into a post-save hook for Realm.
(imported from commit 97e44b51e2b35b4b5b64b4008f6a8d3585a26e33)
2014-01-28 17:40:01 -05:00
Steve Howell 0eed5d20d2 Create cache.flush_realm() and call it from do_deactivate_realm().
This is a slight behavior change, as we now flush user_profile
caches for bots as well as humans.

(imported from commit 24c72c44d851ee4c66a67a4728cd6c548faeedcd)
2014-01-28 17:40:00 -05:00
Steve Howell 3776d11c3a Rename update_user_profile_cache() to flush_user_profile().
(imported from commit 1fddb8b8dfe7943ace70c51d762eeae2ee1203a0)
2014-01-28 17:40:00 -05:00
Leo Franchi 883157893c Use a UserMessage flag to indicate /me messages
(imported from commit ea503b0d3eb6e90230c0859be96ede60faf5c2bd)
2014-01-27 12:07:48 -05:00
Tim Abbott da90d63046 Split out zerver/lib/notifications.py from actions.py.
(imported from commit 784b82834ee4fcb4431e77f8fb1c526f8eec82ad)
2014-01-24 17:33:56 -05:00
Jason Michalski 4104f00229 [schema] Add description to streams and display it
A description was added to the streams and it is now displayed on the
subscriptions page. It can not be set in the UI yet.

(imported from commit 81d08b65eee42dba87cd99dd5bd30106c4eb6c6a)
2014-01-24 14:47:44 -05:00
Jason Michalski 4c90392261 [schema] Add an per-user option to disable notification on new streams
Added a default_desktop_notifications boolean to userprofile with a UI
in Zulip Labs. This flag is used to default the notification flag on new
subscriptions.

(imported from commit a25223cc5ecf09980cf877991e25034bb3fd4046)
2014-01-16 20:13:34 -05:00
Steve Howell 8bf9068d0b Add back end support to restrict creation of streams.
Note that this doesn't actually restrict anybody yet, but it
makes it so that UserProfile.can_create_streams must return True
for a user to create a stream.  We can modify that in the future
to have special behavior for realms that want more restrictions.

(imported from commit 432e85b1ca86aaee4a6bd1d4a6d0b2c78ecb0863)
2014-01-16 14:43:56 -05:00
Jessica McKellar a1d128b6cb Flush memcached on a stream privacy change.
Otherwise uninvited users can join a stream recently turned
invite-only.

(imported from commit ab43bf3b856a0e3b71e6e06cee1519214b7763cd)
2014-01-15 17:13:56 -05:00
Zev Benjamin 3720cb1c33 Move message-related views into their own file
(imported from commit 2c71cc1b5d3f0210c98767888c461d5c6d046b49)
2014-01-10 21:38:59 -05:00
Tim Abbott 47500d8352 [schema] Add a bit for whether inactive users are mirror dummies.
(imported from commit bb21bb2c62ac09742484d7a4ca8907e7d864b982)
2014-01-09 11:08:35 -05:00
Jessica McKellar 8e3911269e Strip whitespace from emails before looking up DB entries in a few places.
(imported from commit eafdce98450d16c0ca51c4cb17a139811a6124bc)
2014-01-07 20:24:21 -05:00
Jessica McKellar a06b5bd720 [schema] Add a deactivated field to Realm.
(imported from commit 8b873296d45dbacc0865c8d101a872be0b65ed46)
2014-01-07 20:24:20 -05:00
Jessica McKellar 8091634814 Move sent_by_human check to a method on the Message class.
(imported from commit 2ef49051932f9633ad11130952591c5c5b147f12)
2013-12-31 16:42:38 -05:00
Tim Abbott 014b5e8a91 Add a per-request realm filters cache.
This avoids doing hundreds of memcached queries in get_old_messages.

(imported from commit 8b64cac3e4e91d46762a13d6812bd3c6f517e9ef)
2013-12-19 14:04:55 -05:00
Tim Abbott c91415f318 Improve names for per-request display recipient cache.
It incorrectly advertises itself as per-process.

(imported from commit faf7ca7374d020058e80249bb16a4c6afbcb3e44)
2013-12-19 14:04:55 -05:00
acrefoot 0fd492a817 [schema] Add enable_autoscroll_past_unread setting
This is for the CUSTOMER28 folks, so that they can turn Zulip into a more "chat client" thing.

(imported from commit 373a8afae4998fce5560e7b2bd13804c8fbb39fc)
2013-12-13 11:50:03 -05:00
Kevin Mehall e4589700b6 [schema] Modify device token to support both iOS and Android
This replaces the AppleDeviceToken table with a generic
PushDeviceToken with a `kind` field to make it easier to add functionality
like per-device/per-stream settings that share code between Android and
iOS devices.

The schema must continue to work on prod with the old table name, so we
add the new table in parallel and can drop the old table once this code
hits prod and any necessary data is copied.

(imported from commit 0209a7013f2850ac6311f23c3d6f92c65ffd19e3)
2013-12-11 15:37:47 -05:00
Leo Franchi 2c4efecee2 [schema] Add data model for managing realm filters via the database.
(imported from commit c624cdda9c23d9ca42706bf64b4c8a4e69e95c50)
2013-12-11 14:39:09 -05:00
Tim Abbott 1fb9c09f02 Don't import bugdown in models.py headings.
This allows us to avoid a circular import when importing models.py
from inside bugdown for the realm-filters-from-database branch.

(imported from commit 7de85b54243132ade6818b080abdc8c5e8ad84f5)
2013-12-11 14:39:09 -05:00
Tim Abbott 59e16feae1 Check whether realm exists in completely_open check.
(imported from commit 5294c4c7cdb6c03feb6bf716a3fc761dc7af1500)
2013-12-09 15:26:15 -05:00
Tim Abbott e56e892578 Enable public streams for most legacy realms.
(imported from commit 6844df2e14c624239d99a1d3fc25e55206c8c264)
2013-12-06 16:26:10 -05:00
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