Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 28 additions & 0 deletions app/controllers/api/v1/briefings_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module Api
module V1
class BriefingsController < ApplicationController
skip_before_action :verify_authenticity_token

RECIPIENT = "austindanielfrench@gmail.com".freeze

def send_briefing
subject = params[:subject]
sections = params[:sections]

if subject.blank? || sections.blank?
return render json: { error: "Missing required fields: subject, sections" }, status: :unprocessable_entity
end

BriefingMailer.digest(
recipient: RECIPIENT,
subject: subject,
sections: sections.map(&:to_unsafe_h)
).deliver_later

render json: { success: true, message: "Briefing email queued for delivery" }
rescue StandardError => e
render json: { error: e.message }, status: :internal_server_error
end
end
end
end
8 changes: 8 additions & 0 deletions app/mailers/briefing_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class BriefingMailer < ApplicationMailer
def digest(recipient:, subject:, sections:)
@sections = sections
@subject = subject

mail(to: recipient, subject: subject)
end
end
56 changes: 56 additions & 0 deletions app/views/briefing_mailer/digest.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><%= @subject %></title>
</head>
<body style="margin: 0; padding: 0; background-color: #1a1a2e; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased;">
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background-color: #1a1a2e;">
<tr>
<td align="center" style="padding: 24px 16px;">
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="max-width: 600px;">
<!-- Header -->
<tr>
<td style="padding: 32px 0 24px 0; text-align: center;">
<h1 style="margin: 0; font-size: 24px; font-weight: 700; color: #e0e0e0; letter-spacing: -0.5px;"><%= @subject %></h1>
<div style="margin-top: 8px; height: 3px; width: 60px; background: linear-gradient(90deg, #533483, #0f3460); border-radius: 2px; display: inline-block;"></div>
</td>
</tr>

<!-- Sections -->
<% @sections.each_with_index do |section, index| %>
<tr>
<td style="padding: 0 0 20px 0;">
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background-color: #16213e; border-radius: 8px; border: 1px solid #0f3460;">
<!-- Section Title -->
<tr>
<td style="padding: 20px 24px 12px 24px; border-bottom: 1px solid rgba(83, 52, 131, 0.3);">
<h2 style="margin: 0; font-size: 16px; font-weight: 600; color: #533483; text-transform: uppercase; letter-spacing: 0.5px;"><%= section[:title] || section["title"] %></h2>
</td>
</tr>
<!-- Section Content -->
<tr>
<td style="padding: 16px 24px 20px 24px; color: #e0e0e0; font-size: 15px; line-height: 1.6;">
<%= raw(section[:content] || section["content"]) %>
</td>
</tr>
</table>
</td>
</tr>
<% end %>

<!-- Footer -->
<tr>
<td style="padding: 24px 0 8px 0; text-align: center; border-top: 1px solid rgba(15, 52, 96, 0.5);">
<p style="margin: 0; font-size: 12px; color: #666; line-height: 1.5;">
Sent by Hermes Agent from austn.net
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
16 changes: 16 additions & 0 deletions app/views/briefing_mailer/digest.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<%= @subject %>
<%= "=" * @subject.length %>

<% @sections.each_with_index do |section, index| %>
<%= (section[:title] || section["title"]).upcase %>
<%= "-" * (section[:title] || section["title"]).length %>

<%= strip_tags(section[:content] || section["content"]) %>

<% unless index == @sections.length - 1 %>
---

<% end %>
<% end %>
--
Sent by Hermes Agent from austn.net
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@
post "images/generate", to: "images#generate" # Sync - blocks until complete
post "images/generate_async", to: "images#generate_async" # Async - returns generation ID
get "images/:id/status", to: "images#status", as: :image_status

# Briefing email endpoint
post "briefings/send", to: "briefings#send_briefing"
end
end

Expand Down
Loading