Business Logic
loglife.app.logic.text.processor
Message processing logic for inbound WhatsApp text commands.
process_text(user, message)
Route incoming text commands to the appropriate goal or rating handler.
Handle commands such as adding goals, submitting ratings, configuring reminder times, and generating look-back summaries. Maintain temporary state for multi-step flows (e.g., goal reminder setup).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user
|
User
|
The user record for the message sender |
required |
message
|
str
|
The incoming text message content |
required |
Returns:
| Type | Description |
|---|---|
str
|
The WhatsApp response text to send back to the user. |
Source code in src/loglife/app/logic/text/processor.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
loglife.app.logic.audio.processor
Audio processing workflow for inbound WhatsApp messages.
Orchestrates transcription (Whisper), summarization (GPT), and database storage of voice notes.
process_audio(sender, user, audio_data, client_type='whatsapp')
Process an incoming audio message from a user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sender
|
str
|
The WhatsApp phone number of the sender |
required |
user
|
User
|
The user record dictionary |
required |
audio_data
|
str
|
Base64 encoded audio payload |
required |
client_type
|
str
|
The client type to send responses to (default: "whatsapp") |
'whatsapp'
|
Returns:
| Type | Description |
|---|---|
str | tuple[str, str]
|
The summarized text generated from the audio, or a tuple of |
str | tuple[str, str]
|
(transcript_file_base64, summarized_text). |
Source code in src/loglife/app/logic/audio/processor.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
loglife.app.logic.vcard.processor
Processing logic for referral VCARD payloads.
process_vcard(referrer_user, raw_vcards)
Create referral users from VCARD attachments.
Parse the incoming VCARD JSON payload, ensure each contact exists as a user, link referrals, and send a welcome message to each referred number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
referrer_user
|
User
|
The user dict of the person sharing the VCARDs |
required |
raw_vcards
|
str
|
JSON string containing the VCARD data list |
required |
Returns:
| Type | Description |
|---|---|
str
|
The referral success message constant. |
Source code in src/loglife/app/logic/vcard/processor.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |