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

Fix/84 Ignore webhook without user details #85

Merged
merged 6 commits into from
Aug 13, 2024

Conversation

Sachinbisht27
Copy link
Member

#84

Please complete the following steps and check these boxes before filing your PR:

Types of changes

  • Bug fix (a change which fixes an issue)
  • New feature (a change which adds functionality)

Short description of what this resolves:

Describe your changes in detail:
Ignore webhooks that lack user details and log a warning for each occurrence.

Checklist:

  • I have performed a self-review of my own code.
  • The code follows the style guidelines of this project.
  • The code changes are passing the CI checks
  • I have documented my code wherever required.
  • The changes requires a change to the documentation.
  • I have updated the documentation based on the my changes.

@Sachinbisht27 Sachinbisht27 added the bug Something isn't working label Aug 9, 2024
@Sachinbisht27 Sachinbisht27 self-assigned this Aug 9, 2024
Comment on lines +49 to +50

GOOGLE_APPLICATION_CREDENTIALS = os.environ.get("GOOGLE_APPLICATION_CREDENTIALS")
Copy link
Member Author

Choose a reason for hiding this comment

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

This is added because every time while run the server locally we get an error that:

google.auth.exceptions.DefaultCredentialsError: File big-query-credentials.json was not found

Comment on lines 28 to 35
user_details_exist = form_data.get("From")

if user_details_exist is None:
logger.warning(
f"User details are missing in the webhook payload: {form_data}"
)
return

Copy link
Member Author

Choose a reason for hiding this comment

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

Here we are checking if the user details are present in the webhook we are getting from the KooKoo. If not then we are skipping those webhooks to be processed.

Comment on lines +12 to +14
call_sid_exist = models.CallLogEvent.query.call_sid_exist(
form_data.get("CallSid")
)
Copy link
Member Author

Choose a reason for hiding this comment

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

Previously, the entire webhook payload was passed as a parameter in the query, and we extracted the callsid within the model. Now, I’ve optimized the process by passing only the callsid in the query, as it's the only required parameter.

Comment on lines +7 to +8
def call_sid_exist(self, call_sid):
return self.filter(CallLogEvent.call_sid == call_sid).first() is not None
Copy link
Member Author

Choose a reason for hiding this comment

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

Updated the query based on the changes done in the handle event service from where the query is called.

@@ -9,6 +9,7 @@ htmlcov/
.venv
env/
venv/
*.json
Copy link
Member Author

Choose a reason for hiding this comment

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

Ignoring the JSON files to be added to the GitHub.

Copy link
Member

@Satendra-SR Satendra-SR left a comment

Choose a reason for hiding this comment

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

Just one suggestion, else looks good to go. Please fix and merge.

@@ -23,6 +25,14 @@ def handle_event_service(self, form_data):
if not system_phone_exists:
return

user_details_exist = form_data.get("From")
Copy link
Member

Choose a reason for hiding this comment

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

The name sounds like it will store a boolean value, which I believe is not correct.
Can we write it just user_details or something similar?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, let me update it.

@Sachinbisht27 Sachinbisht27 merged commit dfbe5bd into develop Aug 13, 2024
1 check passed
@Sachinbisht27 Sachinbisht27 deleted the fix/84-ignore-webhook-without-user-details branch August 13, 2024 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants