Gmail folder auto-advance + /forward command

- Reply-cycle auto-advance: staff reply files the thread to "Awaiting Reply",
  a customer response files it to "Needs Response" (new GMAIL_LABEL_AWAITING_REPLY
  / GMAIL_LABEL_NEEDS_RESPONSE labels + autoAdvanceFolder, which only moves
  threads still in the auto-cycle and leaves hand-filed folders alone)
- /forward: forward a ticket's email to another address (handlers/commands/forward.js
  + forward composition in services/gmail.js)
- Tests for the auto-advance cycle; label fixtures updated for the new labels
This commit is contained in:
2026-06-05 02:46:50 +00:00
parent 0fcffe8d33
commit 6bae3e79b1
10 changed files with 410 additions and 10 deletions

View File

@@ -5,6 +5,7 @@ const { mongoose } = require('../db-connection');
const { CONFIG } = require('../config');
const { extractRawEmail, isStaff, getCleanBody } = require('../utils');
const { getGmailClient, sendGmailReply } = require('../services/gmail');
const { autoAdvanceFolder } = require('../services/gmailLabels');
const { getNotifyDm } = require('../services/staffSettings');
const { logError } = require('../services/debugLog');
@@ -100,6 +101,12 @@ async function handleDiscordReply(m) {
m.author.id,
quote
);
// Staff just replied to the customer → advance to Awaiting Reply (unless the
// thread is manually filed). Fire-and-forget: a label failure must not break
// the reply that already went out.
autoAdvanceFolder(ticket.gmailThreadId, 'AWAITING_REPLY')
.catch(err => logError('autoAdvanceFolder(AWAITING_REPLY)', err).catch(() => {}));
} catch (e) {
console.error('REPLY ERROR:', e);
}