Commit Graph

37820 Commits

Author SHA1 Message Date
Priyank Patel ad5eb68ee1 github-actions: Add focal backend job.
No new sets of change in this commit that are explained two commits
before this one, which add bionic-backend-frontend.
2020-07-06 18:09:15 -07:00
Priyank Patel e834439d82 provision: Do service <service-name> start instead of restart.
Doing service memcached start instead of restart fixed an issue on
focal build in GitHub actions, where it exits with code 1 when it
is done twice.It is done first in Install Dependencies step and then
again in last step where we call tools/ci/setup-backend again which
runs provision.

Furthermore, I don't belive there is a technical reason we use
restart over start; rather I think it was just a random choice with
the intend to just start the services in CI. I traced the code back
to commit 1f2f497cab if it helps.
Looking at the source code of memcached, the step that's failing is:
  start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
which is equivilent to: service memcached stop, we can rule out the
service memcache start since it works. Ideally, we do figure out and
solve the issue of why memcached fails when executing service
memcached stop but I am not equipped with debugging it. And this
workaround seems reasonable rather than a "hacky" solution.

For the relevant code in memcached see:
https://github.com/memcached/memcached/blob/master/scripts/memcached-init.

Finally, the change to the rest of services is for consistency.
2020-07-06 18:09:15 -07:00
Priyank Patel 7ff1fd5923 github-actions: Add bionic frontend and backend test job.
Some noteable diffrence from circleci:
   - We upgrade git to newer version (reason explained in comments)
   - We set HOME to /home/github (also explained in comments)
   - Adjust permissions (... comments)
   - Minor changes to step names and cache keys.
   - We don't need to port the save_cache steps they are done
     automatically in actions. And, we did not port the
     store_test_results step which is circleci specific.
   - We didn't port the notify_failure step yet (see the TODO).
2020-07-06 18:09:15 -07:00
arpit551 a2428017e9 audit_log: Log RealmAuditLog in do_set_realm_authentication_methods.
Log RealmAuditLog in do_set_realm_authentication_methods and added
tests for it.
2020-07-06 17:38:20 -07:00
arpit551 ba92666dbd audit_log: Log RealmAuditLog in do_set_realm_property.
Log RealmAuditLog in do_set_realm_property and do_remove_realm_domain.
Tests for the changes are written in test_events because it will save
duplicate code for test_change_realm_property.
2020-07-06 17:38:19 -07:00
arpit551 6af337c07e audit_log: Log RealmAuditLog when stream is deactivated. 2020-07-06 17:32:11 -07:00
arpit551 e0c9b0fdff audit_log: Log RealmAuditLog when Stream is created.
Added new Event Type in AbstractRealmAuditLog STREAM_CREATED.
Since we finally create streams in create_stream_if_needed function
in zerver/lib/streams.py so logged realm_audit there.
Passed acting_user when create_stream_if_needed or ensure_stream
function  is called.
Added tests in test_audit_log.
2020-07-06 17:32:11 -07:00
arpit551 8807cddc90 audit_log: Correctly add acting_user in bulk_remove_subscriptions.
Earlier we were not adding acting_user while creating RealmAuditLog
objects in bulk_remove_subscriptions. Improved tests_subscriptions
to check it.
2020-07-06 17:32:11 -07:00
arpit551 87aaa84b42 audit_log: Log acting_user in do_change_user_role. 2020-07-06 17:32:11 -07:00
arpit551 01f12b9fc2 audit_log: Log acting_user in user creation and user activation. 2020-07-06 17:32:09 -07:00
arpit551 653928bdfe audit_log: Log acting_user in do_change_avatar_fields. 2020-07-06 17:24:18 -07:00
arpit551 2279fef316 audit_log: Log acting_user in do_change_logo_source. 2020-07-06 17:24:18 -07:00
arpit551 19a8841a9e audit_log: Log acting_user in do_scrub_realm. 2020-07-06 17:24:18 -07:00
Mohit Gupta 98cff4ecbf tests: Move SoftDeactivationMessageTest to test_soft_deactivation.py.
This commit moves out the SoftDeactivationMessageTest out of
test_messages.py (which at the moment have mixed category of tests) into
a more logical file, test_soft_deactivation.py.
2020-07-06 16:36:36 -07:00
Mohit Gupta 146b21a34a tests: Move display_recipient fetching test to test_message_dict.py.
This commit moves TestMessageForIdsDisplayRecipientFetching class which
have tests regarding display_recipient filled in by MessageDict to
test_message_dict.py.
2020-07-06 16:36:36 -07:00
Mohit Gupta b21f59e2f3 tests: Move MessageHydrationTest to test_message_dict.py.
MessageHydrationTest tests hydration done by MessageDict, so moving it
out of test_messages.py to test_message_dict.py.
2020-07-06 16:36:36 -07:00
Mohit Gupta eee5318327 tests: Move InternalPrepTest to test_message_send.py.
This commit moves InternalPrepTest test class to test_message_send.py
because it tests internal_send_* and internal_prep_* functions which are
used for internal message sending in zulip.
2020-07-06 16:36:36 -07:00
Mohit Gupta fb08f27d0e tests: Move ExtractTest class to test_message_send.py.
This commit moves ExtractTest class to test_message_send.py as they
test input parsing extract_* functions used in message sending enpoints.
2020-07-06 16:36:36 -07:00
Mohit Gupta f7063f5ea0 tests: Extract out test_message_dict.py for MessageDict tests. 2020-07-06 16:36:36 -07:00
Mohit Gupta e927ff19ce tests: Move Private Message sending tests to test_message_send.py.
This commit moves few tests related to testing proper sending of private
messages from PrivateMessagesTest class in test_messages.py to a new class
in test_message_send.py.
2020-07-06 16:36:36 -07:00
Mohit Gupta c1e027fbe5 tests: Move StreamMessagesTest to test_message_send.py.
StreamMessagesTest test stuff after message is sent to a stream, so
moving it out from test_messages.py to test_message_send.py.
2020-07-06 16:36:36 -07:00
Mohit Gupta becd4e7367 tests: Move ScheduledMessageTest to test_message_send.py.
This commit moves ScheduledMessageTest that tests sending scheduled
messages from test_messages.py to test_message_send.py.
2020-07-06 16:36:36 -07:00
Mohit Gupta 17fac94ce4 tests: Move test_create_mirror_user_despite_race to test_mirror_users.py.
The commit moves, test_create_mirror_user_despite_race which is not related
to message sending from MessagePOSTTest class in test_message_send.py to
test_mirror_users.py.
2020-07-06 16:36:36 -07:00
Mohit Gupta 04cca01faa tests: Extract test_message_send.py for message sending tests.
This commit extracts out MessagePOSTTest class from test_messages.py
intially.
In future commits other related message sending tests will be moved from
test_messages.py to test_message_send.py.
2020-07-06 16:36:36 -07:00
Mohit Gupta 921b7ff070 tests: Extract out test_mirror_users.py.
Starting with extracting out MirroredMessageUsersTests as it is related to
mirror users than anything message-specific.
In a future commit, may extract out some tests from MessagePOSTTest as well
but still deciding on those.
2020-07-06 16:36:36 -07:00
Mohit Gupta c8f1ae15b9 tests: Extract test_message_topics.py for topic tests. 2020-07-06 16:36:36 -07:00
Mohit Gupta ccba038779 tests: Move DeleteMessageTest class to test_message_edit.py. 2020-07-06 16:36:36 -07:00
Mohit Gupta 79d3e0a7ad tests: Move EditMessageTest class to test_message_edit.py. 2020-07-06 16:36:36 -07:00
Anders Kaseorg f40ad639f8 test_events: Fix check_list(None) calls.
These were fixed by commit acd439dee8
but reintroduced by commit 18537b63f5.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-06 16:22:54 -07:00
Aman Agrawal 261bc043c9 thumbor: Replace comment type annotations with normal annotations.
Run custom lint checks on thumbor files.
2020-07-06 16:09:53 -07:00
Aman Agrawal a486872a8e requirements: Upgrade Thumbor to 7.0.0a5 on Python 3.
Co-authored-by: Anders Kaseorg <anders@zulip.com>
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-06 16:09:53 -07:00
Rohitt Vashishtha c87446a8de timestamp: Extract and improve timerender.get_timestamp_for_flatpickr.
To make the typeahead code more readable, we extract this function to
timerender. We also improve the logic to be more readable, and add tests
to confirm its validity.
2020-07-06 15:53:56 -07:00
Rohitt Vashishtha 5d1365b265 minor: Format comments to be sentences and fix typo. 2020-07-06 15:53:56 -07:00
Rohitt Vashishtha 0b510cd66d timestamp: Hide timestamp forrmat errors in local echo. 2020-07-06 15:53:56 -07:00
Rohitt Vashishtha 3d0a5d28f2 timestamp: Update docs to advertise new syntax and other time formats. 2020-07-06 15:53:56 -07:00
Rohitt Vashishtha 1f765b41ce timestamp: Throw error if frontend cannot parse backend supplied time.
We have moved our invalid timestamp logic to use timestamp-error class,
however, if there are any valid outputs by the backend markdown that
the frontend considers invalid, we want to debug them. This commit
adds tooling to ensure we log those error messages.
2020-07-06 15:53:56 -07:00
Rohitt Vashishtha 088b8e28c3 timestamp: Translate 'invalid time format' message on the frontend. 2020-07-06 15:53:56 -07:00
Rohitt Vashishtha 732ec3c0e6 timestamp: Change syntax to `<time:timestammp>`.
We had been using !time() syntax for timestamps so far. Since its
an unreleased feature, we can make changes without affecting many
people.

Fixes #15442.
2020-07-06 15:53:56 -07:00
Rohitt Vashishtha ca73d81bba timestamp: Extract show_flatpickr() in composebox_typeahead.
The time_jump typeahead code now reads like other typeaheads,
uncluttered with the flatpickr logic.
2020-07-06 15:53:56 -07:00
Aman Agrawal 18537b63f5 move_topic_to_stream: Apply the event to the fetched state.
Fixes #14101.

We fix the unread count for the messages which were moved to
the new stream too.
2020-07-06 15:48:55 -07:00
Aman Agrawal a7eef1ed35 mark_all_messages_unread: Remove reset of depricated pointer. 2020-07-06 15:47:27 -07:00
Ryan Rehman c234b4f254 subscriptions: Fix buggy behaviour of click event handlers.
This commit fixes a bug where clicking on a stream row on the left
in the subscriptions table called the ".stream-row" as well as the
".sub_unsub_button" click events in `stream_edit.js`.

This caused the stream subscription to toggle everytime the row was
clicked. Also, this bug is only observed if the ".sub_unsub_button"
had been clicked first.
2020-07-06 15:43:41 -07:00
Ryan Rehman ca99d62b4e subscriptions: Fix scrolling of streams list.
The previous element passed was a simplebar container which calculated
the incorrect height, thus `scroll_util.scroll_element_into_container`
had no effect.
2020-07-06 15:43:41 -07:00
Ryan Rehman 23f807bf13 subscriptions: Remove unused event handler.
".subscribed-button" was added in
ca4e6a0ff8.
In commit 368b585980,
it was replaced by the "check" class.
2020-07-06 15:43:41 -07:00
Ryan Rehman 3b5ba6b2c1 message list: Change locally echoed message ids synchronously.
There is a bug and race issue that occurs when a message is selected
while we are in the process of reifying a locally echoed message,
raising the "Selected message id not in MessageList" error.
The code flow to get the exception is as follows:

* A user sends a message to the current narrow we are in.
* Before the new message event is received, we sent a message to
  the same message list which renders it with a locally echoed id.
* One of the ways of getting the exception is to already have the
  locally sent message selected, before receiving an acknowledgment
  from the server.
* Thus the Message List Data's `selected_id` now points to the new
  message id. The exception is raised on entering the `was_selected`
  if block inside `message_list_view` which tries to re-select the
  message.

Updating the `_rerender_message` code for this special case won't fix
the entire bug because, as mentioned above there are other ways of
getting the exception:

Ideally, after all our synchronous work (`echo.process_from_server`)
has completed we would expect the re-order and re-render work of the
`change_message_id` would occur first, due to the timer of the
setTimeout being set to 0.

However as evident from the race condition existing, this isn't always
the case. `change_message_id` function is responsible for 3 things:
updation, re-ordering and re-rendering.
The first one which is responsible for updating the message list's
local cache, occurs synchronously while for the latter two, they both
occur asynchronously.

Before the setTimeout which is responsible for the latter two actions,
is encountered the user might select the message by clicking or more
commonly by scrolling, which causes this message selection event to be
ahead of the setTimeout in the callback queue.
During this time frame, our race condition takes place.

And even though the message id is updated it's Message List is not
in the correct sort order, which leads to `closest_id` !== `id` in
`MessageList_select_id` being true and raising the exception.

Now, we only asynchronously call the re_render function, to guarantee
the data is always correct and UI updates should be done at the end.

Extended by tabbott to comment the setTimeout call.

Fixes #15346.
2020-07-06 15:36:33 -07:00
Ryan Rehman 7a8ebfb5eb message list: Update `MessageListData` API by extracting `reorder_messages`.
`change_message_id` in `message_list_data.js` is only called from
one place, the `change_message_id` function in `message_list.js`.
2020-07-06 15:31:26 -07:00
sahil839 66dc712830 compose: Modify validate_stream_message to check invalid stream name early.
We change validate_stream_message to check the existence of stream from
the stream name in compose box early and we then pass stream_id or the
obtained sub objects accordingly to other validate functions.

Passing stream_id or sub objects to these functions, enables us to use
stream_id instead of stream name in stream_data.get_subscriber_count.

stream_data.get_stream_post_policy is also removed as we only used it in
validate_stream_message_policy, but we do not need it now as we can get
stream_post_policy directly from sub object obtained by early check of
valid stream name.
2020-07-06 15:30:01 -07:00
sahil839 c4c1790b00 compose: Add data-stream-id field in compose_invite_users.
This commits add data-stream-id attribute to the compose_invite_users
template. This helps in avoiding the error that occured if user
clicked the link after renaming of stream.

As a result of above changes, the checks for empty and invalid stream
name in compose box are done in warn_if_mentioning_unsubscribed_user
function instead of needs_subscribe_warning function.
2020-07-06 15:30:01 -07:00
Mohit Gupta f8d1e0f86a refactor: Rename convert to markdown_convert.
Prior to this commit whenever convert was imported from zerver.lib.markdown
it was aliased as markdown_convert for readability.
This commit rename convert function to markdown_convert so that it can be
directly import it without aliasing and without compromising readability.
2020-07-06 12:39:59 -07:00
Aman Agrawal c947be5411 msg_edit_form: Show checkboxes in separate lines if present. 2020-07-06 12:38:58 -07:00