Commit Graph

44284 Commits

Author SHA1 Message Date
Mateusz Mandera 4161e0caeb rate_limit: Show html page when rate limited at /new/ endpoint.
Previously this showed a json error, but this is an endpoint that human
users use in the browser, so a proper HTML page is more appropriate.
2021-07-28 15:24:04 -07:00
Priyam Seth 3ec55e7976 compose: Move keydown and keyup from compose.js to compose_ui.js.
This commit moves the handle_keydown and handle_keydown functions
of compose.js to compose_ui.js.

Part of splitting compose.js.
2021-07-28 14:01:40 -07:00
Abhijeet Prasad Bodas de04f0ad67 notifications: Calculate PMs/mentions settings like other settings.
Previously, we checked for the `enable_offline_email_notifications` and
`enable_offline_push_notifications` settings (which determine whether the
user will receive notifications for PMs and mentions) just before sending
notifications. This has a few problem:

1. We do not have access to all the user settings in the notification
handlers (`handle_missedmessage_emails` and `handle_push_notifications`),
and therefore, we cannot correctly determine whether the notification should
be sent. Checks like the following which existed previously, will, for
example, incorrectly not send notifications even when stream email
notifications are enabled-
```
if not receives_offline_email_notifications(user_profile):
    return
```
With this commit, we simply do not enqueue notifications if the "offline"
settings are disabled, which fixes that bug.

Additionally, this also fixes a bug with the "online push notifications"
feature, which was, if someone were to:
* turn off notifications for PMs and mentions (`enable_offline_push_notifications`)
* turn on stream push notifications (`enable_stream_push_notifications`)
* turn on "online push" (`enable_online_push_notifications`)

then, they would still receive notifications for PMs when online.
This isn't how the "online push enabled" feature is supposed to work;
it should only act as a wrapper around the other notification settings.

The buggy code was this in `handle_push_notifications`:
```
if not (
    receives_offline_push_notifications(user_profile)
    or receives_online_push_notifications(user_profile)
):
    return

    // send notifications
```

This commit removes that code, and extends our `notification_data.py` logic
to cover this case, along with tests.

2. The name for these settings is slightly misleading. They essentially
talk about "what to send notifications for" (PMs and mentions), and not
"when to send notifications" (offline). This commit improves this condition
by restricting the use of this term only to the database field, and using
clearer names everywhere else. This distinction will be important to have
non-confusing code when we implement multiple options for notifications
in the future as dropdown (never/when offline/when offline or online, etc).

3. We should ideally re-check all notification settings just before the
notifications are sent. This is especially important for email notifications,
which may be sent after a long time after the message was sent. We will
in the future add code to thoroughly re-check settings before sending
notifications in a clean manner, but temporarily not re-checking isn't
a terrible scenario either.
2021-07-28 13:55:25 -07:00
Riken Shah 6eb88eb3ef puppeteer: Use a better approach to open user popover.
This commit improves the approach to click on the menu
icon on the right sidebar. It'd first hover on the list
instead of the menu to avoid the occasional "HTML node
not present" error. As menu icon our only visible when
we hover over the item.
2021-07-28 12:07:48 -07:00
Tim Abbott 2a2654d5f5 css: Fix vertical alignment of unread message pills.
I'm not entirely sure what broken this, but both the unread message
pills and the \vdots menu were not centered vertically.

Fix for the unread message pills should be general and complete, since
it just declares center alignment, but the \vdots menu is a hack;
further cleanup of that element's CSS is needed to end up with
something good.
2021-07-28 12:04:38 -07:00
Tim Abbott e4667c2af6 docs: Add developer documentation for Python support. 2021-07-28 11:23:27 -07:00
Abhijeet Prasad Bodas 683c8507e4 models: Remove MutedTopic alias for UserTopic.
Part of #19272
2021-07-28 10:25:54 -07:00
Abhijeet Prasad Bodas 798defc046 models: Rename MutedTopic to UserTopic.
Part of #19272

We still keep refering to this model with "MutedTopic" to reduce the
diff size of this commit. The alias will be removed in the next commit.

This commit skips on renaming the `date_muted` field to something more
general. That will be done in further commits, along with the code and
API changes.
2021-07-28 10:25:53 -07:00
Tim Abbott 8532e22fcd user_status: Simplify user status popover labels. 2021-07-28 10:02:51 -07:00
Riken Shah 4eeb6be787 user_status: Add default emoji for common statuses.
Co-authored-by: Yash Rathore <33805964+YashRE42@users.noreply.github.com>
2021-07-28 10:02:51 -07:00
Riken Shah cea961b129 user_info_popover: Show status emoji.
In this commit,

* We show status emoji alongside status text in the user
info popover.

* Updated clear status button to also clear status emoji.
2021-07-28 10:02:51 -07:00
Riken Shah 297379029d user_status: Add UI changes for status emoji feature.
In this commit, we update the UI to:

*  Display emoji on the buddy list (right side sidebar).

*  Display the emoji picker on the set status overlay.

It also updates the `z-index` of
`#set_user_status_modal`, which was changed from 105
to 1050 in 166bfa4cf8. We change it back to 105, so
emoji-popover can be visible on top of the
`#set_user_status_modal`.

We also remove the `tabindex` property from the
`#set_user_status_modal` so it can allow keyboard
events for emoji popover.
2021-07-28 10:02:50 -07:00
Riken Shah 840ab92f7f user_status: Add architecture to support status emoji feature.
In this commit, we only update the existing architecture
to support the status emoji feature:

* We add the `user_status_emoji_info` map so we can
keep track of the users' staus emoji.

* Listen to the server event to update/set the
`user_status_emoji_info` map.

* Add `status_emoji_info` field, when getting user's data.
2021-07-28 09:50:11 -07:00
Riken Shah 6c003a7802 refactor: Move emoji details related code to `emoji.js`.
As `reaction.js` and `user_status.js` has similar code to
get emoji details, it makes more sense to extract this as a
single function.
2021-07-28 09:35:00 -07:00
Gaurav Pandey dc2066c7e8 ci: Remove unnecessary steps from production upgrade script.
This removes some steps which are no longer necessary to be run
in the production upgrade script. The steps were used due to
errors related to supervisor failing to restart which was resolved
in the commit 08c39a7388.
2021-07-28 08:44:15 -07:00
Tim Abbott 63ed398c22 Revert "composebox_typeahead: Trigger foucs to send button only after keyup event."
This reverts commit 3531463ac9.

I also add a comment explaining why this commit was wrong, that should
help us avoid doing this cleanup again.
2021-07-27 18:39:43 -07:00
Riken Shah 9fadd43830 user_status: Add backend changes to support status emoji.
In this commit:

* We update the `UserStatus` model to accept
`AbstractReaction` as a base class so, we can get all the
fields related to store status emoji.

* We update the user status endpoint
(`users/me/status`) to accept status emoji fields.

* We update the user status event to add status emoji
fields.

Co-authored-by: Yash Rathore <33805964+YashRE42@users.noreply.github.com>
2021-07-27 17:57:15 -07:00
Tim Abbott ed01ffadba tests: Fix leading slash in test exclusion as well. 2021-07-27 17:01:18 -07:00
Tim Abbott 5feb3f288c urls: Fix unnecessary leading slash on URL.
This fixes Django warnings introduced in the previous commit.
2021-07-27 16:49:07 -07:00
sahil839 0d6f378ad7 help: Update documentation for add_custom_emoji_policy. 2021-07-27 16:41:23 -07:00
sahil839 b8854a9d92 settings: Add full members and moderators options in custom emoji setting. 2021-07-27 16:41:23 -07:00
sahil839 1ce09d9db6 realm: Extend add_custom_emoji_policy to use COMMON_POLICY_TYPES.
This commit adds full members and moderators option for
add_custom_emoji_policy by using COMMON_POLICY_TYPES.
2021-07-27 16:41:23 -07:00
sahil839 5efc854f66 models: Add can_add_custom_emoji helper.
This commit adds can_add_custom_emoji
helper to check whether the user can
add custom emoji or not.

This function will be used further when
add_custom_emoji_policy will be extended
to include all COMMON_POLICY_VALUES.
2021-07-27 16:41:23 -07:00
sahil839 9ef8727a4a docs: Fix new_feature_tutorial to replace add_emoji_by_admins_only.
This commit replaces add_emoji_by_admins_only with
add_custom_emoji_policy in new_feature_tutorial.md
as the old boolean setting is replaced by a new
integer setting.
2021-07-27 16:41:23 -07:00
sahil839 4b1313a92b models: Replace add_emoji_by_admins_only with add_custom_emoji_policy.
This commit replaces boolean field add_emoji_by_admins_only with an
integer field add_custom_emoji_policy as we would also add full members
and moderators option for this setting in further commits.
2021-07-27 16:41:22 -07:00
Anders Kaseorg 17749cb608 archive: Remove non-functional archive code.
This removes a bunch of non-functional duplicate JavaScript, HTML, and
CSS that was interfering with maintenance on the functional originals,
because it was never clear how to update the duplicates or how to
check that you’d updated the duplicates correctly.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-07-27 16:25:24 -07:00
akshatdalton 3531463ac9 composebox_typeahead: Trigger foucs to send button only after keyup event.
As explained in the commit 3a35a0b72c9b2c46ed0afa6456d4a5a80a2c12f9:
`nextFocus` is set on a keydown event to indicate where
we should focus on keyup. We can't focus at the time of
keydown because we need to wait for typeahead. And we
can't compute where to focus at the time of keyup because
only the keydown has reliable information about whether it
was a Tab or a Shift+Tab.

Though the previous configuration didn't show any bug but we should
follow the same logic here also.
2021-07-27 16:17:31 -07:00
akshatdalton 30435d7943 composebox_typeahead: Prevent default actions only after triggering the focus.
In this case, we need to prevent the default actions
only after triggering the focus of the selected element.

This was known to cause a bug where after starting a new
topic, if one presses the tab key, then focus was not shifted
from the topic input box to the compose box. This commit fixes
that bug.

See: https://chat.zulip.org/#narrow/stream/9-issues/topic/tab.20key.20not.20working.20from.20topic.20input.20box/near/1235022.
2021-07-27 16:17:31 -07:00
M@ 53540432e1
compose: Fix typos in error message for too-long compose content. 2021-07-27 16:03:19 -07:00
Sahil Batra 79b0ff5b23 events: Send enter_sends if update_display_settings in fetch_event_types.
We now send 'enter_sends' in response of '/register' endpoint if
'update_display_settings' is present in 'fetch_event_types' instead
of 'realm_user'.
2021-07-27 15:54:16 -07:00
Sahil Batra 355f6e9b53 settings: Move 'enter_sends' setting to property_types dict.
This commit moves "enter_sends" setting to property_types dict.
With this change, changing enter_sends setting also sends an
event of type "update_display_settings" and thus enables us
to live-update the UI.
2021-07-27 15:52:53 -07:00
Sahil Batra dafd32bd09 compose: Extract compose.toggle_entry_sends_ui function.
This commit extracts the code for hiding and showing the
send button according to 'enter_sends' setting value in
a separate function.
2021-07-27 15:52:53 -07:00
Mateusz Mandera 7af789c48f models: Make realm_id arg of get_system_bot required. 2021-07-27 15:51:59 -07:00
Mateusz Mandera 013d6fa5e6 bots: Assume STAFF_SUBDOMAIN to be the realm where ERROR_BOT lives.
Now that get_system_bot requires a realm argument, a subdomain
needs to be made explicit to know in which organization to look up the
bot.
2021-07-27 15:51:59 -07:00
akshatdalton 3a35a0b72c composebox_typeahead: Re-add comment to explain the need of `nextFocus` variable.
This commit re-adds the comment to explain the need
of `nextFocus` variable which was deleted in
3b0694693b.
2021-07-27 15:41:29 -07:00
Aman Agrawal 0889ded057 plans: Make faq header linkable. 2021-07-27 12:55:54 -07:00
PIG208 ec99c1b58d analytics: Correctly type aggregate_table with Union.
Since mypy doesn't accept redefinition of the same variable within the
same scope, we need to use type annotations with Union to correctly
type aggregate_table. Note that the type cast is necessary for mypy to
narrow the type of aggregate_table.
2021-07-27 12:17:01 -07:00
PIG208 6ab42b7663 analytics: Use type alias for `fixture_data`.
This saves us from repeating the lengthy type annotation for
`fixture_data`.
2021-07-27 12:17:01 -07:00
PIG208 e517f967b8 typing: Amend inaccurate type annotations.
This amend some type annotations that turn out to be inaccurate with
django-stubs.
2021-07-27 12:17:00 -07:00
PIG208 caaa424ef5 typing: Use assertions for broader types.
For types like `Union[Realm, UserProfile, Stream]` and
`Union[AnonymousUser, AbstractBaseUser]`, we need assertions to
tell mypy which type we would be expecting.
2021-07-27 11:44:54 -07:00
PIG208 8121d2d58d typing: Fix misuse of HttpResponse.
Amend usage of HttpResponse when appropriate.
2021-07-27 14:31:19 +08:00
Suyash Vardhan Mathur ad8d9f2133 docs: Document the new APIDocs template system.
Recently, the need for individual Markdown templates for
every endpoint's OpenAPI page was removed, as they are now
auto-generated from OpenAPI data. Further, as a part of this
migration, several new fields and Markdown extensions were added.
This commit updates the documentation to reflect the changes that
have occured as a result of the migration.

With various edits by tabbott to clarify or simplify the documentation.
2021-07-26 18:38:57 -07:00
Alya Abbott 0e89f03ca2 user docs: Add workflow instructions for using Zulip via email. 2021-07-26 18:22:09 -07:00
Tim Abbott 9ada794ce1 test_openapi: Fix mis-resolved merge conflict. 2021-07-26 18:22:09 -07:00
Suyash Vardhan Mathur ec6739ff29 openapi: Document get-subscribers endpoint. 2021-07-26 18:12:12 -07:00
Suyash Vardhan Mathur 2d2b089066 openapi: Document delete-topic endpoint. 2021-07-26 17:56:04 -07:00
sahil839 c840ece1a3 help: Update the documentation for inviting new users.
This commit updates the documentation to mention that
only owners can change who can send invitations.
We also add the newly added "Nobody" option for this
setting in the documentation.
2021-07-26 17:48:01 -07:00
sahil839 cfd64cf951 settings_ui: Add option for changing label on disabling input.
We only disable the dropdown and keep the label as it is when
disabling a dropdown input, but for a check-box we need to
change label style also while disabling it.

Till now disable_sub_settings_on_change was used only for
dropdown but will be used for a check-box in the next commit.
2021-07-26 17:48:01 -07:00
sahil839 c7e756f984 setting: Allow only owners to change "Who can invite users" setting. 2021-07-26 17:48:01 -07:00
sahil839 ca0bb5b9d8 settings: Add nobody option for invite_to_realm_policy in frontend. 2021-07-26 17:48:01 -07:00