From ea21528b1fba618109d97646cb459de98aeb751e Mon Sep 17 00:00:00 2001 From: MelissaCole Date: Thu, 20 Aug 2015 13:45:24 -0700 Subject: [PATCH] Feature flag modmail muting --- r2/example.ini | 2 ++ r2/r2/controllers/api.py | 12 ++++++++++++ r2/r2/controllers/listingcontroller.py | 2 ++ r2/r2/lib/pages/pages.py | 3 +++ r2/r2/lib/pages/things.py | 17 +++++++++-------- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/r2/example.ini b/r2/example.ini index 2f5fd1f05..685dd0676 100644 --- a/r2/example.ini +++ b/r2/example.ini @@ -339,6 +339,7 @@ newsletter_list_id = ############################################ QUOTAS # quota for various types of relations creatable in subreddits sr_banned_quota = 10000 +sr_muted_quota = 10000 sr_moderator_invite_quota = 10000 sr_contributor_quota = 10000 sr_wikibanned_quota = 10000 @@ -874,3 +875,4 @@ feature_give_hsts_grants = off feature_multireddit_customizations = off # Test if `https_testing_img_test` is loaded with an acceptable HTTPS cert according to users' browsers feature_test_https_certs = off +feature_modmail_muting = off diff --git a/r2/r2/controllers/api.py b/r2/r2/controllers/api.py index 54de53e06..624a7e641 100644 --- a/r2/r2/controllers/api.py +++ b/r2/r2/controllers/api.py @@ -855,6 +855,9 @@ class ApiController(RedditController): Complement to [POST_friend](#POST_api_friend) """ + if type == 'muted' and not feature.is_enabled('modmail_muting'): + return abort(403, "This feature is not yet enabled") + self.check_api_friend_oauth_scope(type) victim = iuser or nuser @@ -997,6 +1000,9 @@ class ApiController(RedditController): Complement to [POST_unfriend](#POST_api_unfriend) """ + if type == 'muted' and not feature.is_enabled('modmail_muting'): + return abort(403, "This feature is not yet enabled") + self.check_api_friend_oauth_scope(type) if type in self._sr_friend_types: @@ -1766,6 +1772,9 @@ class ApiController(RedditController): if not subreddit: abort(403, 'Not modmail') + if not feature.is_enabled('modmail_muting', subreddit=subreddit.name): + return abort(403, "This feature is not yet enabled") + user = message.author_slow if not c.user_is_admin: if not subreddit.is_moderator_with_perms(c.user, 'access', 'mail'): @@ -1800,6 +1809,9 @@ class ApiController(RedditController): if not subreddit: abort(403, 'Not modmail') + if not feature.is_enabled('modmail_muting', subreddit=subreddit.name): + return abort(403, "This feature is not yet enabled") + user = message.author_slow if not c.user_is_admin: if not subreddit.is_moderator_with_perms(c.user, 'access', 'mail'): diff --git a/r2/r2/controllers/listingcontroller.py b/r2/r2/controllers/listingcontroller.py index f4e7ca4a4..e4e020494 100644 --- a/r2/r2/controllers/listingcontroller.py +++ b/r2/r2/controllers/listingcontroller.py @@ -1750,6 +1750,8 @@ class UserListListingController(ListingController): elif where == 'muted': if not has_mod_access: abort(403) + if not feature.is_enabled('modmail_muting'): + abort(403) self.listing_cls = MutedListing elif where == 'wikibanned': diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index f02558774..26d905e51 100644 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -494,6 +494,9 @@ class Reddit(Templated): if is_single_subreddit: if is_moderator_with_perms('access'): buttons.append(NamedButton("banned", css_class="reddit-ban")) + + if (is_moderator_with_perms('access', 'mail') and + feature.is_enabled("modmail_muting")): buttons.append(NamedButton("muted", css_class="reddit-mute")) if is_moderator_with_perms('flair'): buttons.append(NamedButton("flair", css_class="reddit-flair")) diff --git a/r2/r2/lib/pages/things.py b/r2/r2/lib/pages/things.py index d50faf618..0dce83abc 100644 --- a/r2/r2/lib/pages/things.py +++ b/r2/r2/lib/pages/things.py @@ -241,14 +241,15 @@ class MessageButtons(PrintableButtons): if thing.sr_id: sr = thing.subreddit_slow - if (sr.is_muted(first_message.author_slow) or - (first_message.to_id and - sr.is_muted(first_message.recipient_slow))): - is_muted = True - - if (not sr.is_moderator(thing.author_slow) and - sr.is_moderator_with_perms(c.user, 'access', 'mail')): - can_mute = True + if feature.is_enabled('modmail_muting', subreddit=sr.name): + if (sr.is_muted(first_message.author_slow) or + (first_message.to_id and + sr.is_muted(first_message.recipient_slow))): + is_muted = True + + if (not sr.is_moderator(thing.author_slow) and + sr.is_moderator_with_perms(c.user, 'access', 'mail')): + can_mute = True can_reply = (c.user_is_loggedin and getattr(thing, "repliable", True) and -- 2.11.4.GIT