Skip to content

Add WA msg timestamp extraction & msg-age condition #173

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

Merged

Conversation

OdyAsh
Copy link
Collaborator

@OdyAsh OdyAsh commented Apr 23, 2025

No description provided.

@OdyAsh OdyAsh requested a review from Copilot April 23, 2025 20:27
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds extraction of the Unix timestamp from incoming WhatsApp messages and implements a condition to check the age of the message (i.e., ignore messages older than 24 hours).

  • Extracts and stores message_unix_time in the WhatsAppPresenter constructor and related methods
  • Updates the tuple returned by extract_relevant_whatsapp_message_details to include the new timestamp
  • Integrates a new is_message_too_old method in both the presenter and main webhook for early message rejection

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/ansari/presenters/whatsapp_presenter.py Added message timestamp extraction, updated return types, and introduced a new method to check message age
src/ansari/app/main_whatsapp.py Updated presenter instantiation and added logic to check message age before processing
Comments suppressed due to low confidence (1)

src/ansari/presenters/whatsapp_presenter.py:140

  • The condition is comparing the value of incoming_msg['type'] to the keys of incoming_msg, which is a logical error. Instead, check for the key's existence (e.g. 'if "type" in incoming_msg') or use a more appropriate validation logic.
incoming_msg_type = incoming_msg["type"] if incoming_msg["type"] in incoming_msg.keys() else "errors"

@waleedkadous waleedkadous self-requested a review April 23, 2025 21:10
@waleedkadous waleedkadous merged commit b643992 into ansari-project:develop Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants