-
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
Changes from 5 commits
2352652
1809e99
e4f2968
3f249fa
11835c7
ad74a9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ htmlcov/ | |
.venv | ||
env/ | ||
venv/ | ||
*.json | ||
|
||
.vscode | ||
.DS_Store |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,8 @@ | |
|
||
|
||
class CallLogEventQuery(BaseQuery): | ||
def call_sid_exist(self, form_data): | ||
return ( | ||
self.filter(CallLogEvent.call_sid == form_data["CallSid"]).first() | ||
is not None | ||
) | ||
def call_sid_exist(self, call_sid): | ||
return self.filter(CallLogEvent.call_sid == call_sid).first() is not None | ||
Comment on lines
+7
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
|
||
class CallLogEvent(TimestampMixin, db.Model): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,9 @@ | |
|
||
class HandleEventService: | ||
def handle_event_service(self, form_data): | ||
call_sid_exist = models.CallLogEvent.query.call_sid_exist(form_data) | ||
call_sid_exist = models.CallLogEvent.query.call_sid_exist( | ||
form_data.get("CallSid") | ||
) | ||
Comment on lines
+12
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
if call_sid_exist: | ||
return | ||
|
@@ -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 commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, let me update it. |
||
|
||
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 commentThe 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. |
||
try: | ||
data = {} | ||
data["call_sid"] = form_data["CallSid"] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,5 @@ | |
TELCO_CODE_ANSWERED = 16 | ||
DEFAULT_LANGUAGE_ID = 1 | ||
MAX_RETRY_ATTEMPTS_FOR_LOGS = os.environ.get("MAX_RETRY_ATTEMPTS_FOR_LOGS", 3) | ||
|
||
GOOGLE_APPLICATION_CREDENTIALS = os.environ.get("GOOGLE_APPLICATION_CREDENTIALS") | ||
Comment on lines
+49
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
|
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.