-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix/84 Ignore webhook without user details #85
Conversation
|
||
GOOGLE_APPLICATION_CREDENTIALS = os.environ.get("GOOGLE_APPLICATION_CREDENTIALS") |
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.
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
api/services/handle_event_service.py
Outdated
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 | ||
|
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.
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.
call_sid_exist = models.CallLogEvent.query.call_sid_exist( | ||
form_data.get("CallSid") | ||
) |
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.
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.
def call_sid_exist(self, call_sid): | ||
return self.filter(CallLogEvent.call_sid == call_sid).first() is not None |
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.
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 |
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.
Ignoring the JSON files to be added to the GitHub.
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.
Just one suggestion, else looks good to go. Please fix and merge.
api/services/handle_event_service.py
Outdated
@@ -23,6 +25,14 @@ def handle_event_service(self, form_data): | |||
if not system_phone_exists: | |||
return | |||
|
|||
user_details_exist = form_data.get("From") |
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.
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?
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.
Sure, let me update it.
#84
Please complete the following steps and check these boxes before filing your PR:
Types of changes
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: