fix: lates
Some checks are pending
CI - Production Readiness / Verify (push) Waiting to run

This commit is contained in:
2026-04-21 20:37:59 +07:00
parent f48c87e36d
commit 137edc12b7
15 changed files with 846 additions and 23 deletions

View File

@ -19,7 +19,46 @@ export type AuthSession = {
};
export const SESSION_COOKIE = "wa_inbox_session";
const SESSION_TTL_SECONDS = 60 * 60 * 24 * 7;
const DEFAULT_SESSION_TTL_SECONDS = 60 * 60 * 24 * 7;
const SESSION_TTL_SECONDS = getConfiguredSessionTtlSeconds(process.env.SESSION_TTL_SECONDS);
export const SESSION_COOKIE_DOMAIN = process.env.SESSION_COOKIE_DOMAIN?.trim() || "";
export const SESSION_COOKIE_SECURE_ENV = process.env.COOKIE_SECURE?.trim().toLowerCase() || "";
function getConfiguredSessionTtlSeconds(raw: string | undefined) {
if (typeof raw === "string" && raw.trim().length > 0) {
const parsed = Number(raw.trim());
if (Number.isFinite(parsed) && parsed > 0) {
return Math.floor(parsed);
}
}
const legacyHours = Number(process.env.SESSION_TTL_HOURS);
if (Number.isFinite(legacyHours) && legacyHours > 0) {
return Math.floor(legacyHours * 60 * 60);
}
return DEFAULT_SESSION_TTL_SECONDS;
}
export function getSessionTtlSeconds() {
return SESSION_TTL_SECONDS;
}
function parseCookieDomain() {
if (!SESSION_COOKIE_DOMAIN) {
return undefined;
}
if (SESSION_COOKIE_DOMAIN === "localhost" || SESSION_COOKIE_DOMAIN === "127.0.0.1") {
return undefined;
}
return SESSION_COOKIE_DOMAIN;
}
export function getSessionCookieDomain() {
return parseCookieDomain();
}
const AUTH_SECRET = process.env.AUTH_SECRET;
const SESSION_ITERATIONS = 120000;
@ -238,8 +277,8 @@ export async function parseSessionCookie(raw: string) {
return {
userId,
role: role as UserRole,
tenantId,
role: role as UserRole,
tenantId,
tenantName: "",
fullName: "",
email: "",

View File

@ -330,15 +330,17 @@ export async function getInboxWorkspace({ scope, conversationId, filter = "all"
return {
id: conversation.id,
tenantId: conversation.tenantId,
name: conversation.contact.fullName,
phone: conversation.contact.phoneNumber,
name: conversation.contact?.fullName ?? "Unknown Contact",
phone: conversation.contact?.phoneNumber ?? "-",
snippet: latestMessage?.contentText ?? conversation.subject ?? "No content",
time: formatRelativeDate(conversation.lastMessageAt),
status: mapConversationStatus(conversation.status),
assignee: conversation.assignedUser?.fullName ?? "Unassigned",
assigneeId: conversation.assignedUser?.id ?? null,
channel: conversation.channel.channelName,
tags: conversation.conversationTags.map((item) => item.tag.name),
channel: conversation.channel?.channelName ?? "Unknown Channel",
tags: conversation.conversationTags
.map((item) => item.tag?.name)
.filter((tag): tag is string => Boolean(tag)),
priority: mapConversationPriority(conversation.priority),
contactId: conversation.contactId
} satisfies ConversationSummary;
@ -394,17 +396,19 @@ export async function getInboxWorkspace({ scope, conversationId, filter = "all"
? {
id: fullConversation.id,
tenantId: fullConversation.tenantId,
name: fullConversation.contact.fullName,
phone: fullConversation.contact.phoneNumber,
name: fullConversation.contact?.fullName ?? "Unknown Contact",
phone: fullConversation.contact?.phoneNumber ?? "-",
snippet: fullConversation.subject ?? fullConversation.messages[0]?.contentText ?? "No content",
time: formatRelativeDate(fullConversation.lastMessageAt),
status: mapConversationStatus(fullConversation.status),
assignee: fullConversation.assignedUser?.fullName ?? "Unassigned",
assigneeId: fullConversation.assignedUser?.id ?? null,
channel: fullConversation.channel.channelName,
tags: fullConversation.conversationTags.map((item) => item.tag.name),
channel: fullConversation.channel?.channelName ?? "Unknown Channel",
tags: fullConversation.conversationTags
.map((item) => item.tag?.name)
.filter((tag): tag is string => Boolean(tag)),
priority: mapConversationPriority(fullConversation.priority),
contactId: fullConversation.contact.id,
contactId: fullConversation.contact?.id ?? fullConversation.contactId,
tagJson: JSON.stringify(fullConversation.conversationTags.map((item) => item.tag.name)),
messages: fullConversation.messages
.slice()