mirror of https://github.com/zulip/zulip.git
widgets: Remove ALLOW_SUB_MESSAGES flag and enable widgets by default.
This commit is contained in:
parent
a197959959
commit
a2751d90c2
|
@ -34,7 +34,6 @@ messages).
|
||||||
Here are some code entities used in the above
|
Here are some code entities used in the above
|
||||||
features:
|
features:
|
||||||
|
|
||||||
- `ALLOW_SUB_MESSAGES` setting
|
|
||||||
- `SubMessage` database table
|
- `SubMessage` database table
|
||||||
- `/json/zcommand` API endpoint
|
- `/json/zcommand` API endpoint
|
||||||
- `/json/submessage` API endpoint
|
- `/json/submessage` API endpoint
|
||||||
|
@ -109,13 +108,10 @@ launch widgets by sending one of the following messages:
|
||||||
- /todo
|
- /todo
|
||||||
- /tictactoe
|
- /tictactoe
|
||||||
|
|
||||||
These widgets are only turned on if you set the `ALLOW_SUB_MESSAGES`
|
The webapp client provides the "widget experience" by
|
||||||
boolean to `True` in the appropriate `settings.py`.
|
default. Other clients just show raw messages like
|
||||||
Currently the setting is only enabled for dev and
|
"/poll" or "/ticactoe", and should be adding support
|
||||||
our main community realm (chat.zulip.org). Also,
|
for widgets soon.
|
||||||
only the webapp client provides the "widget experience".
|
|
||||||
Other clients just show raw messages like "/poll"
|
|
||||||
or "/ticactoe".
|
|
||||||
|
|
||||||
Our customers have long requested a poll/survey widget.
|
Our customers have long requested a poll/survey widget.
|
||||||
See [this issue](https://github.com/zulip/zulip/issues/9736).
|
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
|
The beautiful thing is that any thrid party developer
|
||||||
can enhance bots that are similar to the **trivia_quiz**
|
can enhance bots that are similar to the **trivia_quiz**
|
||||||
bot without touching any Zulip code, because **zforms**
|
bot without touching any Zulip code, because **zforms**
|
||||||
are completely generic. (The only caveat is that
|
are completely generic.
|
||||||
the server must turn on `ALLOW_SUB_MESSAGES`.)
|
|
||||||
|
|
||||||
## Data flow
|
## Data flow
|
||||||
|
|
||||||
|
|
|
@ -46,11 +46,9 @@ def get_extra_data_from_widget_type(content: str,
|
||||||
|
|
||||||
def do_widget_post_save_actions(message: MutableMapping[str, Any]) -> None:
|
def do_widget_post_save_actions(message: MutableMapping[str, Any]) -> None:
|
||||||
'''
|
'''
|
||||||
This is experimental code that only works with the
|
This code works with the webapp; mobile and other
|
||||||
webapp for now.
|
clients should also start supporting this soon.
|
||||||
'''
|
'''
|
||||||
if not settings.ALLOW_SUB_MESSAGES:
|
|
||||||
return
|
|
||||||
content = message['message'].content
|
content = message['message'].content
|
||||||
sender_id = message['message'].sender_id
|
sender_id = message['message'].sender_id
|
||||||
message_id = message['message'].id
|
message_id = message['message'].id
|
||||||
|
|
|
@ -232,12 +232,3 @@ class WidgetContentTestCase(ZulipTestCase):
|
||||||
submessage = SubMessage.objects.get(message_id=message.id)
|
submessage = SubMessage.objects.get(message_id=message.id)
|
||||||
self.assertEqual(submessage.msg_type, 'widget')
|
self.assertEqual(submessage.msg_type, 'widget')
|
||||||
self.assertEqual(ujson.loads(submessage.content), expected_submessage_content)
|
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())
|
|
||||||
|
|
|
@ -27,10 +27,6 @@ def process_submessage(request: HttpRequest,
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
message, user_message = access_message(user_profile, message_id)
|
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:
|
try:
|
||||||
ujson.loads(content)
|
ujson.loads(content)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
@ -246,10 +246,6 @@ DEFAULT_SETTINGS = {
|
||||||
# In-development search pills feature.
|
# In-development search pills feature.
|
||||||
'SEARCH_PILLS_ENABLED': False,
|
'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
|
# We log emails in development environment for accessing
|
||||||
# them easily through /emails page
|
# them easily through /emails page
|
||||||
'DEVELOPMENT_LOG_EMAILS': DEVELOPMENT,
|
'DEVELOPMENT_LOG_EMAILS': DEVELOPMENT,
|
||||||
|
|
Loading…
Reference in New Issue