talawa-api icon indicating copy to clipboard operation
talawa-api copied to clipboard

[Feature Request] Posts and Events features and Spam mitigation for Talawa-admin issue fixed

Open asmitsirohi opened this issue 2 years ago • 9 comments

What kind of change does this PR introduce?

feature

Issue Number:

Fixes #740

Did you add tests for your changes?

Yes

Snapshots/Videos:

  • Filter events Screenshot 2022-08-09 at 06-03-08 Playground - http __localhost 4000_graphql

  • Filter posts Screenshot 2022-08-09 at 06-04-39 Playground - http __localhost 4000_graphql

  • Update post Screenshot 2022-08-09 at 06-09-09 Playground - http __localhost 4000_graphql

  • Spamming an organization group chat Screenshot 2022-08-09 at 06-15-46 Playground - http __localhost 4000_graphql

  • Spammed user stores in organization Screenshot 2022-08-09 at 06-17-59 Playground - http __localhost 4000_graphql

  • User document holding the data in which user has spammed Screenshot 2022-08-09 at 06-20-43 Playground - http __localhost 4000_graphql

If relevant, did you update the documentation?

No

Summary

This Pull request is the changes in the backend regarding PalisadoesFoundation/talawa-admin#358

In this, the following things are implemented,

  • A mutation is added to update the already existing post.
  • A new function is implemented in the postsByOrganization resolver to filter the posts.
  • A new function is implemented in the eventsByOrganization resolver to filter the events.
  • A new field is added in the organization schema named ‘spamCount’ to store the details of users who spammed in the organization.
  • A new field is added in the user schema named ‘spamInOrganizations’ to store the details of the organization in which the user has spammed.
  • A new helper function is created named ‘checkSpamMessages’ to check whether the message is spam or not.
  • To check whether the message is spam or not following tasks is done:
    • Check whether the message contains the keywords of spam or not.
    • Check the frequency of the last 30 messages. If the message frequency is less than 5 seconds then it is spam.
  • A helper function is checking about the spam just before storing the messages in the database i.e. in the ‘sendMessageToGroupChat’ resolver.
  • A new mutation is added named ‘updateSpamNotifcation’, to update the readed notifications in talawa-admin.

Does this PR introduce a breaking change?

No

Other information

This pull request is under GSoC'22.

Have you read the contributing guide?

Yes

asmitsirohi avatar Aug 09 '22 04:08 asmitsirohi

Codecov Report

Merging #742 (74de117) into develop_legacy (cecf46f) will increase coverage by 2.52%. The diff coverage is 95.18%.

@@                Coverage Diff                 @@
##           develop_legacy     #742      +/-   ##
==================================================
+ Coverage           66.12%   68.65%   +2.52%     
==================================================
  Files                 190      195       +5     
  Lines                3398     3563     +165     
  Branches              724      774      +50     
==================================================
+ Hits                 2247     2446     +199     
+ Misses                907      890      -17     
+ Partials              244      227      -17     
Impacted Files Coverage Δ
lib/models/Organization.js 100.00% <ø> (ø)
lib/models/User.js 100.00% <ø> (ø)
lib/resolvers/user_query/users.js 23.40% <ø> (ø)
lib/helper_functions/checkSpamMessage.js 83.33% <83.33%> (ø)
lib/resolvers/post_mutations/updatePost.js 93.33% <93.33%> (ø)
...s/organization_mutations/updateSpamNotification.js 95.45% <95.45%> (ø)
lib/resolvers/Mutation.js 100.00% <100.00%> (ø)
lib/resolvers/event_query/event_filter.js 100.00% <100.00%> (ø)
lib/resolvers/event_query/eventsByOrganization.js 100.00% <100.00%> (ø)
...ers/group_chat_mutations/sendMessageToGroupChat.js 92.85% <100.00%> (+0.54%) :arrow_up:
... and 5 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov-commenter avatar Aug 09 '22 04:08 codecov-commenter

@yasharth291 please review

asmitsirohi avatar Aug 09 '22 04:08 asmitsirohi

This pull request did not get any activity in the past 60 days and will be closed in 365 days if no update occurs. Please verify it has no conflicts with the develop branch and rebase if needed. Mention it now if you need help or give permission to other people to finish your work.

github-actions[bot] avatar Oct 09 '22 00:10 github-actions[bot]

@yasharth291 Please review.

palisadoes avatar Oct 09 '22 17:10 palisadoes

@yasharth291 Please review

palisadoes avatar Oct 23 '22 18:10 palisadoes

@yasharth291 Please review so we can merge.

palisadoes avatar Dec 03 '22 19:12 palisadoes

@asmitsirohi remove the conflicts

yasharth291 avatar Dec 04 '22 06:12 yasharth291

@asmitsirohi Please fix the failing tests

palisadoes avatar Dec 05 '22 03:12 palisadoes

The code coverage has also declined with this PR. Please also add the corresponding tests needed to restore the coverage to the previous value or better.

palisadoes avatar Dec 05 '22 03:12 palisadoes

@palisadoes @yasharth291, please see this now, I have resolved all the conflicts.

asmitsirohi avatar Dec 27 '22 09:12 asmitsirohi