Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
1275ac0
ci: replace --no-frozen-lockfile with --frozen-lockfile
sankalpaacharya Aug 3, 2025
b707cec
Merge pull request #99 from heygaia/fix/workflow
Dhruv-Maradiya Aug 3, 2025
b46e9ca
perf: parallelize cloudinary upload and summary generation
sankalpaacharya Aug 3, 2025
9d39255
ci: upgrade pnpm from v8 to v10.12.2
sankalpaacharya Aug 3, 2025
ad1e562
Merge pull request #98 from heygaia/fix/file_upload
sankalpaacharya Aug 3, 2025
c4199c6
feat: update privacy policy to include Google user data handling and …
aryanranderiya Aug 6, 2025
3ab5b73
refactor: simplify onboarding process by removing country-related fie…
aryanranderiya Aug 6, 2025
b2315ef
Merge 3ab5b736c2e7804b53fd777fa80676ee6e5a097c into ad1e562b548800688…
aryanranderiya Aug 6, 2025
605786c
ci(auto-fix): Apply ESLint formatting
actions-user Aug 6, 2025
e1f2176
feat: enhance subscription management and webhook processing
aryanranderiya Aug 6, 2025
3c95a51
refactor: update datetime handling and remove unused apiService
Dhruv-Maradiya Aug 6, 2025
2434176
Refactor payment handling and UI components
aryanranderiya Aug 6, 2025
9720dd0
feat: add dodo_product_id to Plan model and update related components
aryanranderiya Aug 6, 2025
308c3c8
feat: implement JWT authentication for Pub/Sub webhook requests
Dhruv-Maradiya Aug 7, 2025
1cd16f0
fix: filtered empty user messages in system generated chat when respo…
Dhruv-Maradiya Aug 7, 2025
45627a9
feat: enhance logout functionality to redirect to logout URL from bac…
Dhruv-Maradiya Aug 7, 2025
6898cb6
feat: implement Dodo Payments webhook handling and processing logic
aryanranderiya Aug 7, 2025
8bc3549
feat: enhance error handling for integration toasts to prevent duplic…
Dhruv-Maradiya Aug 7, 2025
5101fda
feat: update Navbar to display chat icon and link based on user authe…
Dhruv-Maradiya Aug 7, 2025
1f84ef8
Refactor Dodo Payments integration:
aryanranderiya Aug 7, 2025
6db268e
feat: enhance tool execution request message to include fallback for …
Dhruv-Maradiya Aug 7, 2025
0ddae59
feat: enhance Dodo Payments webhook handling with signature verification
aryanranderiya Aug 7, 2025
ec47b25
feat: add auto redirect countdown to SubscriptionSuccessModal
aryanranderiya Aug 7, 2025
abdbf4f
Merge 6db268e085bfe757aaf8daa9732d7a065487413c into ad1e562b548800688…
Dhruv-Maradiya Aug 7, 2025
dac68fd
ci(auto-fix): Apply ESLint formatting
actions-user Aug 7, 2025
b43afd6
feat: integrate Standard Webhooks library for Dodo Payments signature…
aryanranderiya Aug 7, 2025
7e362b1
feat: update Dodo Payments setup script and modify subscription plans…
aryanranderiya Aug 7, 2025
ccfd72d
Merge 7e362b17f442e589175ea911021dc64cf6b99416 into ad1e562b548800688…
aryanranderiya Aug 7, 2025
839733d
ci(auto-fix): Apply ESLint formatting
actions-user Aug 7, 2025
ff5f475
feat: refactor navigation components and enhance app configuration wi…
aryanranderiya Aug 7, 2025
12bcc6d
feat: add ScrollToBottomButton component for improved chat navigation
aryanranderiya Aug 7, 2025
181a2e1
feat: implement abort controller management for chat stream handling
aryanranderiya Aug 7, 2025
d512dfd
feat: implement save functionality for incomplete conversations in ch…
aryanranderiya Aug 8, 2025
a9f7ff0
feat: refactor modal handling in ChatOptionsDropdown for improved sta…
aryanranderiya Aug 8, 2025
177d711
fix: shift + enter appends to end of composer
aryanranderiya Aug 8, 2025
efaa599
chore:lint
aryanranderiya Aug 8, 2025
9151019
Merge pull request #101 from heygaia/fix/onboarding
Dhruv-Maradiya Aug 9, 2025
6ce38c2
feat: enhance memory management with async client and export options …
aryanranderiya Aug 9, 2025
17b2730
Apply suggestion from @Copilot
aryanranderiya Aug 9, 2025
27b331a
Update backend/app/models/payment_models.py
aryanranderiya Aug 9, 2025
5846c87
Update backend/scripts/dodo_setup.py
aryanranderiya Aug 9, 2025
c364762
Update backend/scripts/dodo_setup.py
aryanranderiya Aug 9, 2025
a0edf14
Merge branch 'develop' of https://github.com/heygaia/gaia into fix/pa…
aryanranderiya Aug 9, 2025
f47b9fc
Merge a0edf142aa304160c4cce252510cf157fb034011 into 915101989e29068a2…
aryanranderiya Aug 9, 2025
019cdaf
ci(auto-fix): Apply pre-commit hooks formatting
actions-user Aug 9, 2025
d3488cd
Merge pull request #103 from heygaia/fix/payment-gateway
aryanranderiya Aug 9, 2025
dd00ba8
Merge remote-tracking branch 'origin/develop' into fix/minor-bug-fixes
aryanranderiya Aug 9, 2025
8fbb3ab
Merge dd00ba837e854debb22b1867e6df6259f95b661d into d3488cd90da859412…
aryanranderiya Aug 9, 2025
d0bb0d2
ci(auto-fix): Apply ESLint formatting
actions-user Aug 9, 2025
6ed518d
refactor: improve validation and sanitization in onboarding preferences
aryanranderiya Aug 9, 2025
1a0e9b0
Merge branch 'develop' of https://github.com/heygaia/gaia into fix/bu…
aryanranderiya Aug 9, 2025
a137583
refactor: update OAuth integration comments and adjust dropdown posit…
aryanranderiya Aug 9, 2025
04f7a87
refactor: streamline input clearing logic in Composer and useChatStream
aryanranderiya Aug 9, 2025
0c73b68
Merge branch 'develop' into fix/stream-break
aryanranderiya Aug 9, 2025
4a4a984
Merge 0c73b68fcf6f49624fd3cc23fdb3537f5c694f25 into d3488cd90da859412…
Dhruv-Maradiya Aug 9, 2025
f46beb5
ci(auto-fix): Apply pre-commit hooks formatting
actions-user Aug 9, 2025
87bd465
feat: enhance OAuth integration handling with unified integrations su…
aryanranderiya Aug 9, 2025
d825ad6
feat: implement caching for integrations configuration to enhance per…
aryanranderiya Aug 9, 2025
fcceeb2
Merge d825ad64707c3674490ffa3a9c0b11f468b42bc4 into d3488cd90da859412…
aryanranderiya Aug 9, 2025
65c199c
ci(auto-fix): Apply ESLint formatting
actions-user Aug 9, 2025
babd2a9
feat: refactor Google OAuth integration handling and improve scope ma…
aryanranderiya Aug 9, 2025
86493cb
Merge branch 'fix/oauth-integrations-config' of https://github.com/he…
aryanranderiya Aug 9, 2025
b30ac41
feat: update integration icon handling to support multiple icons
aryanranderiya Aug 9, 2025
2482139
chore: fix linting & type issues
aryanranderiya Aug 9, 2025
67c62f5
Merge 2482139201e8ae01d218215653d03163305cd8e5 into d3488cd90da859412…
aryanranderiya Aug 9, 2025
923edd1
ci(auto-fix): Apply ESLint formatting
actions-user Aug 9, 2025
ef63c64
chore: configure PostHog analytics
aryanranderiya Aug 9, 2025
715a89b
feat: add Sentry integration for error tracking and performance monit…
aryanranderiya Aug 10, 2025
e9db07d
feat: integrate Sentry for error tracking and performance monitoring
aryanranderiya Aug 10, 2025
1914759
Merge branch 'master' of https://github.com/heygaia/gaia into develop
aryanranderiya Aug 10, 2025
cba299e
Merge branch 'develop' into fix/stream-break
aryanranderiya Aug 10, 2025
b4a8309
Merge pull request #102 from heygaia/fix/stream-break
aryanranderiya Aug 10, 2025
8824e0f
Merge branch 'develop' into fix/minor-bug-fixes
aryanranderiya Aug 10, 2025
c45cc20
Merge 8824e0f77ab85c60d4becd31e82194cb6c4a1c6b into b4a83099b4ae747d6…
aryanranderiya Aug 10, 2025
45c8623
ci(auto-fix): Apply pre-commit hooks formatting
actions-user Aug 10, 2025
90988ba
Create CODE_OF_CONDUCT.md
aryanranderiya Aug 10, 2025
80077e3
Merge pull request #108 from heygaia/code-of-conduct
aryanranderiya Aug 10, 2025
c2d5803
Merge pull request #107 from heygaia/feat/tracking-posthog-sentry
Dhruv-Maradiya Aug 11, 2025
4eeba86
Merge pull request #106 from heygaia/fix/bugs-1
Dhruv-Maradiya Aug 11, 2025
40d471e
feat: enhance calendar event handling with timezone support and updat…
Dhruv-Maradiya Aug 11, 2025
d520cf9
feat: update WorkOS client to AsyncWorkOSClient and enhance calendar …
Dhruv-Maradiya Aug 12, 2025
d1bfa29
refactor: remove unused router import from useChatStream hook
Dhruv-Maradiya Aug 12, 2025
5e876d5
Merge branch 'develop' of https://github.com/heygaia/gaia into fix/oa…
aryanranderiya Aug 12, 2025
bd9721c
Remove outdated documentation and OAuth integration icons from the pr…
aryanranderiya Aug 12, 2025
3110a22
Merge pull request #105 from heygaia/fix/oauth-integrations-config
aryanranderiya Aug 12, 2025
df94b7b
Update frontend/src/features/chat/components/composer/ComposerRight.tsx
aryanranderiya Aug 12, 2025
25a7891
Merge branch 'develop' of https://github.com/heygaia/gaia into fix/mi…
aryanranderiya Aug 12, 2025
3a02a87
Merge branch 'fix/minor-bug-fixes' of https://github.com/heygaia/gaia…
aryanranderiya Aug 12, 2025
ef57688
Merge pull request #104 from heygaia/fix/minor-bug-fixes
aryanranderiya Aug 12, 2025
7bcaece
fix: "error in chat stream" error infinite
Dhruv-Maradiya Aug 12, 2025
eef3937
feat: implement support ticket system with creation and management tools
Dhruv-Maradiya Aug 13, 2025
3617c5b
docs: update usage rules in support ticket tool documentation for cla…
Dhruv-Maradiya Aug 13, 2025
f7c5c52
Merge branch 'develop' of https://github.com/heygaia/gaia into feat/i…
aryanranderiya Aug 13, 2025
d598b22
feat: add Cerebras AI configuration and integrate ChatCerebras model …
Dhruv-Maradiya Aug 13, 2025
7fad1eb
Merge branch 'feat/integrate-cerebras' of https://github.com/heygaia/…
Dhruv-Maradiya Aug 13, 2025
118759c
Merge 7fad1eb58798106ce9f0207d437d34d1277ed857 into ef57688a6f86c7c68…
Dhruv-Maradiya Aug 13, 2025
8c21817
ci(auto-fix): Apply ESLint formatting
actions-user Aug 13, 2025
d50836b
feat: removed unused nltk and replaced embeddings model with better e…
Dhruv-Maradiya Aug 13, 2025
dfc9b58
fix: remove unnecessary max-height from description scroll shadow
Dhruv-Maradiya Aug 13, 2025
5a9c559
Merge dfc9b58ee739249fcf3fd50194482d5e189f7780 into ef57688a6f86c7c68…
Dhruv-Maradiya Aug 13, 2025
3fe09a8
ci(auto-fix): Apply pre-commit hooks formatting
actions-user Aug 13, 2025
05577c3
Merge pull request #109 from heygaia/feat/integrate-cerebras
aryanranderiya Aug 14, 2025
8956a7b
Merge branch 'master' of https://github.com/heygaia/gaia into develop
aryanranderiya Aug 21, 2025
80a1315
chore(ci): add manual trigger for Release Please workflow
aryanranderiya Aug 21, 2025
ee12dc3
Merge pull request #117 from heygaia/chore/ci-add-release-please-manu…
aryanranderiya Aug 21, 2025
125b919
fix: update release token in workflow and import useRouter in useChat…
aryanranderiya Aug 21, 2025
7f8fbe2
Merge branch 'develop' into aryanranderiya-patch-releases
aryanranderiya Aug 21, 2025
486ed9d
Merge 7f8fbe2e1c027b2c302656fbdbaf8009c7b52c81 into ee12dc324dbd63cb3…
aryanranderiya Aug 21, 2025
64c08b2
ci(auto-fix): Apply ESLint formatting
actions-user Aug 21, 2025
336ef86
Merge pull request #118 from heygaia/aryanranderiya-patch-releases
aryanranderiya Aug 21, 2025
5c68dca
chore: merge master into develop
aryanranderiya Aug 21, 2025
083b078
Merge branch 'master' into develop
aryanranderiya Aug 21, 2025
5bc5ff8
chore(lint): Remove unused imports in PricingPage component
aryanranderiya Aug 21, 2025
c39e683
Merge branch 'develop' of https://github.com/heygaia/gaia into develop
aryanranderiya Aug 21, 2025
931a959
docs: Added Code of Conduct
jigarbhoye04 Aug 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- uses: pnpm/action-setup@v2
with:
version: 8
version: 10.12.2

- name: Use Node.js
uses: actions/setup-node@v3
Expand All @@ -31,8 +31,7 @@ jobs:

- name: Install dependencies
run: |
pnpm install --no-frozen-lockfile
pnpm install
pnpm install --frozen-lockfile

- name: Run ESLint with autofix
run: pnpm lint:fix
Expand Down
58 changes: 58 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Contributor Covenant Code of Conduct

## Our Commitment

We are committed to making participation in our community a welcoming, respectful, and productive experience for everyone.

## Standards

Positive examples of behavior include:

- Showing respect and kindness to others
- Being open to different perspectives and experiences
- Offering and accepting constructive feedback
- Taking responsibility for mistakes and working to correct them

Unacceptable behavior includes:

- Harassment or discrimination of any kind
- Offensive, derogatory, or inappropriate comments
- Personal attacks or trolling
- Sharing private information without consent
- Any unprofessional or disruptive conduct

## Responsibilities

Community leaders will:

- Enforce this Code of Conduct consistently and fairly
- Take appropriate action for violations, which may include warnings, temporary bans, or permanent bans
- Provide clear reasons for moderation decisions when possible

## Scope

This Code of Conduct applies across all community spaces and when an individual is representing the community in public settings.

## Enforcement

If you experience or witness unacceptable behavior, please report it to the community leaders at **your-email@example.com**. Reports will be handled respectfully, promptly, and with confidentiality.

## Enforcement Guidelines

Community leaders will use the following guidelines when determining consequences for violations:

1. **Warning**
- *Behavior*: Minor or first-time violation.
- *Action*: Private warning with explanation. A public apology may be requested.

2. **Temporary Ban**
- *Behavior*: More serious or repeated violations.
- *Action*: Temporary restriction from community participation.

3. **Permanent Ban**
- *Behavior*: Severe or ongoing violations.
- *Action*: Permanent removal from the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant, version 2.0](https://www.contributor-covenant.org/version/2/0/code_of_conduct.html), with modifications for clarity and brevity.
11 changes: 11 additions & 0 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# ============================================================================================
# IMPORTANT: DO NOT DELETE THIS FILE
# --------------------------------------------------------------------------------------------
# This `.env.example` file is required for the repository. It serves as a reference template
# showing the environment variables needed to run the project. Actual values must be provided
# via Infisical or your own `.env` file, but this file should remain in version control.
#
# For setup instructions and details on configuring environment variables, see:
# https://docs.heygaia.io/configuration/environment-variables
# ============================================================================================

# Environment Configuration
ENV=development # Environment type: development, staging, production
DISABLE_PROFILING=true # Disable performance profiling in non-production environments
Expand Down
9 changes: 3 additions & 6 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@
uv pip install --system --no-cache-dir -r heavy-deps.txt && \
rm -rf /root/.cache/pip

# Setup Playwright and NLTK
RUN python -m playwright install --with-deps chromium
RUN python -m nltk.downloader punkt stopwords punkt_tab && \
rm -rf /root/.cache/nltk
# Setup Playwright
RUN python -m playwright install chromium

# ---- Default Dependencies Stage: Install default application dependencies ----
FROM heavy-dependencies AS default-dependencies
Expand Down Expand Up @@ -82,8 +80,7 @@

# Setup non-root user and permissions
RUN adduser --disabled-password --gecos '' appuser \
&& mkdir -p /home/appuser/.cache/huggingface /home/appuser/nltk_data \
&& cp -R /root/nltk_data/* /home/appuser/nltk_data/ \
&& mkdir -p /home/appuser/.cache \
&& chown -R appuser:appuser /home/appuser \
&& cp -R /root/.cache/ms-playwright /home/appuser/.cache/ \
&& chown -R appuser:appuser /home/appuser/.cache/ms-playwright \
Expand Down
50 changes: 25 additions & 25 deletions backend/app/api/v1/dependencies/google_scope_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
before allowing access to protected endpoints that require specific integrations.
"""

from typing import Dict, List, Literal, Union
from typing import List, Literal, Union

import httpx
from app.api.v1.dependencies.oauth_dependencies import get_current_user
from app.config.loggers import auth_logger as logger
from app.config.oauth_config import get_integration_scopes, get_short_name_mapping
from app.config.token_repository import token_repository
from fastapi import Depends, HTTPException, status

Expand Down Expand Up @@ -40,10 +41,13 @@ async def wrapper(user: dict = Depends(get_current_user)):
)

try:
token = await token_repository.get_token(
user_id, "google", renew_if_expired=True
)
authorized_scopes = str(token.get("scope", "")).split()
try:
token = await token_repository.get_token(
user_id, "google", renew_if_expired=True
)
authorized_scopes = str(token.get("scope", "")).split()
except HTTPException:
authorized_scopes = []

# Handle both single scope and list of scopes
required_scopes = [scope] if isinstance(scope, str) else scope
Expand Down Expand Up @@ -76,18 +80,6 @@ async def wrapper(user: dict = Depends(get_current_user)):
return wrapper


# Mapping of integration names to their required OAuth scope URLs
GOOGLE_SCOPE_URLS: Dict[str, Union[str, List[str]]] = {
"gmail": "https://www.googleapis.com/auth/gmail.modify",
"calendar": [
"https://www.googleapis.com/auth/calendar.events",
"https://www.googleapis.com/auth/calendar.readonly",
],
"drive": "https://www.googleapis.com/auth/drive.file",
"docs": "https://www.googleapis.com/auth/documents",
}


def require_google_integration(
integration: Literal["gmail", "calendar", "drive", "docs"],
):
Expand All @@ -101,24 +93,32 @@ def require_google_integration(
def get_events(user = Depends(require_google_integration("calendar"))):
# user has Calendar scope with both read and write permissions

# For Calendar readonly endpoints
@app.get("/calendar/events/readonly")
def get_events_readonly(user = Depends(require_google_integration("calendar_readonly"))):
# user has Calendar readonly scope
# For Gmail endpoints
@app.get("/gmail/messages")
def get_messages(user = Depends(require_google_integration("gmail"))):
# user has Gmail scope with required permissions

Args:
integration: The Google integration name
integration: The Google integration short name

Returns:
The corresponding scope dependency function

Raises:
ValueError: If unknown integration name is provided
"""
if integration not in GOOGLE_SCOPE_URLS:
# Get the short name mapping from oauth_config (single source of truth)
short_name_mapping = get_short_name_mapping()

if integration not in short_name_mapping:
raise ValueError(
f"Unknown integration: {integration}. Available: {list(GOOGLE_SCOPE_URLS.keys())}"
f"Unknown integration: {integration}. Available: {list(short_name_mapping.keys())}"
)

scope_urls = GOOGLE_SCOPE_URLS[integration]
integration_id = short_name_mapping[integration]
scope_urls = get_integration_scopes(integration_id)

if not scope_urls:
raise ValueError(f"No scopes found for integration: {integration_id}")

return require_google_scope(scope_urls)
76 changes: 72 additions & 4 deletions backend/app/api/v1/router/chat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, timezone

from fastapi import APIRouter, BackgroundTasks, Depends
from fastapi.responses import StreamingResponse
Expand All @@ -7,13 +7,23 @@
get_current_user,
get_user_timezone,
)
from app.decorators import tiered_rate_limit
from app.models.message_models import MessageRequestWithHistory
from app.services.chat_service import chat_stream
from app.decorators import profile_time, tiered_rate_limit
from app.models.message_models import (
MessageRequestWithHistory,
SaveIncompleteConversationRequest,
MessageDict,
)
from app.models.chat_models import MessageModel, UpdateMessagesRequest
from app.services.chat_service import (
chat_stream,
)
from app.services.conversation_service import update_messages
from app.utils.chat_utils import create_conversation

router = APIRouter()


@profile_time()
@router.post("/chat-stream")
@tiered_rate_limit("chat_messages")
async def chat_stream_endpoint(
Expand All @@ -38,3 +48,61 @@ async def chat_stream_endpoint(
"Access-Control-Allow-Origin": "*",
},
)


@router.post("/save-incomplete-conversation")
@tiered_rate_limit("chat_messages")
async def save_incomplete_conversation(
body: SaveIncompleteConversationRequest,
background_tasks: BackgroundTasks,
user: dict = Depends(get_current_user),
) -> dict:
"""
Save incomplete conversation when stream is cancelled.
"""
conversation_id = body.conversation_id

# Only create new conversation if conversation_id is None
if conversation_id is None:
last_message: MessageDict = {"role": "user", "content": body.message}
selectedTool = body.selectedTool
conversation = await create_conversation(
last_message, user=user, selectedTool=selectedTool
)
conversation_id = conversation.get("conversation_id", "")

# Save the incomplete conversation immediately (not as background task)
# Since user expects to see it right away when they navigate/refresh

# Create user message
user_message = MessageModel(
type="user",
response=body.message,
date=datetime.now(timezone.utc).isoformat(),
fileIds=body.fileIds,
fileData=body.fileData,
selectedTool=body.selectedTool,
toolCategory=body.toolCategory,
)

# Create bot message with incomplete response
bot_message = MessageModel(
type="bot",
response=body.incomplete_response,
date=datetime.now(timezone.utc).isoformat(),
fileIds=body.fileIds,
)

# Save immediately instead of background task
await update_messages(
UpdateMessagesRequest(
conversation_id=conversation_id,
messages=[user_message, bot_message],
),
user=user,
)

return {
"success": True,
"conversation_id": conversation_id,
}
22 changes: 14 additions & 8 deletions backend/app/api/v1/router/mail_webhook.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import json

from fastapi import APIRouter, HTTPException, Request
from fastapi.encoders import jsonable_encoder
from fastapi.exceptions import RequestValidationError
from pydantic import ValidationError

from app.config.loggers import mail_webhook_logger as logger
from app.models.mail_models import EmailWebhookRequest
from app.services.mail_webhook_service import queue_email_processing
from app.utils.pubsub_auth import get_verified_pubsub_request
from fastapi import APIRouter, Depends, HTTPException, Request
from fastapi.encoders import jsonable_encoder
from fastapi.exceptions import RequestValidationError
from pydantic import ValidationError

router = APIRouter()

Expand All @@ -16,13 +16,21 @@
"/mail-webhook/receive",
summary="Process Email Webhook",
)
async def receive_email(request: Request):
async def receive_email(
request: Request,
jwt_payload: dict = Depends(
get_verified_pubsub_request
), # Ensure the request is verified
):
"""
Process incoming email webhook notifications from Gmail.
The webhook payload contains information about new emails.

This endpoint receives the webhook, validates the payload,
and queues a background task for processing.

The request is authenticated using JWT tokens to ensure it
comes from Google Cloud Pub/Sub and not unauthorized entities.
"""
try:
# Log raw request body
Expand All @@ -44,8 +52,6 @@ async def receive_email(request: Request):
detail="Email address and history ID must be provided.",
)

logger.info(f"Parsed: email={email_address}, historyId={history_id}")

# Use service to queue email processing
return await queue_email_processing(email_address, history_id)

Expand Down
Loading