Track HiveGrid Cloud planning reference

This commit is contained in:
david committed 2026-06-26 20:48:01 +02:00
1 parent b3d5ea6764
commit e341c5938a
5784 files changed
+1104929 -3

No files matched your search

@@ -0,0 +1,85 @@
import { TFunction } from "i18next";
import NotificationService from "~/modules/notifications/services/.server/NotificationService";
import { createSupportTicket } from "../db/supportTickets.db.server";
import { redactFeedbackText } from "./FeedbackRedaction.server";
const MAX_SUBJECT_LENGTH = 160;
function normalizeSubject(subject: string, message: string) {
const redactedSubject = redactFeedbackText(subject).trim();
if (redactedSubject) {
return redactedSubject.slice(0, MAX_SUBJECT_LENGTH);
}
return redactFeedbackText(message).trim().slice(0, MAX_SUBJECT_LENGTH) || "Support request";
}
async function createInline({
t,
tenantId,
userId,
subject,
message,
fromUrl,
}: {
t: TFunction;
tenantId: string | null;
userId: string | null;
subject: string;
message: string;
fromUrl: string;
}) {
const redactedMessage = redactFeedbackText(message);
const redactedFromUrl = redactFeedbackText(fromUrl);
if (!redactedMessage) {
throw Error(t("feedback.messageRequired"));
}
const ticket = await createSupportTicket({
tenantId,
userId,
source: "inline",
subject: normalizeSubject(subject, redactedMessage),
message: redactedMessage,
fromUrl: redactedFromUrl,
});
await NotificationService.sendToRoles({
channel: "admin-users",
tenantId: null,
notification: {
message: `[New Support Ticket] ${ticket.subject}`,
},
});
return ticket;
}
async function createFromInboundEmail({
tenantId,
fromEmail,
subject,
message,
inboundMessageId,
}: {
tenantId: string | null;
fromEmail: string;
subject: string;
message: string;
inboundMessageId: string;
}) {
const redactedMessage = redactFeedbackText(message);
if (!redactedMessage) {
throw Error("Message is required");
}
return await createSupportTicket({
tenantId,
userId: null,
source: "email",
subject: normalizeSubject(subject, redactedMessage),
message: redactedMessage,
fromEmail: redactFeedbackText(fromEmail),
inboundMessageId,
});
}
export default {
createInline,
createFromInboundEmail,
};