Spaces:
Running

axeronis commited on
Commit
82ce87f
·
1 Parent(s): 3ebcffb

Refactor: Remove hardcoded company names for true multi-tenancy

Browse files

- email.py: Use settings.APP_NAME instead of 'MicroFunnel Studio'
- booking_service.py: Use tenant.business_name in Google Calendar descriptions
- notification_service.py: Use settings.FRONTEND_URL for dynamic links
- Enables each tenant/deployment to have custom branding
- Supports white-label deployments

backend/app/services/booking_service.py CHANGED
@@ -214,8 +214,9 @@ class BookingService:
214
 
215
  # Fetch lead details
216
  lead = await session.get(Lead, lead_id)
 
217
  summary = f"Meeting with {lead.name} ({service.name})"
218
- description = f"MicroFunnel Booking\nLead: {lead.name}\nPhone: {lead.whatsapp_id}\nService: {service.name}"
219
 
220
  # TODO: If lead has email, add as attendee?
221
  # attendees = [lead.email] if lead.email else []
 
214
 
215
  # Fetch lead details
216
  lead = await session.get(Lead, lead_id)
217
+ tenant_name = tenant.business_name or tenant.name or "Meeting"
218
  summary = f"Meeting with {lead.name} ({service.name})"
219
+ description = f"{tenant_name} - {service.name}\nКлиент: {lead.name}\nТелефон: {lead.whatsapp_id}"
220
 
221
  # TODO: If lead has email, add as attendee?
222
  # attendees = [lead.email] if lead.email else []
backend/app/services/email.py CHANGED
@@ -129,7 +129,7 @@ class EmailService:
129
 
130
  try:
131
  # 1. Try with configured email
132
- from_addr = f"MicroFunnel Studio <{self.from_email}>"
133
  response = await try_send(from_addr)
134
 
135
  # 2. If rejected (likely domain not verified), try onboarding@resend.dev
@@ -249,7 +249,7 @@ class EmailService:
249
 
250
  <div style="margin-top: 30px; padding-top: 20px; border-top: 1px solid #e5e7eb;">
251
  <p style="color: #6b7280; font-size: 14px;">
252
- This is an automated notification from MicroFunnel AI.
253
  <br>
254
  Please respond to this lead as soon as possible.
255
  </p>
@@ -287,14 +287,14 @@ class EmailService:
287
 
288
  async def send_verification_email(self, to_email: str, code: str) -> bool:
289
  """Send email verification code."""
290
- subject = f"Verify your email - MicroFunnel Studio"
291
 
292
  html_body = f"""
293
  <html>
294
  <body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
295
  <div style="max-width: 600px; margin: 0 auto; padding: 20px;">
296
  <h2 style="color: #2563eb;">Verify your email</h2>
297
- <p>Thanks for signing up for MicroFunnel Studio! Please use the following code to verify your email address:</p>
298
 
299
  <div style="background: #eff6ff; border-left: 4px solid #2563eb; padding: 15px; margin: 20px 0;">
300
  <h1 style="margin: 0; letter-spacing: 5px; color: #1e40af;">{code}</h1>
@@ -324,7 +324,7 @@ class EmailService:
324
 
325
  async def send_password_reset_email(self, to_email: str, code: str) -> bool:
326
  """Send password reset code."""
327
- subject = f"Reset your password - MicroFunnel Studio"
328
 
329
  html_body = f"""
330
  <html>
 
129
 
130
  try:
131
  # 1. Try with configured email
132
+ from_addr = f"{settings.APP_NAME} <{self.from_email}>"
133
  response = await try_send(from_addr)
134
 
135
  # 2. If rejected (likely domain not verified), try onboarding@resend.dev
 
249
 
250
  <div style="margin-top: 30px; padding-top: 20px; border-top: 1px solid #e5e7eb;">
251
  <p style="color: #6b7280; font-size: 14px;">
252
+ This is an automated notification from {settings.APP_NAME}.
253
  <br>
254
  Please respond to this lead as soon as possible.
255
  </p>
 
287
 
288
  async def send_verification_email(self, to_email: str, code: str) -> bool:
289
  """Send email verification code."""
290
+ subject = f"Verify your email - {settings.APP_NAME}"
291
 
292
  html_body = f"""
293
  <html>
294
  <body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
295
  <div style="max-width: 600px; margin: 0 auto; padding: 20px;">
296
  <h2 style="color: #2563eb;">Verify your email</h2>
297
+ <p>Thanks for signing up for {settings.APP_NAME}! Please use the following code to verify your email address:</p>
298
 
299
  <div style="background: #eff6ff; border-left: 4px solid #2563eb; padding: 15px; margin: 20px 0;">
300
  <h1 style="margin: 0; letter-spacing: 5px; color: #1e40af;">{code}</h1>
 
324
 
325
  async def send_password_reset_email(self, to_email: str, code: str) -> bool:
326
  """Send password reset code."""
327
+ subject = f"Reset your password - {settings.APP_NAME}"
328
 
329
  html_body = f"""
330
  <html>
backend/app/services/notification_service.py CHANGED
@@ -146,9 +146,9 @@ class NotificationService:
146
  logger.error("⚠️ Set TELEGRAM_NOTIFICATION_TOKEN env var or configure tenant bot token")
147
  return
148
 
149
- # Build notification URL (assuming frontend domain from tenant or env)
150
- # For now use placeholder
151
- notification_url = f"https://app.microfunnel.io/chats?lead={lead.id}"
152
 
153
  message = f"""
154
  🔥 <b>ГОРЯЧИЙ ЛИД!</b>
 
146
  logger.error("⚠️ Set TELEGRAM_NOTIFICATION_TOKEN env var or configure tenant bot token")
147
  return
148
 
149
+ # Build notification URL from settings
150
+ base_url = settings.FRONTEND_URL or "https://app.microfunnel.io"
151
+ notification_url = f"{base_url}/chats?lead={lead.id}"
152
 
153
  message = f"""
154
  🔥 <b>ГОРЯЧИЙ ЛИД!</b>