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: add support for sns sms provider #306

Merged
merged 8 commits into from
Sep 9, 2024
Merged

Conversation

Harish-osmosys
Copy link
Contributor

@Harish-osmosys Harish-osmosys commented Aug 8, 2024

API PR Checklist

Pre-requisites

  • I have gone through the Contributing guidelines for Submitting a Pull Request (PR) and ensured that this is not a duplicate PR.
  • I have performed preliminary testing using the test suite to ensure that any existing features are not impacted and any new features are working as expected.
  • I have updated the required api docs as applicable.
  • I have added/updated test cases to the test suite as applicable

PR Details

PR details have been updated as per the given format (see below)

  • PR title adheres to the format specified in guidelines (e.g., feat: add admin login endpoint)
  • Description has been added
  • Related changes have been added (optional)
  • Screenshots have been added (optional)
  • Query request and response examples have been added (as applicable, in case added or updated)
  • Documentation changes have been listed (as applicable)
  • Test suite output is added (as applicable)
  • Pending actions have been added (optional)
  • Any other additional notes have been added (optional)

Additional Information

  • Appropriate label(s) have been added (ready for review should be added if the PR is ready to be reviewed)
  • Assignee(s) and reviewer(s) have been added (optional)

Description:

This PR add support for sending sms using the sns

Related changes:

  • Install @aws/ses node package
  • Create migration to populate master_provider details
  • Create module and service file for SES provider with all the relevant functions
  • Add documentation with related links for the specified provider aws ses
  • Update postman collection with aws ses request queries

Screenshots:

NA

Query request and response:

curl --location 'localhost:3000/notifications' \
--header 'Content-Type: application/json' \
--header 'x-api-key: OsmoX-test-key' \
--data '{
    "providerId": 12,
    "data": {

        "to": "+919234567890",
        "message": "This is a test notification"
    }
}'

Documentation changes:

NA

Test suite output:

NA

Pending actions:

NA

Additional notes:

NA

Summary by CodeRabbit

  • New Features

    • Introduced support for sending SMS notifications via AWS SNS.
    • Added a new service for handling SMS notifications and integration with the notification system.
    • Comprehensive documentation for AWS SNS SMS messaging integration.
  • Enhancements

    • Enhanced validation for SMS notification data.
    • Improved the API request collection with new entries and testing capabilities for SMS notifications.
    • Expanded notification channel options with the addition of SMS via SNS.
  • Bug Fixes

    • Adjusted various configurations and error handling for the new SMS channel type.

@Harish-osmosys Harish-osmosys self-assigned this Aug 8, 2024
Copy link

coderabbitai bot commented Aug 8, 2024

Walkthrough

The recent updates enhance the notification system by integrating SMS capabilities through AWS SNS. Key changes include the introduction of new API requests, data validation, a dedicated service for SMS functionalities, and comprehensive documentation. These modifications improve the robustness and flexibility of the application, allowing it to effectively handle SMS notifications alongside existing channels, thereby broadening communication options for users.

Changes

File(s) Change Summary
apps/api/OsmoX.postman_collection.json Updated API descriptions for SMS and WhatsApp channels, replaced "Twilio" with "Plivo," added AWS SES and SNS SMS notification entries.
apps/api/docs/channels/sms-sns.md Introduced documentation for AWS SNS SMS integration, detailing configuration and example requests.
apps/api/src/common/constants/notifications.ts Added new channel type SMS_SNS and updated confirmation channels.
apps/api/src/modules/notifications/dtos/providers/smsSns-data.dto.ts Added SmsSnsDataDto for validating SMS notification data.
apps/api/src/modules/providers/sms-sns/sms-sns.service.ts Developed SmsSnsService for sending SMS messages, with methods for configuration and message sending.
apps/api/src/modules/notifications/queues/queue.service.ts Updated QueueService to include handling for SMS notifications via SNS.
apps/api/src/jobs/consumers/notifications/smsSns-notifications.job.consumer.ts Introduced SmsSnsNotificationConsumer for processing SMS notifications from the queue.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant QueueService
    participant SmsSnsNotificationConsumer
    participant SmsSnsService

    User->>QueueService: Send SMS Notification
    QueueService->>SmsSnsNotificationConsumer: Process Notification
    SmsSnsNotificationConsumer->>SmsSnsService: Send SMS Message
    SmsSnsService->>SmsSnsService: Assign SNS Config
    SmsSnsService->>SmsSnsService: Publish SMS
    SmsSnsService-->>SmsSnsNotificationConsumer: Return Result
    SmsSnsNotificationConsumer-->>QueueService: Acknowledge Processing
    QueueService-->>User: Notify User of Status
Loading

Poem

🐇
In fields where the daisies dance and sway,
A new SMS feature hops in to play.
With whispers of SNS, messages fly,
Through channels of laughter, they leap and they cry.
So cheer for the changes, both bright and bold,
A rabbit's delight in the stories retold!
🌼

Tip

We have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord.


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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

@Harish-osmosys Harish-osmosys changed the title Feat/add sns sms provider feat: add support for sns sms provider Aug 8, 2024
Copy link

@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: 2

Outside diff range, codebase verification and nitpick comments (4)
apps/api/docs/channels/sms-sns.md (4)

3-5: Clarify the documentation reference.

Consider adding a direct link to the SNS documentation for easy access.

- Refer to the SNS documentation to dive deeper into the features AWS SNS offers and understand how it all works.
+ Refer to the [AWS SNS documentation](https://docs.aws.amazon.com/sns/latest/dg/welcome.html) to dive deeper into the features AWS SNS offers and understand how it all works.

11-14: Clarify database field descriptions.

The instructions for setting fields in the notify_providers table could be more explicit about what each field represents.

- Create a new entry in table `notify_providers` and set the fields - `name`, `application_id`, `user_id`
+ Create a new entry in the `notify_providers` table and set the following fields:
+ - `name`: The name of the provider (e.g., "AWS SNS")
+ - `application_id`: The ID of the application using this provider
+ - `user_id`: The ID of the user configuring this provider

18-23: Ensure security of AWS credentials.

Highlight the importance of securing AWS credentials and consider recommending environment variables for storing sensitive information.

- | AWS_ACCESS_KEY_ID     | Access key for AWS instance |
- | AWS_SECRET_ACCESS_KEY | Secret access key for AWS   |
- | AWS_REGION            | Region of the AWS instance  |
+ | AWS_ACCESS_KEY_ID     | Access key for AWS instance (store securely) |
+ | AWS_SECRET_ACCESS_KEY | Secret access key for AWS (store securely)   |
+ | AWS_REGION            | Region of the AWS instance  |

+ Note: It is recommended to store AWS credentials in environment variables for enhanced security.

35-45: Correct JSON formatting.

Remove the trailing comma in the JSON example to ensure valid JSON syntax.

-    "providerId": 11,
-    "data": {
-        "phoneNumber": "+1234567890",
-        "message": "This is a test notification",
-    }
+    "providerId": 11,
+    "data": {
+        "phoneNumber": "+1234567890",
+        "message": "This is a test notification"
+    }
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4ee7ba9 and 4841497.

Files selected for processing (12)
  • apps/api/OsmoX.postman_collection.json (3 hunks)
  • apps/api/docs/channels/sms-sns.md (1 hunks)
  • apps/api/src/common/constants/notifications.ts (2 hunks)
  • apps/api/src/common/decorators/is-data-valid.decorator.ts (2 hunks)
  • apps/api/src/database/migrations/1723113193873-migration.ts (1 hunks)
  • apps/api/src/jobs/consumers/notifications/smsSns-notifications.job.consumer.ts (1 hunks)
  • apps/api/src/modules/notifications/dtos/providers/smsSns-data.dto.ts (1 hunks)
  • apps/api/src/modules/notifications/notifications.module.ts (3 hunks)
  • apps/api/src/modules/notifications/queues/queue.service.ts (3 hunks)
  • apps/api/src/modules/providers/sms-sns/sms-sns.module.ts (1 hunks)
  • apps/api/src/modules/providers/sms-sns/sms-sns.service.spec.ts (1 hunks)
  • apps/api/src/modules/providers/sms-sns/sms-sns.service.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • apps/api/src/modules/providers/sms-sns/sms-sns.service.spec.ts
Additional context used
Learnings (1)
apps/api/src/jobs/consumers/notifications/smsSns-notifications.job.consumer.ts (1)
Learnt from: LakshayaT
PR: OsmosysSoftware/osmo-x#263
File: apps/api/src/jobs/consumers/notifications/waTwilio-notifications.job.consumer.ts:0-0
Timestamp: 2024-06-28T05:14:27.772Z
Learning: Error handling for `processWaTwilioNotificationQueue` is implemented in the superclass method, as pointed out by the user LakshayaT.
Additional comments not posted (21)
apps/api/src/modules/notifications/dtos/providers/smsSns-data.dto.ts (1)

1-11: DTO Implementation Looks Good!

The use of class-validator decorators to ensure phoneNumber and message are non-empty strings is appropriate for this DTO.

apps/api/src/modules/providers/sms-sns/sms-sns.module.ts (1)

1-12: Module Setup Looks Good!

The SmsSnsModule correctly imports necessary modules and provides the SmsSnsService along with other services. It also exports SmsSnsService for use in other parts of the application.

apps/api/src/database/migrations/1723113193873-migration.ts (1)

1-20: Migration Script Looks Good!

The migration script correctly adds and removes the SMS SNS provider entry in the notify_master_providers table. The configuration includes validation patterns for AWS credentials, which is a good practice.

Ensure that this migration runs successfully in your development and staging environments before deploying to production.

apps/api/src/modules/providers/sms-sns/sms-sns.service.ts (3)

1-2: Consider security implications of AWS credentials.

Ensure that AWS credentials are securely managed and not hard-coded. Consider using environment variables or a secure vault.


10-11: Service class looks good.

The @Injectable() decorator is appropriately used for the service class.


14-17: Ensure Logger is properly configured.

Verify that the Logger instance is correctly configured and used consistently across the application.

apps/api/src/common/constants/notifications.ts (2)

21-21: Addition of SMS_SNS channel type looks good.

The new channel type SMS_SNS is correctly added to the ChannelType object.


69-69: Update to SkipProviderConfirmationChannels is appropriate.

Including ChannelType.SMS_SNS in SkipProviderConfirmationChannels aligns with the intended functionality.

apps/api/src/jobs/consumers/notifications/smsSns-notifications.job.consumer.ts (2)

11-12: Consumer class looks good.

The @Injectable() decorator is appropriately used for the consumer class.


25-33: Ensure consistent error handling.

Ensure that error handling is consistent with other consumer implementations, particularly in the processSmsSnsNotificationQueue method.

apps/api/src/modules/notifications/notifications.module.ts (3)

59-59: LGTM! Integration of SmsSnsModule is correct.

The SmsSnsModule has been correctly added to the providerModules array.


73-73: LGTM! Integration of SmsSnsNotificationConsumer is correct.

The SmsSnsNotificationConsumer has been correctly added to the consumers array.


41-42: Ensure consistency in import paths.

Verify that the import paths for SmsSnsNotificationConsumer and SmsSnsModule are correct and consistent with the project's structure.

Verification successful

Import paths are consistent and correct.

The import paths for SmsSnsNotificationConsumer and SmsSnsModule are correctly aligned with the project's structure. No changes are needed.

  • SmsSnsNotificationConsumer is located at apps/api/src/jobs/consumers/notifications/smsSns-notifications.job.consumer.ts.
  • SmsSnsModule is located at apps/api/src/modules/providers/sms-sns/sms-sns.module.ts.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the imported modules to ensure correct paths.

# Test: Check for the existence of the SmsSnsNotificationConsumer and SmsSnsModule files.
fd 'smsSns-notifications.job.consumer.ts' src/jobs/consumers/notifications
fd 'sms-sns.module.ts' src/modules/providers/sms-sns

Length of output: 364


Script:

#!/bin/bash
# Search for the correct file paths of SmsSnsNotificationConsumer and SmsSnsModule in the repository.

# Find the SmsSnsNotificationConsumer file
fd 'smsSns-notifications.job.consumer.ts'

# Find the SmsSnsModule file
fd 'sms-sns.module.ts'

Length of output: 200

apps/api/src/common/decorators/is-data-valid.decorator.ts (1)

131-136: LGTM! Validation logic for ChannelType.SMS_SNS is correctly implemented.

The validation logic for ChannelType.SMS_SNS is consistent with other channel types and correctly uses SmsSnsDataDto.

apps/api/src/modules/notifications/queues/queue.service.ts (3)

10-10: Import statement is correct.

The import for SmsSnsNotificationConsumer is correctly added and follows the existing pattern.


40-40: Constructor parameter addition is correct.

The smsSnsNotificationConsumer parameter is added consistently with the existing pattern for other consumers.


173-176: Switch case addition is correct.

The new case for SMS_SNS correctly integrates the smsSnsNotificationConsumer into the notification processing workflow.

apps/api/OsmoX.postman_collection.json (4)

3-7: Update of _postman_id and _exporter_id is appropriate.

These changes ensure the uniqueness and traceability of the Postman collection.


4210-4214: Addition of global variable x-api-key is beneficial.

This change enhances the flexibility and maintainability of the collection.


2603-2841: SNS SMS Notification requests are well-structured.

The requests include comprehensive test scripts for validating responses and handling error scenarios.

Ensure that the test scripts accurately reflect the expected API behavior.

Verification successful

Test script for "Send SNS SMS Notification - Success" is correctly implemented.

The test script effectively validates JSON structure and key properties, ensuring robust checks for successful notification creation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of test scripts for SNS SMS Notification requests.

# Test: Search for SNS SMS Notification test scripts. Expect: Correct validation logic.
rg --type json -A 5 $'"name": "Send SNS SMS Notification - Success"'

Length of output: 441


Script:

#!/bin/bash
# Extract the complete "exec" array for the "Send SNS SMS Notification - Success" test script
rg --type json -A 50 $'"name": "Send SNS SMS Notification - Success"' apps/api/OsmoX.postman_collection.json

Length of output: 2272


2363-2602: AWS SES Notification requests are well-structured.

The requests include comprehensive test scripts for validating responses and handling error scenarios.

Ensure that the test scripts accurately reflect the expected API behavior.

Verification successful

Test scripts for AWS SES Notification are correctly implemented.

The test scripts for the "Send AWS SES Notification - Success" request validate the response structure and properties accurately, ensuring the API behaves as expected.

  • The scripts check for JSON validity, correct status, and the presence of necessary fields like 'notification', 'channelType', and 'deliveryStatus'.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of test scripts for AWS SES Notification requests.

# Test: Search for AWS SES Notification test scripts. Expect: Correct validation logic.
rg --type json -A 5 $'"name": "Send AWS SES Notification - Success"'

Length of output: 441


Script:

#!/bin/bash
# Extract the complete test script for "Send AWS SES Notification - Success" to verify validation logic.
rg --type json -A 20 '"name": "Send AWS SES Notification - Success"' apps/api/OsmoX.postman_collection.json

Length of output: 1149

apps/api/src/modules/providers/sms-sns/sms-sns.service.ts Outdated Show resolved Hide resolved
apps/api/src/modules/providers/sms-sns/sms-sns.service.ts Outdated Show resolved Hide resolved
Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4841497 and 3e240fe.

Files selected for processing (1)
  • apps/api/src/modules/providers/sms-sns/sms-sns.service.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/api/src/modules/providers/sms-sns/sms-sns.service.ts

apps/api/docs/channels/sms-sns.md Show resolved Hide resolved
apps/api/src/common/constants/notifications.ts Outdated Show resolved Hide resolved
Copy link

@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 (1)
apps/api/docs/channels/sms-sns.md (1)

1-59: Excellent documentation for AWS SNS integration! Just a couple of suggestions to further enhance it.

The documentation provides a clear and comprehensive guide for integrating AWS SNS to send SMS notifications. The inclusion of configuration details, a sample request body, and relevant links is highly beneficial.

Here are a couple of suggestions for minor improvements:

  1. Consider formatting the table in the "Values to Update in Database" section to improve readability. For example, you can use the following format:

    Key Description
    AWS_ACCESS_KEY_ID Access key for AWS instance
    AWS_SECRET_ACCESS_KEY Secret access key for AWS
    AWS_REGION Region of the AWS instance
  2. In the "Dependencies" section, consider adding a brief explanation of why the @aws-sdk/client-sns package is required. For example:

    The @aws-sdk/client-sns package is required to interact with AWS SNS using the AWS SDK for JavaScript. It provides the necessary methods to send SMS messages via SNS.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3e240fe and 35aa37a.

Files selected for processing (5)
  • apps/api/OsmoX.postman_collection.json (36 hunks)
  • apps/api/docs/channels/sms-sns.md (1 hunks)
  • apps/api/src/common/constants/notifications.ts (2 hunks)
  • apps/api/src/modules/notifications/dtos/providers/smsSns-data.dto.ts (1 hunks)
  • apps/api/src/modules/providers/sms-sns/sms-sns.service.ts (1 hunks)
Additional comments not posted (27)
apps/api/src/modules/notifications/dtos/providers/smsSns-data.dto.ts (1)

1-11: LGTM!

The SmsSnsDataDto class is well-defined and follows best practices:

  • The class name follows the naming convention and includes the provider name for clarity.
  • The to and message properties are appropriately named and typed.
  • The validation decorators ensure that the to property is not empty and has a maximum length of 16 characters, which is a reasonable limit for phone numbers.
  • The validation decorators ensure that the message property is a non-empty string.

The code changes are approved.

apps/api/src/common/constants/notifications.ts (2)

21-21: LGTM!

The code changes are approved.


69-69: LGTM!

The code changes are approved.

apps/api/src/modules/providers/sms-sns/sms-sns.service.ts (5)

1-8: LGTM!

The imports and interface declaration are appropriate.


10-17: LGTM!

The SmsSnsService class and its constructor are properly implemented.


19-35: LGTM!

The assignSnsConfig method is implemented correctly and follows best practices for error handling.


37-53: LGTM!

The sendMessage method is implemented correctly and follows best practices for error handling.


1-54: Overall, the SmsSnsService class is well-implemented and follows best practices.

The file contains all the necessary elements, and the code is properly structured with appropriate error handling.

apps/api/OsmoX.postman_collection.json (19)

3-3: Skipping comment.

The change to _postman_id is non-impactful and can be skipped for review.


7-7: Skipping comment.

The change to _exporter_id is non-impactful and can be skipped for review.


1277-1277: LGTM!

The updated description correctly reflects the Plivo SMS notification request.


1338-1338: LGTM!

The updated description correctly reflects the Plivo SMS notification request.


1393-1393: LGTM!

The updated description correctly reflects the Plivo SMS notification request.


1447-1447: LGTM!

The updated description correctly reflects the Plivo SMS notification request.


1519-1519: LGTM!

The updated description correctly specifies the Twilio WhatsApp Business API.


1580-1580: LGTM!

The updated description correctly specifies the Twilio WhatsApp Business API.


1633-1633: LGTM!

The updated description correctly specifies the Twilio WhatsApp Business API.


1687-1687: LGTM!

The updated description correctly specifies the Twilio WhatsApp Business API.


1759-1759: LGTM!

The updated description correctly reflects the KAPS SMS notification request.


1820-1820: LGTM!

The updated description correctly reflects the KAPS SMS notification request.


1873-1873: LGTM!

The updated description correctly reflects the KAPS SMS notification request.


1927-1927: LGTM!

The updated description correctly reflects the KAPS SMS notification request.


1998-1999: LGTM!

The updated description correctly reflects the AWS SES push notification request for Android.


2064-2065: LGTM!

The updated description correctly reflects the AWS SES push notification request for iOS.


2137-2137: LGTM!

The updated description correctly reflects the Twilio Voice Call notification request.


2198-2198: LGTM!

The updated description correctly reflects the Twilio Voice Call notification request.


2251-2251: LGTM!

The updated description correctly reflects the Twilio Voice Call notification request.

Copy link

@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 35aa37a and 92080f8.

Files selected for processing (2)
  • apps/api/src/common/constants/notifications.ts (2 hunks)
  • apps/api/src/modules/notifications/queues/queue.service.ts (3 hunks)
Additional context used
Learnings (1)
apps/api/src/modules/notifications/queues/queue.service.ts (1)
Learnt from: LakshayaT
PR: OsmosysSoftware/osmo-x#262
File: apps/api/src/modules/notifications/queues/queue.service.ts:87-87
Timestamp: 2024-07-03T08:38:36.915Z
Learning: The `processNotificationQueue` method in the `NotificationConsumer` class includes error handling, which covers the `processMailgunNotificationQueue` method in the `MailgunNotificationConsumer` class.
Biome
apps/api/src/modules/notifications/queues/queue.service.ts

[error] 176-177: This case is falling through to the next case.

Add a break or return statement to the end of this case to prevent fallthrough.

(lint/suspicious/noFallthroughSwitchClause)

Additional comments not posted (4)
apps/api/src/common/constants/notifications.ts (2)

21-21: LGTM!

The code changes are approved.


70-70: LGTM!

The code changes are approved.

apps/api/src/modules/notifications/queues/queue.service.ts (2)

10-10: LGTM!

The import statement is approved.


41-41: LGTM!

The new private member is approved.

Harish-osmosys and others added 2 commits September 3, 2024 23:25
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link

@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 (1)
apps/api/src/jobs/consumers/notifications/smsSns-notifications.job.consumer.ts (1)

34-42: Consider declaring notificationSendResponse as const.

Based on the learning from PR #262, consider declaring the notificationSendResponse variable as const instead of let in the processSmsSnsNotificationQueue method, as it is never reassigned.

async processSmsSnsNotificationQueue(id: number): Promise<void> {
  return super.processNotificationQueue(id, async () => {
    const notification = (await this.notificationsService.getNotificationById(id))[0];
-   let notificationSendResponse = await this.smsSnsService.sendMessage(
+   const notificationSendResponse = await this.smsSnsService.sendMessage(
      notification.data as unknown as SmsSnsData,
      notification.providerId,
    );
    return notificationSendResponse;
  });
}
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 92080f8 and 8508955.

Files selected for processing (2)
  • apps/api/src/jobs/consumers/notifications/smsSns-notifications.job.consumer.ts (1 hunks)
  • apps/api/src/modules/notifications/queues/queue.service.ts (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/api/src/modules/notifications/queues/queue.service.ts
Additional context used
Learnings (1)
apps/api/src/jobs/consumers/notifications/smsSns-notifications.job.consumer.ts (2)
Learnt from: LakshayaT
PR: OsmosysSoftware/osmo-x#263
File: apps/api/src/jobs/consumers/notifications/waTwilio-notifications.job.consumer.ts:0-0
Timestamp: 2024-06-28T05:14:27.772Z
Learning: Error handling for `processWaTwilioNotificationQueue` is implemented in the superclass method, as pointed out by the user LakshayaT.
Learnt from: ayushnvs
PR: OsmosysSoftware/osmo-x#262
File: apps/api/src/jobs/consumers/notifications/mailgun-notifications.job.consumer.ts:0-0
Timestamp: 2024-07-03T13:27:46.550Z
Learning: The `notificationSendResponse` variable in the `processMailgunNotificationConfirmationQueue` method of the `MailgunNotificationConsumer` class was changed from `let` to `const` to reflect that it is never reassigned.
Additional comments not posted (1)
apps/api/src/jobs/consumers/notifications/smsSns-notifications.job.consumer.ts (1)

1-43: LGTM!

The code changes are approved. The SmsSnsNotificationConsumer class follows the same pattern as other notification consumers and the processSmsSnsNotificationQueue method is implemented correctly.

@xixas xixas merged commit feaca76 into main Sep 9, 2024
6 checks passed
@xixas xixas deleted the feat/add-sns-sms-provider branch September 9, 2024 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants