-
Notifications
You must be signed in to change notification settings - Fork 6
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: move logic for calling webhook to separate queue #311
Conversation
Update notification.ts to add a WEBHOOK QueueAction Update QueueService to add switch case for webhook related queues for providers, calling triggerWebhook Update WebhookService and WebhookModule to to use NotificationsService for getting notification details from DB by ID, had some issues with circular dependencies, resolved them using forwardRef Update NotificationConsumer to save notification and add notification to webhook queue for processing, wherever earlier webhook was being triggered directly Update all provider consumers to import and pass in super method the NotificationQueueProducer
WalkthroughThe changes introduce a new Changes
Sequence Diagram(s)sequenceDiagram
participant Producer as NotificationQueueProducer
participant Consumer as NotificationConsumer
participant Service as NotificationsService
participant Webhook as WebhookService
Consumer->>Producer: addNotificationToQueue(action, notification)
Producer->>Service: save notification to repository
Producer->>Webhook: triggerWebhook(id)
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this 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 (4)
apps/api/src/jobs/consumers/notifications/wa360dialog-notifications.job.consumer.ts (1)
Unused Dependency:
notificationsQueueService
inWa360dialogNotificationsConsumer
The
notificationsQueueService
is injected into theWa360dialogNotificationsConsumer
class but is not currently utilized within this class or its superclassNotificationConsumer
. This could be an oversight or preparation for future functionality.
- Consider reviewing the necessity of this dependency or ensuring its intended use is implemented.
Analysis chain
Line range hint
13-24
: Dependency Injection: Verify the new dependency integration.The
NotificationQueueProducer
is now injected into theWa360dialogNotificationsConsumer
class. Ensure that this new dependency is correctly utilized within the class.Run the following script to verify the usage of
notificationsQueueService
within this class:Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify usage of `notificationsQueueService` in `Wa360dialogNotificationsConsumer`. # Test: Search for `notificationsQueueService` usage. Expect: At least one usage. rg --type ts 'notificationsQueueService' -A 5Length of output: 12572
Script:
#!/bin/bash # Description: Search for methods in `Wa360dialogNotificationsConsumer` that use `notificationsQueueService`. # Test: Search for `notificationsQueueService` usage within methods of `Wa360dialogNotificationsConsumer`. ast-grep --lang typescript --pattern $'class Wa360dialogNotificationsConsumer extends $_ { $$$ $_() { $$$ this.notificationsQueueService.$_($$); $$$ } $$$ }'Length of output: 178
Script:
#!/bin/bash # Description: Search for usage of `notificationsQueueService` in `NotificationConsumer`. # Test: Search for `notificationsQueueService` usage within methods of `NotificationConsumer`. ast-grep --lang typescript --pattern $'class NotificationConsumer { $$$ $_() { $$$ this.notificationsQueueService.$_($$); $$$ } $$$ }'Length of output: 155
apps/api/src/modules/webhook/webhook.service.ts (1)
38-41
: Missing Method:getNotificationById
not found inNotificationsService
.The
getNotificationById
method expected to be in theNotificationsService
class does not exist in the codebase. This indicates a potential issue with thetriggerWebhook
method inwebhook.service.ts
, as it references a non-existent method.
- Check the implementation of
triggerWebhook
inapps/api/src/modules/webhook/webhook.service.ts
.- Verify the intended source and implementation of
getNotificationById
.Analysis chain
Method Update: Verify notification retrieval by ID.
The
triggerWebhook
method now retrieves the notification using its ID. Ensure that thegetNotificationById
method returns the correct data.Run the following script to verify the
getNotificationById
method's implementation and usage:Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify `getNotificationById` method in `NotificationsService`. # Test: Search for `getNotificationById` method implementation. Expect: Correct retrieval logic. ast-grep --lang typescript --pattern $'class NotificationsService { $$$ getNotificationById($_) { $$$ } $$$ }'Length of output: 123
Script:
#!/bin/bash # Search for the NotificationsService class in the codebase ast-grep --lang typescript --pattern $'class NotificationsService { $$$ }'Length of output: 2530
Script:
#!/bin/bash # Search for any method named getNotificationById in the codebase ast-grep --lang typescript --pattern $'function getNotificationById($_) { $$$ }'Length of output: 81
apps/api/src/jobs/consumers/notifications/waTwilio-notifications.job.consumer.ts (1)
Dependency Injection Verification:
notificationsQueueService
UsageThe
notificationsQueueService
is injected into theWaTwilioNotificationsConsumer
class but is only passed to the superclass constructor and not directly utilized within the class itself. Ensure that this service is intended to be used this way or consider adding logic to utilize it within the class if necessary.
- File:
apps/api/src/jobs/consumers/notifications/waTwilio-notifications.job.consumer.ts
Analysis chain
Line range hint
15-26
: Dependency Injection: Verify the new dependency integration.The
NotificationQueueProducer
is now injected into theWaTwilioNotificationsConsumer
class. Ensure that this new dependency is correctly utilized within the class.Run the following script to verify the usage of
notificationsQueueService
within this class:Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify usage of `notificationsQueueService` in `WaTwilioNotificationsConsumer`. # Test: Search for `notificationsQueueService` usage. Expect: At least one usage. rg --type ts 'notificationsQueueService' -A 5Length of output: 12572
Script:
#!/bin/bash # Description: Verify specific usage of `notificationsQueueService` in `WaTwilioNotificationsConsumer`. # Test: Search for `notificationsQueueService` usage within the WaTwilioNotificationsConsumer class. ast-grep --lang typescript --pattern $'class WaTwilioNotificationsConsumer extends $_ { $$$ notificationsQueueService: $_ $$$ }' | xargs -I {} rg 'notificationsQueueService' -A 5 {}Length of output: 190
Script:
#!/bin/bash # Description: Find the file containing the WaTwilioNotificationsConsumer class and verify usage of notificationsQueueService. # Find the file containing the class definition file=$(rg --files-with-matches 'class WaTwilioNotificationsConsumer' --type ts) # Search for notificationsQueueService usage within the identified file if [ -n "$file" ]; then rg 'notificationsQueueService' -A 5 "$file" else echo "WaTwilioNotificationsConsumer class not found." fiLength of output: 639
apps/api/src/jobs/consumers/notifications/smsPlivo-notifications.job.consumer.ts (1)
Dependency Injection: Unused Dependency in
SmsPlivoNotificationsConsumer
The
notificationsQueueService
is injected into theSmsPlivoNotificationsConsumer
class but is not directly used within the class. It is only passed to the superclass constructor. Consider reviewing its necessity or implementing its intended functionality.
apps/api/src/jobs/consumers/notifications/smsPlivo-notifications.job.consumer.ts
Analysis chain
Line range hint
15-26
: Dependency Injection: Verify the new dependency integration.The
NotificationQueueProducer
is now injected into theSmsPlivoNotificationsConsumer
class. Ensure that this new dependency is correctly utilized within the class.Run the following script to verify the usage of
notificationsQueueService
within this class:Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify usage of `notificationsQueueService` in `SmsPlivoNotificationsConsumer`. # Test: Search for `notificationsQueueService` usage. Expect: At least one usage. rg --type ts 'notificationsQueueService' -A 5Length of output: 12572
Script:
#!/bin/bash # Description: Check for any usage of `notificationsQueueService` within `SmsPlivoNotificationsConsumer`. # Test: Search for method calls or operations involving `notificationsQueueService`. rg 'SmsPlivoNotificationsConsumer' -A 20 | rg 'notificationsQueueService'Length of output: 324
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (15)
- apps/api/src/common/constants/notifications.ts (1 hunks)
- apps/api/src/jobs/consumers/notifications/mailgun-notifications.job.consumer.ts (2 hunks)
- apps/api/src/jobs/consumers/notifications/notification.consumer.ts (5 hunks)
- apps/api/src/jobs/consumers/notifications/pushSns-notifications.job.consumer.ts (2 hunks)
- apps/api/src/jobs/consumers/notifications/smsKapsystem-notifications.job.consumer.ts (2 hunks)
- apps/api/src/jobs/consumers/notifications/smsPlivo-notifications.job.consumer.ts (2 hunks)
- apps/api/src/jobs/consumers/notifications/smsTwilio-notifications.job.consumer.ts (2 hunks)
- apps/api/src/jobs/consumers/notifications/smtp-notifications.job.consumer.ts (2 hunks)
- apps/api/src/jobs/consumers/notifications/vcTwilio-notifications.job.consumer.ts (2 hunks)
- apps/api/src/jobs/consumers/notifications/wa360dialog-notifications.job.consumer.ts (2 hunks)
- apps/api/src/jobs/consumers/notifications/waTwilio-notifications.job.consumer.ts (2 hunks)
- apps/api/src/jobs/consumers/notifications/waTwilioBusiness-notifications.job.consumer.ts (2 hunks)
- apps/api/src/modules/notifications/queues/queue.service.ts (3 hunks)
- apps/api/src/modules/webhook/webhook.module.ts (1 hunks)
- apps/api/src/modules/webhook/webhook.service.ts (3 hunks)
Additional context used
Learnings (10)
apps/api/src/jobs/consumers/notifications/smtp-notifications.job.consumer.ts (1)
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.
apps/api/src/jobs/consumers/notifications/pushSns-notifications.job.consumer.ts (1)
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.
apps/api/src/jobs/consumers/notifications/smsKapsystem-notifications.job.consumer.ts (1)
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.
apps/api/src/jobs/consumers/notifications/wa360dialog-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: LakshayaT PR: OsmosysSoftware/osmo-x#263 File: apps/api/src/jobs/consumers/notifications/waTwilio-notifications.job.consumer.ts:32-55 Timestamp: 2024-06-28T05:15:55.671Z Learning: Error handling for methods in `WaTwilioNotificationsConsumer` is managed by the superclass `NotificationConsumer`.
apps/api/src/jobs/consumers/notifications/waTwilio-notifications.job.consumer.ts (4)
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: LakshayaT PR: OsmosysSoftware/osmo-x#263 File: apps/api/src/jobs/consumers/notifications/waTwilio-notifications.job.consumer.ts:32-55 Timestamp: 2024-06-28T05:15:55.671Z Learning: Error handling for methods in `WaTwilioNotificationsConsumer` is managed by the superclass `NotificationConsumer`.
Learnt from: LakshayaT PR: OsmosysSoftware/osmo-x#263 File: apps/api/src/jobs/consumers/notifications/waTwilio-notifications.job.consumer.ts:0-0 Timestamp: 2024-07-02T10:51:45.044Z Learning: When refactoring code in the `WaTwilioNotificationsConsumer` class, unnecessary `else` clauses after `return` statements should be removed to simplify the control flow.
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.
apps/api/src/jobs/consumers/notifications/vcTwilio-notifications.job.consumer.ts (4)
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: LakshayaT PR: OsmosysSoftware/osmo-x#263 File: apps/api/src/jobs/consumers/notifications/waTwilio-notifications.job.consumer.ts:32-55 Timestamp: 2024-06-28T05:15:55.671Z Learning: Error handling for methods in `WaTwilioNotificationsConsumer` is managed by the superclass `NotificationConsumer`.
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.
Learnt from: LakshayaT PR: OsmosysSoftware/osmo-x#263 File: apps/api/src/jobs/consumers/notifications/waTwilio-notifications.job.consumer.ts:0-0 Timestamp: 2024-07-02T10:51:45.044Z Learning: When refactoring code in the `WaTwilioNotificationsConsumer` class, unnecessary `else` clauses after `return` statements should be removed to simplify the control flow.
apps/api/src/jobs/consumers/notifications/smsTwilio-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: LakshayaT PR: OsmosysSoftware/osmo-x#263 File: apps/api/src/jobs/consumers/notifications/waTwilio-notifications.job.consumer.ts:32-55 Timestamp: 2024-06-28T05:15:55.671Z Learning: Error handling for methods in `WaTwilioNotificationsConsumer` is managed by the superclass `NotificationConsumer`.
apps/api/src/jobs/consumers/notifications/waTwilioBusiness-notifications.job.consumer.ts (3)
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: LakshayaT PR: OsmosysSoftware/osmo-x#263 File: apps/api/src/jobs/consumers/notifications/waTwilio-notifications.job.consumer.ts:32-55 Timestamp: 2024-06-28T05:15:55.671Z Learning: Error handling for methods in `WaTwilioNotificationsConsumer` is managed by the superclass `NotificationConsumer`.
Learnt from: LakshayaT PR: OsmosysSoftware/osmo-x#263 File: apps/api/src/jobs/consumers/notifications/waTwilio-notifications.job.consumer.ts:0-0 Timestamp: 2024-07-02T10:51:45.044Z Learning: When refactoring code in the `WaTwilioNotificationsConsumer` class, unnecessary `else` clauses after `return` statements should be removed to simplify the control flow.
apps/api/src/jobs/consumers/notifications/mailgun-notifications.job.consumer.ts (2)
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.
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.
apps/api/src/jobs/consumers/notifications/notification.consumer.ts (2)
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.
Learnt from: LakshayaT PR: OsmosysSoftware/osmo-x#263 File: apps/api/src/jobs/consumers/notifications/notification.consumer.ts:36-40 Timestamp: 2024-07-03T05:58:54.296Z Learning: When reviewing retry mechanisms and delivery status updates, if the error object is already being logged, additional log messages for retry count and status might be redundant.
Additional comments not posted (12)
apps/api/src/modules/webhook/webhook.module.ts (1)
1-17
: LGTM! Verify the use offorwardRef
.The use of
forwardRef
to resolve circular dependencies is appropriate.However, ensure that the usage of
forwardRef
is consistent and correctly implemented across the codebase.Run the following script to verify the usage of
forwardRef
:Verification successful
Verification Successful: Consistent Use of
forwardRef
The usage of
forwardRef
is consistent across the codebase, primarily in resolving circular dependencies within thewebhook
andnotifications
modules. No issues were found with its implementation.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `forwardRef` in the codebase. # Test: Search for all occurrences of `forwardRef`. Expect: Consistent usage across the codebase. rg --type ts 'forwardRef'Length of output: 4644
apps/api/src/common/constants/notifications.ts (1)
26-26
: LGTM! Verify the usage ofWEBHOOK
.The addition of
WEBHOOK
to theQueueAction
object is appropriate.However, ensure that the
WEBHOOK
action is utilized correctly in the codebase.Run the following script to verify the usage of
WEBHOOK
:Verification successful
WEBHOOK Usage Verified
The
WEBHOOK
action is correctly utilized in the codebase, both in queue operations and notification processing logic.
queue.service.ts
: Handles various channel types and triggers webhooks appropriately.notification.consumer.ts
: Involved in notification processing logic.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `WEBHOOK` in the codebase. # Test: Search for all occurrences of `WEBHOOK`. Expect: Correct usage in queue operations. rg --type ts 'QueueAction.WEBHOOK'Length of output: 1568
Script:
#!/bin/bash # Check the context of `WEBHOOK` usage in queue.service.ts rg --type ts -A 5 'QueueAction.WEBHOOK' apps/api/src/modules/notifications/queues/queue.service.ts # Check the context of `WEBHOOK` usage in notification.consumer.ts rg --type ts -A 5 'QueueAction.WEBHOOK' apps/api/src/jobs/consumers/notifications/notification.consumer.tsLength of output: 1524
apps/api/src/jobs/consumers/notifications/smtp-notifications.job.consumer.ts (1)
Line range hint
11-32
: LGTM! Verify the usage ofNotificationQueueProducer
.The injection of
NotificationQueueProducer
intoSmtpNotificationConsumer
is appropriate.However, ensure that
NotificationQueueProducer
is utilized correctly in the codebase.Run the following script to verify the usage of
NotificationQueueProducer
:Verification successful
Usage of
NotificationQueueProducer
is verified and correct.The
NotificationQueueProducer
is used appropriately across the codebase, particularly in adding notifications to the queue with various actions. Its integration within consumer classes and services aligns with its intended functionality.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `NotificationQueueProducer` in the codebase. # Test: Search for all occurrences of `NotificationQueueProducer`. Expect: Correct usage in consumer classes. rg --type ts 'NotificationQueueProducer'Length of output: 5823
Script:
#!/bin/bash # Description: Search for method calls or usages of `NotificationQueueProducer` in the codebase. # Test: Search for all occurrences of method calls on `NotificationQueueProducer`. Expect: Correct usage in consumer classes. rg --type ts 'notificationQueueService\.' -A 3Length of output: 2154
apps/api/src/jobs/consumers/notifications/pushSns-notifications.job.consumer.ts (1)
Line range hint
10-31
: LGTM! Verify the usage ofNotificationQueueProducer
.The injection of
NotificationQueueProducer
intoPushSnsNotificationConsumer
is appropriate.However, ensure that
NotificationQueueProducer
is utilized correctly in the codebase.Run the following script to verify the usage of
NotificationQueueProducer
:Verification successful
Correct Usage of
NotificationQueueProducer
VerifiedThe
NotificationQueueProducer
class is being utilized correctly across the codebase. TheaddNotificationToQueue
method is called in various locations, including consumer classes and services, indicating its integration and usage are consistent with its intended purpose.
- Files with method calls:
apps/api/src/modules/notifications/notifications.service.ts
apps/api/src/jobs/consumers/notifications/notification.consumer.ts
These calls confirm that the
NotificationQueueProducer
is actively used to add notifications to the queue, aligning with its design.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `NotificationQueueProducer` in the codebase. # Test: Search for all occurrences of `NotificationQueueProducer`. Expect: Correct usage in consumer classes. rg --type ts 'NotificationQueueProducer'Length of output: 5823
Script:
#!/bin/bash # Description: Extract methods where `NotificationQueueProducer` is used to verify correct utilization. # Search for methods using `NotificationQueueProducer` in TypeScript files. rg --type ts 'NotificationQueueProducer' -A 10Length of output: 34911
Script:
#!/bin/bash # Description: Verify calls to `addNotificationToQueue` method in the codebase. # Search for calls to `addNotificationToQueue` method in TypeScript files. rg --type ts 'addNotificationToQueue'Length of output: 1026
apps/api/src/jobs/consumers/notifications/smsKapsystem-notifications.job.consumer.ts (1)
Line range hint
13-34
: LGTM! Verify the usage ofNotificationQueueProducer
.The injection of
NotificationQueueProducer
intoSmsKapsystemNotificationsConsumer
is appropriate.However, ensure that
NotificationQueueProducer
is utilized correctly in the codebase.Run the following script to verify the usage of
NotificationQueueProducer
:Verification successful
Correct Usage of
NotificationQueueProducer
VerifiedThe
NotificationQueueProducer
is used appropriately in the codebase. It is primarily used to add notifications to a queue with specific actions, indicating correct utilization.
notifications.service.ts
: CallsaddNotificationToQueue
with actions likeSEND
andDELIVERY_STATUS
.notification.consumer.ts
: CallsaddNotificationToQueue
with theWEBHOOK
action.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `NotificationQueueProducer` in the codebase. # Test: Search for all occurrences of `NotificationQueueProducer`. Expect: Correct usage in consumer classes. rg --type ts 'NotificationQueueProducer'Length of output: 5823
Script:
#!/bin/bash # Description: Verify the usage of `NotificationQueueProducer` methods or properties in the codebase. # Test: Search for all occurrences of `NotificationQueueProducer` method or property usage. rg --type ts 'notificationQueueService\.' -A 3Length of output: 2154
apps/api/src/modules/webhook/webhook.service.ts (1)
17-18
: Dependency Injection: Ensure circular dependency resolution.The
NotificationsService
is injected usingforwardRef
to resolve circular dependencies. Verify that this approach is correctly implemented and does not introduce runtime issues.Run the following script to check for any circular dependency issues:
Verification successful
Circular Dependency Resolution Verified
The use of
forwardRef
to injectNotificationsService
is correctly implemented to resolve circular dependencies. There are no indications of runtime issues related to this setup. The implementation is consistent and follows best practices for dependency injection in the codebase.
forwardRef
is used appropriately in thewebhook.service.ts
and other related files.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify circular dependency resolution for `NotificationsService`. # Test: Search for `forwardRef` usage related to `NotificationsService`. Expect: Correct usage without runtime issues. rg --type ts 'forwardRef\(\s*\(\)\s*=>\s*NotificationsService\s*\)' -A 5Length of output: 8436
Script:
#!/bin/bash # Description: Check if NotificationsService uses forwardRef to inject any dependent services. # Search for forwardRef usage within NotificationsService rg --type ts 'forwardRef\(\s*\(\)\s*=>\s*' -A 5 | grep -B 5 'NotificationsService'Length of output: 7068
apps/api/src/jobs/consumers/notifications/vcTwilio-notifications.job.consumer.ts (1)
Line range hint
15-26
: Dependency Injection: Verify the new dependency integration.The
NotificationQueueProducer
is now injected into theVcTwilioNotificationsConsumer
class. Ensure that this new dependency is correctly utilized within the class.Run the following script to verify the usage of
notificationsQueueService
within this class:Verification successful
Dependency Injection: Verify the new dependency integration.
The
notificationsQueueService
is injected into theVcTwilioNotificationsConsumer
class and passed to the superclass constructor. However, it is not directly used within the methods of this class. Ensure that this integration aligns with the intended design, especially if the superclass handles its usage.
- Consider reviewing the superclass to ensure proper utilization of
notificationsQueueService
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify usage of `notificationsQueueService` in `VcTwilioNotificationsConsumer`. # Test: Search for `notificationsQueueService` usage. Expect: At least one usage. rg --type ts 'notificationsQueueService' -A 5Length of output: 12572
Script:
#!/bin/bash # Description: Verify specific usage of `notificationsQueueService` in `VcTwilioNotificationsConsumer` class. # Test: Search for `notificationsQueueService` usage within the class definition. ast-grep --lang typescript --pattern $'class VcTwilioNotificationsConsumer extends $_ { $$$ notificationsQueueService: $_ $$$ }' -A 20Length of output: 141
Script:
#!/bin/bash # Description: Search for any usage of `notificationsQueueService` within the `VcTwilioNotificationsConsumer` class. # Test: Locate `notificationsQueueService` usage in the specific file. rg 'notificationsQueueService' apps/api/src/jobs/consumers/notifications/vcTwilio-notifications.job.consumer.ts -A 10Length of output: 730
apps/api/src/jobs/consumers/notifications/smsTwilio-notifications.job.consumer.ts (1)
Line range hint
15-26
: LGTM! Verify the integration ofNotificationQueueProducer
.The addition of
NotificationQueueProducer
to the constructor looks good.Ensure that
NotificationQueueProducer
is correctly integrated and utilized in the rest of the codebase.Run the following script to verify the usage of
NotificationQueueProducer
in the codebase:apps/api/src/jobs/consumers/notifications/waTwilioBusiness-notifications.job.consumer.ts (1)
Line range hint
15-26
: LGTM! Verify the integration ofNotificationQueueProducer
.The addition of
NotificationQueueProducer
to the constructor looks good.Ensure that
NotificationQueueProducer
is correctly integrated and utilized in the rest of the codebase.Run the following script to verify the usage of
NotificationQueueProducer
in the codebase:apps/api/src/jobs/consumers/notifications/mailgun-notifications.job.consumer.ts (1)
Line range hint
13-24
: LGTM! Verify the integration ofNotificationQueueProducer
.The addition of
NotificationQueueProducer
to the constructor looks good.Ensure that
NotificationQueueProducer
is correctly integrated and utilized in the rest of the codebase.Run the following script to verify the usage of
NotificationQueueProducer
in the codebase:Verification successful
Integration of
NotificationQueueProducer
VerifiedThe
NotificationQueueProducer
is correctly integrated and utilized across the codebase. It is consistently used to enqueue notifications for various actions, demonstrating its effective integration.
- Usage Locations:
notifications.service.ts
: Used for actions likeSEND
andDELIVERY_STATUS
.notification.consumer.ts
: Used forWEBHOOK
actions.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `NotificationQueueProducer`. # Test: Search for the usage of `NotificationQueueProducer`. Expect: Correct integration and usage. rg --type ts 'NotificationQueueProducer'Length of output: 5823
Script:
#!/bin/bash # Description: Verify the usage of `NotificationQueueProducer` by checking for method calls or interactions. # Search for method calls or interactions with `NotificationQueueProducer` rg --type ts 'notificationQueueService\.' -A 5Length of output: 3001
apps/api/src/jobs/consumers/notifications/notification.consumer.ts (1)
Line range hint
13-24
: LGTM! Verify the integration ofNotificationQueueProducer
.The addition of
NotificationQueueProducer
to the constructor and its usage in queuing notifications looks good.Ensure that
NotificationQueueProducer
is correctly integrated and utilized in the rest of the codebase.Run the following script to verify the usage of
NotificationQueueProducer
in the codebase:Verification successful
Integration of
NotificationQueueProducer
VerifiedThe
NotificationQueueProducer
is correctly integrated and utilized in the codebase. It is used to add notifications to the queue in various parts of the application, such as innotifications.service.ts
andnotification.consumer.ts
. The methodaddNotificationToQueue
is called with appropriate parameters, indicating its intended functionality is being used.
- Files with Usage:
apps/api/src/modules/notifications/notifications.service.ts
apps/api/src/jobs/consumers/notifications/notification.consumer.ts
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `NotificationQueueProducer`. # Test: Search for the usage of `NotificationQueueProducer`. Expect: Correct integration and usage. rg --type ts 'NotificationQueueProducer'Length of output: 5823
Script:
#!/bin/bash # Description: Verify method calls on instances of `NotificationQueueProducer`. # Test: Search for method calls on `NotificationQueueProducer` instances. rg --type ts '\bnotificationQueueService\.\w+\(' -A 3Length of output: 2161
apps/api/src/modules/notifications/queues/queue.service.ts (1)
Line range hint
16-40
: LGTM! Verify the integration ofWebhookService
.The addition of
WebhookService
to the constructor and its usage in handling webhook actions looks good.Ensure that
WebhookService
is correctly integrated and utilized in the rest of the codebase.Run the following script to verify the usage of
WebhookService
in the codebase:Verification successful
WebhookService Integration Verified
The
WebhookService
is correctly integrated and utilized in the codebase. It is actively used in various parts of the application, including thequeue.service.ts
andwebhook.resolver.ts
files, to handle webhook-related actions. No issues were found with its integration.
queue.service.ts
: Used to trigger webhooks.webhook.resolver.ts
: Used to register webhooks.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `WebhookService`. # Test: Search for the usage of `WebhookService`. Expect: Correct integration and usage. rg --type ts 'WebhookService'Length of output: 4412
Script:
#!/bin/bash # Description: Verify the usage of `WebhookService` methods. # Search for method calls or interactions with `WebhookService` in relevant files. rg --type ts 'webhookService\.' -A 3Length of output: 776
API PR Checklist
Pre-requisites
.env.example
file with the required values as applicable.PR Details
PR details have been updated as per the given format (see below)
feat: add admin login endpoint
)Additional Information
ready for review
should be added if the PR is ready to be reviewed)Note: Reviewer should ensure that the checklist and description have been populated and followed correctly, and the PR should be merged only after resolving all conversations and verifying that CI checks pass.
Description:
This PR moves the logic for sending webhook calls to a separate queue instead of handling it during the notification sending and provider confirmation itself.
Related changes:
Screenshots:
N/A
Query request and response:
N/A
Documentation changes:
N/A
Test suite/unit testing output:
N/A
Pending actions:
N/A
Additional notes:
N/A
Summary by CodeRabbit
New Features
WEBHOOK
action, enhancing the notification management system.Bug Fixes
Documentation
WebhookModule
andNotificationsModule
.Refactor
WebhookService
to accept notification IDs instead of objects, streamlining webhook triggering processes.