Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

US1: Remove limitation on the number of messages allowed to be send in a minute #20

Merged
merged 10 commits into from
Oct 10, 2024

Conversation

ThomasJXiao
Copy link

@ThomasJXiao ThomasJXiao commented Sep 24, 2024

Update:
Removed 2 test functions that tests message flooding prevention, We removed these tests because as this user story is trying to disable the message rate limit in chats.

The tests are in the test/messaging.js file. Here are the following test.

image image

Description:
Removed the limit on the number of messages that are allowed to be sent within a minute.
Removed the error message after a user tried to send multiple messages within a minute. 

Fixes #9
Fixes #10

What Has Been Changed:
Now if someone is logged into their Nodebb account and has chosen someone to chat with, when they send multiple messages in any chat within a minute, then all messages should be delivered without any delay or constraints.
Now if someone is part of a chat with multiple members, when they send multiple messages in rapid succession, then each message should appear in the correct order on the recipients' screens.
Now if someone sends multiple messages within a minute, when the messages contain different content (text, links, emojis, or attachments), then all message types should be sent successfully without constraints.
Now if someone sends multiple messages rapidly, when the messages are sent within a one-minute window, then there should be no error message or warning indicating a rate limit has been reached.
Code Changes :

• Modified Config.json, src/api/chats.js, src/middleware/ratelimit.js
Modified rateLimitExceeded function in chat.js
image

  • Modified isFlooding function in ratelimit.js
image

Testing:

Tested & Verified that the user are allowed to send multiple message within a minutes into a direct messages chat and group chats
Tested & Verified that the error message for limiting the amount of message sent is not visible after multiple message are sent within a minute

Copy link

@tanoctavius tanoctavius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good and make sense! However, the lint tests need to be passed before it can be merged.

Copy link

@gpxxlt gpxxlt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deletion is quite self-explanatory, and will be better if there are some comments.

Copy link

@Akshra-school Akshra-school left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code changes look good but make sure the lint tests pass before merging!

@ThomasJXiao
Copy link
Author

ThomasJXiao commented Sep 25, 2024

US1: Remove limitation on the number of messages allowed to be send in a minute

Description:
Removed the limit on the number of messages that are allowed to be sent within a minute.
Removed the error message after a user tried to send multiple messages within a minute. 

Fixes #9
Fixes #10
What Has Been Changed:

  • Now if someone is logged into their Nodebb account and has chosen someone to chat with, when they send multiple messages in any chat within a minute, then all messages should be delivered without any delay or constraints.
  • Now if someone is part of a chat with multiple members, when they send multiple messages in rapid succession, then each message should appear in the correct order on the recipients' screens.
  • Now if someone sends multiple messages within a minute, when the messages contain different content (text, links, emojis, or attachments), then all message types should be sent successfully without constraints.
  • Now if someone sends multiple messages rapidly, when the messages are sent within a one-minute window, then there should be no error message or warning indicating a rate limit has been reached.
    Code Changes :
    • Modified Config.json, src/api/chats.js, src/middleware/ratelimit.js
    • Modified rateLimitExceeded function in chat.js
Pasted Graphic
* Modified isFlooding function in ratelimit.js
ratelimit isFlooding = function (socket) €

Testing:

  • Tested & Verified that the user are allowed to send multiple message within a minutes into a direct messages chat and group chats
  • Tested & Verified that the error message for limiting the amount of message sent is not visible after multiple message are sent within a minute
  • All UX testing is now working

Comments on not passing the lint test:

  • The test that is not passing on this PR is the following test:
    rooms
    should return rate limit error on second try:

    AssertionError [ERR_ASSERTION]: 200 == 400

    • expected - actual

    -200
    +400

    at Context. (test/messaging.js:165:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

We are not going to try to fix this lint test error, as this user story is trying to disable the message rate limit in chats. It would be counterintuitive for us to pass this lint test.

@gpxxlt gpxxlt self-requested a review September 25, 2024 03:34
Copy link

@tanoctavius tanoctavius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lint tests works so its all good!

@ThomasJXiao
Copy link
Author

The code changes look good but make sure the lint tests pass before merging!

Fixed. Check the newest code for reference.

@ThomasJXiao ThomasJXiao reopened this Oct 10, 2024
@coveralls
Copy link

coveralls commented Oct 10, 2024

Pull Request Test Coverage Report for Build 11283411447

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 63 unchanged lines in 12 files lost coverage.
  • Overall coverage remained the same at 82.666%

Files with Coverage Reduction New Missed Lines %
src/controllers/write/topics.js 1 96.09%
src/middleware/ratelimit.js 1 86.36%
src/privileges/topics.js 2 93.33%
src/topics/index.js 2 93.83%
src/database/redis/hash.js 3 94.58%
src/api/chats.js 3 74.06%
src/posts/tools.js 4 77.78%
src/topics/events.js 5 92.5%
src/api/helpers.js 6 83.33%
src/api/topics.js 8 86.88%
Totals Coverage Status
Change from base Build 11022158816: 0.0%
Covered Lines: 22344
Relevant Lines: 25606

💛 - Coveralls

Copy link

@Akshra-school Akshra-school left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you fixed your tests and removed code that was nonessential. Great work!

Copy link

@gpxxlt gpxxlt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impressive work to get all tests passed!

@tanoctavius tanoctavius merged commit 4663ea7 into f24 Oct 10, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants