From a2751d90c292251a0a57c932fa2059d441408caf Mon Sep 17 00:00:00 2001 From: Rohitt Vashishtha Date: Tue, 29 Jan 2019 15:57:45 +0000 Subject: [PATCH] widgets: Remove ALLOW_SUB_MESSAGES flag and enable widgets by default. --- docs/subsystems/widgets.md | 15 +++++---------- zerver/lib/widget.py | 6 ++---- zerver/tests/test_widgets.py | 9 --------- zerver/views/submessage.py | 4 ---- zproject/settings.py | 4 ---- 5 files changed, 7 insertions(+), 31 deletions(-) diff --git a/docs/subsystems/widgets.md b/docs/subsystems/widgets.md index 4ea61a8e8e..89c2438902 100644 --- a/docs/subsystems/widgets.md +++ b/docs/subsystems/widgets.md @@ -34,7 +34,6 @@ messages). Here are some code entities used in the above features: -- `ALLOW_SUB_MESSAGES` setting - `SubMessage` database table - `/json/zcommand` API endpoint - `/json/submessage` API endpoint @@ -109,13 +108,10 @@ launch widgets by sending one of the following messages: - /todo - /tictactoe -These widgets are only turned on if you set the `ALLOW_SUB_MESSAGES` -boolean to `True` in the appropriate `settings.py`. -Currently the setting is only enabled for dev and -our main community realm (chat.zulip.org). Also, -only the webapp client provides the "widget experience". -Other clients just show raw messages like "/poll" -or "/ticactoe". +The webapp client provides the "widget experience" by +default. Other clients just show raw messages like +"/poll" or "/ticactoe", and should be adding support +for widgets soon. Our customers have long requested a poll/survey widget. See [this issue](https://github.com/zulip/zulip/issues/9736). @@ -301,8 +297,7 @@ and grades the answer using ordinary chat-bot coding. The beautiful thing is that any thrid party developer can enhance bots that are similar to the **trivia_quiz** bot without touching any Zulip code, because **zforms** -are completely generic. (The only caveat is that -the server must turn on `ALLOW_SUB_MESSAGES`.) +are completely generic. ## Data flow diff --git a/zerver/lib/widget.py b/zerver/lib/widget.py index d8ec1bfaf2..98fd048c5d 100644 --- a/zerver/lib/widget.py +++ b/zerver/lib/widget.py @@ -46,11 +46,9 @@ def get_extra_data_from_widget_type(content: str, def do_widget_post_save_actions(message: MutableMapping[str, Any]) -> None: ''' - This is experimental code that only works with the - webapp for now. + This code works with the webapp; mobile and other + clients should also start supporting this soon. ''' - if not settings.ALLOW_SUB_MESSAGES: - return content = message['message'].content sender_id = message['message'].sender_id message_id = message['message'].id diff --git a/zerver/tests/test_widgets.py b/zerver/tests/test_widgets.py index 4a9df23610..97199738dd 100644 --- a/zerver/tests/test_widgets.py +++ b/zerver/tests/test_widgets.py @@ -232,12 +232,3 @@ class WidgetContentTestCase(ZulipTestCase): submessage = SubMessage.objects.get(message_id=message.id) self.assertEqual(submessage.msg_type, 'widget') self.assertEqual(ujson.loads(submessage.content), expected_submessage_content) - - # Now test the feature flag. - with self.settings(ALLOW_SUB_MESSAGES=False): - result = self.api_post(sender_email, "/api/v1/messages", payload) - self.assert_json_success(result) - - message = self.get_last_message() - self.assertEqual(message.content, content) - self.assertFalse(SubMessage.objects.filter(message_id=message.id).exists()) diff --git a/zerver/views/submessage.py b/zerver/views/submessage.py index 93a416676b..30a51ce1bd 100644 --- a/zerver/views/submessage.py +++ b/zerver/views/submessage.py @@ -27,10 +27,6 @@ def process_submessage(request: HttpRequest, ) -> HttpResponse: message, user_message = access_message(user_profile, message_id) - if not settings.ALLOW_SUB_MESSAGES: # nocoverage - msg = 'Feature not enabled' - return json_error(msg) - try: ujson.loads(content) except Exception: diff --git a/zproject/settings.py b/zproject/settings.py index 11a1ab83a9..acbff7873a 100644 --- a/zproject/settings.py +++ b/zproject/settings.py @@ -246,10 +246,6 @@ DEFAULT_SETTINGS = { # In-development search pills feature. 'SEARCH_PILLS_ENABLED': False, - # We use SubMessage for now-experimental features like - # slash commands. - 'ALLOW_SUB_MESSAGES': DEVELOPMENT, - # We log emails in development environment for accessing # them easily through /emails page 'DEVELOPMENT_LOG_EMAILS': DEVELOPMENT,