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

feat: manage participant #169

Merged
merged 3 commits into from
Jul 13, 2024
Merged

feat: manage participant #169

merged 3 commits into from
Jul 13, 2024

Conversation

aldinokemal
Copy link
Owner

Context

Manage Participant

  • Add participant to group
  • Remove participant from group
  • Promote to admin
  • Demote from admin

Copy link
Contributor

coderabbitai bot commented Jul 13, 2024

Warning

Rate limit exceeded

@aldinokemal has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 51 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 600170f and 4abe566.

Walkthrough

In this update, several changes were made to managing participants in groups, including modifying methods for removing, promoting, and demoting participants. Additionally, a new feature for starring messages was introduced. The version of the application was incremented, and various files were updated to accommodate these changes, ensuring proper integration and functionality.

Changes

File Path Change Summary
readme.md Updated summary and alterations to exported or public entities.
src/config/settings.go Updated AppVersion from "v4.14.2" to "v4.15.0".
src/domains/group/group.go Renamed AddParticipant to ManageParticipant and added Action field to ParticipantRequest.
src/internal/rest/group.go Introduced new functions for deleting, promoting, and demoting participants.
src/pkg/whatsapp/whatsapp.go Revised logic for determining file extension in ExtractMedia function.
src/services/group.go Renamed AddParticipant function to ManageParticipant and updated success message.
src/views/components/... Modified GroupManageParticipants component to handle multiple participant actions.
docs/openapi.yaml Added new endpoints and updated schema definitions for managing group participants.
src/views/index.html Updated import statement to GroupManageParticipants.js.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GroupComponent
    participant GroupController
    participant GroupService
    participant WhatsAppAPI
    
    User->>GroupComponent: Select Action (add, remove, promote, demote)
    GroupComponent->>GroupController: Submit Action Request
    GroupController->>GroupService: ManageParticipant(Request)
    GroupService->>WhatsAppAPI: Execute ParticipantChange
    WhatsAppAPI-->>GroupService: Return Status
    GroupService-->>GroupController: Return Status
    GroupController-->>GroupComponent: Return Status
    GroupComponent-->>User: Display Result
Loading

Poem

In groups where members play and chat,
Actions change at the drop of a hat.
Add, promote, demote, or remove,
New features make the system groove.
Messages starred with a gentle touch,
Version bump shows how we care so much.
A rabbit's joy in code's embrace,
Bringing changes with a smiley face. 🐇🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (3)
src/services/group.go (1)

Line range hint 92-108:
Consider adding more specific error messages.

The error messages in the loop could be more specific to the action being performed (e.g., "Failed to promote participant").

-  Message:     "Failed to add participant",
+  Message:     fmt.Sprintf("Failed to %s participant", request.Action),
src/views/index.html (1)

147-147: Update the usage of the renamed import.

The import statement for GroupManageParticipants.js is correct, but the variable name GroupAddParticipants is still used in the codebase. Please update the usage to GroupManageParticipants for consistency.

  • Update the usage of GroupAddParticipants to GroupManageParticipants in src/views/index.html.
Analysis chain

Verify the correctness of the new import path.

Ensure that the new import path ./components/GroupManageParticipants.js is correct and consistent with other parts of the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the new import path.

# Test: Check if the file `GroupManageParticipants.js` exists in the `components` directory.
fd 'GroupManageParticipants.js' --search-path ./src/views/components

Length of output: 118


Script:

#!/bin/bash
# Description: Verify the usage of the renamed import throughout the codebase.

# Search for occurrences of the old import name `GroupAddParticipants`.
rg 'GroupAddParticipants' -A 3

# Search for occurrences of the new import name `GroupManageParticipants`.
rg 'GroupManageParticipants' -A 3

Length of output: 1050

readme.md (1)

124-124: The Star message API endpoint is not defined in the codebase.

The searches did not return any relevant results for the Star message endpoint, suggesting that it is either not implemented or incorrectly documented in the readme.md file.

  • Please verify the implementation or correct the documentation for the Star message API endpoint.
Analysis chain

Verify the correctness of the new API endpoint.

Ensure that the description and method for the Star message API endpoint are correct.


Let's broaden our search to ensure we capture any relevant definitions or comments related to the Star message endpoint.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and correctness of the new API endpoint.

# Test: Check if the `Star message` API endpoint is correctly defined in the codebase.
rg --type go 'POST.*message.*star'

Length of output: 36


Script:

#!/bin/bash
# Description: Broaden the search to verify the existence and correctness of the new API endpoint.

# Test: Search for the term `star` within the Go codebase to capture any relevant definitions or comments.
rg --type go 'star'

Length of output: 322

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5050c56 and 558983f.

Files selected for processing (8)
  • readme.md (1 hunks)
  • src/config/settings.go (1 hunks)
  • src/domains/group/group.go (2 hunks)
  • src/internal/rest/group.go (4 hunks)
  • src/pkg/whatsapp/whatsapp.go (1 hunks)
  • src/services/group.go (3 hunks)
  • src/views/components/GroupManageParticipants.js (4 hunks)
  • src/views/index.html (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/config/settings.go
Additional comments not posted (18)
src/domains/group/group.go (2)

12-12: LGTM! The method name ManageParticipant is more descriptive.

The method name change aligns with the new functionality and improves code readability.


29-31: LGTM! The addition of the Action field is appropriate.

The new Action field allows for handling different participant actions and is correctly typed.

src/services/group.go (1)

Line range hint 76-108:
LGTM! The ManageParticipant method is well-structured.

The method includes appropriate validation, error handling, and participant management logic.

src/internal/rest/group.go (4)

101-119: LGTM! The DeleteParticipants endpoint is correctly implemented.

The endpoint uses the DELETE method and sets the Action field appropriately.


121-139: LGTM! The PromoteParticipants endpoint is correctly implemented.

The endpoint uses the PATCH method and sets the Action field appropriately.


141-159: LGTM! The DemoteParticipants endpoint is correctly implemented.

The endpoint uses the PATCH method and sets the Action field appropriately.


88-90: LGTM! The AddParticipants endpoint is correctly implemented.

The endpoint sets the Action field appropriately.

src/views/components/GroupManageParticipants.js (9)

2-2: LGTM! The component name is appropriately updated.

The new name ManageGroupParticipants reflects the updated functionality.


7-7: LGTM! The action field is correctly added to the data object.

The action field allows the component to handle different participant actions.


13-14: LGTM! The group_id computed property is correctly implemented.

The computed property generates the correct group ID format.


25-28: LGTM! The methods for adding and deleting participants are correctly implemented.

The methods handle adding and deleting participants in the data object.


32-36: LGTM! The handleSubmit method is correctly implemented.

The method handles form submission and displays success or error messages.


42-62: LGTM! The submitApi method is correctly implemented.

The method handles different participant actions based on the action field.


77-77: LGTM! The handleReset method is correctly implemented.

The method resets the form fields to their default values.


85-87: LGTM! The template is correctly updated to reflect the new functionality.

The template includes the updated header, description, and action dropdown.


Line range hint 96-136:
LGTM! The modal template is correctly updated.

The modal includes the form fields for group ID, participants, and action.

readme.md (1)

129-131: Verify the correctness of the updated API endpoints.

Ensure that the descriptions and methods for the API endpoints for removing, promoting, and demoting participants in a group are correct.

src/pkg/whatsapp/whatsapp.go (1)

461-468: Verify the correctness of the changes to the ExtractMedia function.

Ensure that the error handling for cases where the extension is not found or directly extracted from the MIME type is correct and that the function works as expected.

Verification successful

Verify the correctness of the changes to the ExtractMedia function.

Ensure that the error handling for cases where the extension is not found or directly extracted from the MIME type is correct and that the function works as expected.


The error handling and logic for extracting the file extension in the ExtractMedia function are correct.

The function first attempts to get the extension using mime.ExtensionsByType and falls back to deriving it from the MIME type string if necessary. This ensures robust handling of different MIME types.

  • The implementation correctly handles cases where the extension is not found or directly extracted from the MIME type.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the changes to the `ExtractMedia` function.

# Test: Check if the `ExtractMedia` function is correctly defined and used in the codebase.
rg --type go 'func ExtractMedia'
rg --type go 'ExtractMedia'

Length of output: 997


Script:

#!/bin/bash
# Description: Inspect the implementation of the `ExtractMedia` function to verify changes.

# Extract the full implementation of the `ExtractMedia` function for review.
ast-grep --lang go --pattern 'func ExtractMedia($_, $_) ($_ $_, $_ error) {
  $$$
}' src/pkg/whatsapp/whatsapp.go

Length of output: 2867

coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 13, 2024
…ts to use POST instead of DELETE and PATCH for better compatibility and consistency
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 558983f and 600170f.

Files selected for processing (3)
  • docs/openapi.yaml (3 hunks)
  • src/internal/rest/group.go (4 hunks)
  • src/views/components/GroupManageParticipants.js (4 hunks)
Files skipped from review as they are similar to previous changes (2)
  • src/internal/rest/group.go
  • src/views/components/GroupManageParticipants.js
Additional context used
yamllint
docs/openapi.yaml

[warning] 1046-1046: wrong indentation: expected 12 but found 14

(indentation)


[warning] 1048-1048: wrong indentation: expected 12 but found 14

(indentation)

Additional comments not posted (5)
docs/openapi.yaml (5)

4-4: Version update approved.

The version update to 4.1.0 is consistent with the changes introduced in the PR.


841-860: New endpoint for adding participants looks good.

The endpoint for adding participants is correctly defined with appropriate request and response schemas.


861-890: New endpoint for removing participants looks good.

The endpoint for removing participants is correctly defined with appropriate request and response schemas.


891-920: New endpoint for promoting participants looks good.

The endpoint for promoting participants is correctly defined with appropriate request and response schemas.


Line range hint 921-950: New endpoint for demoting participants looks good.

The endpoint for demoting participants is correctly defined with appropriate request and response schemas.

docs/openapi.yaml Outdated Show resolved Hide resolved
@aldinokemal aldinokemal merged commit d62ef31 into main Jul 13, 2024
9 checks passed
@aldinokemal aldinokemal deleted the feat/manage-participant branch July 13, 2024 15:19
@coderabbitai coderabbitai bot mentioned this pull request Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant