widgets: Remove ALLOW_SUB_MESSAGES flag and enable widgets by default.

This commit is contained in:
Rohitt Vashishtha 2019-01-29 15:57:45 +00:00 committed by Tim Abbott
parent a197959959
commit a2751d90c2
5 changed files with 7 additions and 31 deletions

View File

@ -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

View File

@ -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

View File

@ -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())

View File

@ -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:

View File

@ -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,