added replyall, cc, bcc etc

This commit is contained in:
Arjun 2026-05-23 08:51:08 +05:30
parent 04e756d17e
commit 3a27c2ebd6
5 changed files with 375 additions and 27 deletions

View file

@ -1234,6 +1234,8 @@ async function performSync() {
export interface SendReplyOptions {
threadId: string;
to: string;
cc?: string;
bcc?: string;
subject: string;
bodyHtml: string;
bodyText: string;
@ -1246,6 +1248,13 @@ export interface SendReplyResult {
error?: string;
}
/** The connected Gmail address (cached). Used by the composer to exclude "me" from reply-all. */
export async function getAccountEmail(): Promise<string | null> {
const auth = await GoogleClientFactory.getClient();
if (!auth) return null;
return getUserEmail(auth);
}
function encodeRfc2047(text: string): string {
// Only encode if non-ASCII chars present.
// eslint-disable-next-line no-control-regex
@ -1265,6 +1274,8 @@ export async function sendThreadReply(opts: SendReplyOptions): Promise<SendReply
const headers: string[] = [];
headers.push(`From: ${userEmail}`);
headers.push(`To: ${opts.to}`);
if (opts.cc?.trim()) headers.push(`Cc: ${opts.cc.trim()}`);
if (opts.bcc?.trim()) headers.push(`Bcc: ${opts.bcc.trim()}`);
headers.push(`Subject: ${encodeRfc2047(opts.subject)}`);
if (opts.inReplyTo) headers.push(`In-Reply-To: ${opts.inReplyTo}`);
if (opts.references) headers.push(`References: ${opts.references}`);

View file

@ -152,6 +152,8 @@ const ipcSchemas = {
req: z.object({
threadId: z.string().min(1),
to: z.string().min(1),
cc: z.string().optional(),
bcc: z.string().optional(),
subject: z.string(),
bodyHtml: z.string(),
bodyText: z.string(),
@ -163,6 +165,12 @@ const ipcSchemas = {
error: z.string().optional(),
}),
},
'gmail:getAccountEmail': {
req: z.object({}),
res: z.object({
email: z.string().nullable(),
}),
},
'gmail:archiveThread': {
req: z.object({ threadId: z.string().min(1) }),
res: z.object({ ok: z.boolean(), error: z.string().optional() }),