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
2 changes: 1 addition & 1 deletion apps/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@profullstack/myna",
"version": "0.56.0",
"version": "0.56.1",
"description": "A terminal social media manager. Log in, compose, schedule and post to every network from one TUI.",
"license": "MIT",
"type": "module",
Expand Down
6 changes: 3 additions & 3 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@profullstack/myna-core",
"version": "0.56.0",
"version": "0.56.1",
"description": "Network adapters, credential vault, scheduling and the AI writer behind myna.",
"license": "MIT",
"type": "module",
Expand Down
16 changes: 11 additions & 5 deletions packages/core/src/core/mail/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,13 @@ export function emailQueueStartupProblems(env: Record<string, string | undefined
let warnedSmtpDirect = false;

/**
* Every Resend and Gmail send goes through the account-scoped BullMQ queue,
* including newsletters, one-off CLI sends and other callers of resolveSender.
* Missing Redis fails closed; never silently fall back to direct delivery.
* Every Gmail send goes through the account-scoped BullMQ queue, including
* newsletters, one-off CLI sends and other callers of resolveSender. Missing
* Redis fails closed for Gmail; never silently fall back to direct delivery.
*
* Resend joins the queue only when EMAIL_QUEUE_REDIS_URL is set. Without it,
* Resend sends directly through its API, as it did before the queue existed:
* an install with no queue worker deployed can still send.
*
* Non-Google SMTP senders (e.g. Forward Email mailboxes) join the queue only
* when BOTH EMAIL_QUEUE_REDIS_URL and EMAIL_QUEUE_ENCRYPTION_KEY are set, so a
Expand All @@ -138,7 +142,9 @@ let warnedSmtpDirect = false;
*/
function queueGuard(sender: MailSender, smtpHost = ""): MailSender {
const google = isGoogleSender(sender, smtpHost);
const mustQueue = sender.type === "resend" || google;
const resendQueued = sender.type === "resend" && Boolean(process.env.EMAIL_QUEUE_REDIS_URL?.trim());
const mustQueue = resendQueued || google;
if (sender.type === "resend" && !resendQueued) return sender;
if (!mustQueue) {
if (sender.type !== "smtp") return sender;
const ready = Boolean(process.env.EMAIL_QUEUE_REDIS_URL?.trim() && process.env.EMAIL_QUEUE_ENCRYPTION_KEY?.trim());
Expand All @@ -155,7 +161,7 @@ function queueGuard(sender: MailSender, smtpHost = ""): MailSender {
batchSize: 1,
send: async (message, context) => {
const url = process.env.EMAIL_QUEUE_REDIS_URL ?? (mustQueue ? process.env.REDIS_URL : undefined) ?? "";
if (!url) return { ok: false, retryable: true, status: 429, error: "Email queue requires EMAIL_QUEUE_REDIS_URL (Redis); Gmail/Resend direct sending is disabled." };
if (!url) return { ok: false, retryable: true, status: 429, error: "Email queue requires EMAIL_QUEUE_REDIS_URL (Redis); Gmail direct sending is disabled." };
const problems = emailQueueStartupProblems({ ...process.env, EMAIL_QUEUE_REDIS_URL: url });
if (problems.length) {
// Same shape as "queue unavailable": a newsletter stops at the first one instead of burning the list.
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
* binary reporting the wrong version, and nothing would fail. A test asserts
* this matches the package.json it is published under.
*/
export const VERSION = "0.56.0";
export const VERSION = "0.56.1";
21 changes: 21 additions & 0 deletions packages/core/test/mail-send.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,27 @@ test("non-Google SMTP stays direct without the queue env and joins the queue whe
}
}, 20_000);

test("Resend sends directly without EMAIL_QUEUE_REDIS_URL and joins the queue when it is set", async () => {
const saved = { url: process.env.EMAIL_QUEUE_REDIS_URL, key: process.env.EMAIL_QUEUE_ENCRYPTION_KEY };
try {
delete process.env.EMAIL_QUEUE_REDIS_URL;
delete process.env.EMAIL_QUEUE_ENCRYPTION_KEY;
saveMailProvider({ id: "rs", type: "resend", from: "News <news@example.com>" }, "re_supersecret");
const direct = resolveSender("rs");
expect("google" in direct).toBe(false); // the plain Resend provider, no queue wrapper
expect(direct.type).toBe("resend");
process.env.EMAIL_QUEUE_REDIS_URL = "redis://127.0.0.1:1";
const queued = resolveSender("rs");
expect("google" in queued).toBe(true);
const result = await queued.send({ to: "a@example.net", subject: "s", text: "t" });
expect(result.ok).toBe(false);
expect(result.error).toContain("no direct send attempted");
} finally {
if (saved.url === undefined) delete process.env.EMAIL_QUEUE_REDIS_URL; else process.env.EMAIL_QUEUE_REDIS_URL = saved.url;
if (saved.key === undefined) delete process.env.EMAIL_QUEUE_ENCRYPTION_KEY; else process.env.EMAIL_QUEUE_ENCRYPTION_KEY = saved.key;
}
}, 20_000);

test("a queue without EMAIL_QUEUE_ENCRYPTION_KEY is reported at startup", () => {
expect(emailQueueStartupProblems({})).toEqual([]);
expect(emailQueueStartupProblems({ EMAIL_QUEUE_REDIS_URL: "redis://x" }).join(" ")).toContain("EMAIL_QUEUE_ENCRYPTION_KEY is not set");
Expand Down
2 changes: 1 addition & 1 deletion packages/mcp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@profullstack/myna-mcp",
"version": "0.56.0",
"version": "0.56.1",
"description": "MCP server for myna. Lets an agent post, schedule and read across every connected social account.",
"license": "MIT",
"type": "module",
Expand Down
Loading