Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

refactor: remove edge function for slack sync

Brad Barbin83436285c718
diff --git a/apps/erp/app/routes/x+/issue+/$id.status.tsx b/apps/erp/app/routes/x+/issue+/$id.status.tsx
index 5dd4c953ea..5cb89543a1 100644
--- a/apps/erp/app/routes/x+/issue+/$id.status.tsx
+++ b/apps/erp/app/routes/x+/issue+/$id.status.tsx
@@ -58,11 +58,11 @@ export async function action({ request, params }: ActionFunctionArgs) {
if (hasSlack) {
await syncIssueStatusToSlack(client, {
- nonConformanceId: id,
companyId,
- previousStatus,
newStatus: status,
- updatedBy: userId,
+ nonConformanceId: id,
+ previousStatus,
+ userId,
});
}
} catch (error) {
diff --git a/apps/erp/app/routes/x+/issue+/task.$id.status.tsx b/apps/erp/app/routes/x+/issue+/task.$id.status.tsx
index 4e6a5a892d..15312ed430 100644
--- a/apps/erp/app/routes/x+/issue+/task.$id.status.tsx
+++ b/apps/erp/app/routes/x+/issue+/task.$id.status.tsx
@@ -52,15 +52,15 @@ export async function action({ request, params }: ActionFunctionArgs) {
const hasSlack = await hasSlackIntegration(client, companyId);
if (hasSlack) {
await syncIssueTaskToSlack(client, {
- nonConformanceId,
- companyId,
- taskType: type as "investigation" | "action" | "approval",
- taskName,
- status,
assignedTo: assignee || undefined,
- completedBy: status === "Completed" ? userId : undefined,
completedAt:
status === "Completed" ? new Date().toISOString() : undefined,
+ companyId,
+ nonConformanceId,
+ status,
+ taskName,
+ taskType: type as "investigation" | "action" | "approval",
+ userId,
});
}
} catch (error) {
diff --git a/packages/database/supabase/functions/slack-document-sync/index.ts b/packages/database/supabase/functions/slack-document-sync/index.ts
deleted file mode 100644
index 035835bb70..0000000000
--- a/packages/database/supabase/functions/slack-document-sync/index.ts
+++ /dev/null
@@ -1,250 +0,0 @@
-import { serve } from "https://deno.land/[email protected]/http/server.ts";
-import { tasks } from "npm:@trigger.dev/[email protected]/v3";
-import { z } from "npm:zod@^3.24.1";
-import {
- slackDocumentAssignmentUpdate,
- slackDocumentCreated,
- slackDocumentStatusUpdate,
- slackDocumentTaskUpdate,
-} from "../../../../jobs/trigger/slack-document-sync.ts";
-import { corsHeaders } from "../lib/headers.ts";
-import { getSupabaseServiceRole } from "../lib/supabase.ts";
-
-const documentTypeSchema = z.enum([
- "nonConformance",
- "quote",
- "salesOrder",
- "job",
- "purchaseOrder",
- "invoice",
- "receipt",
- "shipment",
-]);
-
-type DocumentType = z.infer<typeof documentTypeSchema>;
-
-const metadataSchema = z.record(z.unknown()).optional();
-
-const payloadValidator = z.discriminatedUnion("type", [
- z.object({
- type: z.literal("created"),
- documentType: documentTypeSchema,
- documentId: z.string(),
- companyId: z.string(),
- channelId: z.string(),
- threadTs: z.string(),
- payload: z
- .object({
- metadata: metadataSchema,
- })
- .optional(),
- }),
- z.object({
- type: z.literal("status-update"),
- documentType: documentTypeSchema,
- documentId: z.string(),
- companyId: z.string(),
- payload: z.object({
- previousStatus: z.string(),
- newStatus: z.string(),
- updatedBy: z.string(),
- metadata: metadataSchema,
- }),
- }),
- z.object({
- type: z.literal("task-update"),
- documentType: documentTypeSchema,
- documentId: z.string(),
- companyId: z.string(),
- payload: z.object({
- taskType: z.enum(["investigation", "action", "approval"]),
- taskName: z.string(),
- status: z.string(),
- assignedTo: z.string().optional(),
- completedBy: z.string().optional(),
- completedAt: z.string().optional(),
- notes: z.string().optional(),
- metadata: metadataSchema,
- }),
- }),
- z.object({
- type: z.literal("assignment-update"),
- documentType: documentTypeSchema,
- documentId: z.string(),
- companyId: z.string(),
- payload: z.object({
- previousAssignee: z.string().optional(),
- newAssignee: z.string(),
- updatedBy: z.string(),
- metadata: metadataSchema,
- }),
- }),
- z.object({
- type: z.literal("custom"),
- documentType: documentTypeSchema,
- documentId: z.string(),
- companyId: z.string(),
- payload: z.object({
- customType: z.string(),
- data: z.record(z.unknown()),
- }),
- }),
-]);
-
-type ValidatedPayload = z.infer<typeof payloadValidator>;
-
-interface SlackIntegrationMetadata {
- access_token?: string;
- [key: string]: unknown;
-}
-
-serve(async (req: Request) => {
- if (req.method === "OPTIONS") {
- return new Response("ok", { headers: corsHeaders });
- }
-
- try {
- const body = await req.json();
- const validatedPayload = payloadValidator.parse(body);
- const { type, documentType, documentId, companyId, payload, ...otherData } =
- validatedPayload;
-
- console.log({
- function: "slack-document-sync",
- type,
- documentType,
- documentId,
- companyId,
- });
-
- // Check if Slack integration is enabled for this company
- const serviceRole = await getSupabaseServiceRole(
- req.headers.get("Authorization"),
- req.headers.get("carbon-key") ?? "",
- companyId
- );
-
- const { data: integration } = await serviceRole
- .from("companyIntegration")
- .select("metadata")
- .eq("companyId", companyId)
- .eq("active", true)
- .single();
-
- if (!integration?.metadata) {
- console.log("Slack integration not active for company", companyId);
- return new Response(
- JSON.stringify({
- success: true,
- message: "Slack integration not active",
- }),
- {
- headers: { ...corsHeaders, "Content-Type": "application/json" },
- status: 200,
- }
- );
- }
-
- const metadata = integration.metadata as SlackIntegrationMetadata;
-
- // Check if notifications are enabled for this document type
- const notificationKey = `${documentType}_notifications_enabled`;
- if (metadata[notificationKey] === false) {
- console.log(
- `${documentType} notifications disabled for company`,
- companyId
- );
- return new Response(
- JSON.stringify({
- success: true,
- message: `${documentType} notifications disabled`,
- }),
- {
- headers: { ...corsHeaders, "Content-Type": "application/json" },
- status: 200,
- }
- );
- }
-
- // Trigger the appropriate Trigger.dev job
- switch (type) {
- case "created": {
- const createdData = otherData as Extract<
- ValidatedPayload,
- { type: "created" }
- >;
- await tasks.trigger<typeof slackDocumentCreated>(
- "slack-document-created",
- {
- documentType,
- documentId,
- companyId,
- channelId: createdData.channelId,
- threadTs: createdData.threadTs,
- }
- );
- break;
- }
-
- case "status-update":
- await tasks.trigger<typeof slackDocumentStatusUpdate>(
- "slack-document-status-update",
- {
- documentType,
- documentId,
- companyId,
- ...payload,
- }
- );
- break;
-
- case "task-update":
- await tasks.trigger<typeof slackDocumentTaskUpdate>(
- "slack-document-task-update",
- {
- documentType,
- documentId,
- companyId,
- ...payload,
- }
- );
- break;
-
- case "assignment-update":
- await tasks.trigger<typeof slackDocumentAssignmentUpdate>(
- "slack-document-assignment-update",
- {
- documentType,
- documentId,
- companyId,
- ...payload,
- }
- );
- break;
-
- case "custom":
- // For now, just log custom updates
- console.log(`Custom update for ${documentType}:`, payload);
- break;
-
- default:
- throw new Error(`Invalid type ${type}`);
- }
-
- return new Response(
- JSON.stringify({
- success: true,
- }),
- {
- headers: { ...corsHeaders, "Content-Type": "application/json" },
- status: 200,
- }
- );
- } catch (err) {
- console.error("slack-document-sync error:", err);
- return new Response(JSON.stringify(err), {
- headers: { ...corsHeaders, "Content-Type": "application/json" },
- status: 500,
- });
- }
-});
diff --git a/packages/integrations/src/slack/lib/service.ts b/packages/integrations/src/slack/lib/service.ts
index fbda072e92..b3bafe2216 100644
--- a/packages/integrations/src/slack/lib/service.ts
+++ b/packages/integrations/src/slack/lib/service.ts
@@ -1,6 +1,13 @@
import { getCarbonServiceRole } from "@carbon/auth";
import type { Database } from "@carbon/database";
+import type {
+ slackDocumentAssignmentUpdate,
+ slackDocumentCreated,
+ slackDocumentStatusUpdate,
+ slackDocumentTaskUpdate,
+} from "@carbon/jobs/trigger/slack-document-sync";
import type { SupabaseClient } from "@supabase/supabase-js";
+import { tasks } from "@trigger.dev/sdk/v3";
import { createSlackWebClient } from "./client";
export type DocumentType = "nonConformance";
@@ -244,6 +251,15 @@ export async function getSlackAuth(
};
}
+export async function getSlackUserIdForCarbonUser(
+ client: SupabaseClient<Database>,
+ companyId: string,
+ userId: string
+): Promise<string | null> {
+ const auth = await getSlackAuth(client, companyId, userId);
+ return auth?.slackUserId || null;
+}
+
export async function getSlackDocumentThread(
client: SupabaseClient<Database>,
documentType: DocumentType,
@@ -323,6 +339,7 @@ export async function syncDocumentToSlack(
documentType: DocumentType;
documentId: string;
companyId: string;
+ userId: string;
type:
| "created"
| "status-update"
@@ -333,25 +350,131 @@ export async function syncDocumentToSlack(
}
) {
const serviceRole = getCarbonServiceRole();
- const thread = await getSlackDocumentThread(
- serviceRole,
- data.documentType,
- data.documentId,
- data.companyId
- );
+ const [thread, slackUserId] = await Promise.all([
+ getSlackDocumentThread(
+ serviceRole,
+ data.documentType,
+ data.documentId,
+ data.companyId
+ ),
+ getSlackUserIdForCarbonUser(serviceRole, data.companyId, data.userId),
+ ]);
if (thread.data) {
- return serviceRole.functions.invoke("slack-document-sync", {
- body: {
- documentType: data.documentType,
- documentId: data.documentId,
- companyId: data.companyId,
- type: data.type,
- channelId: thread.data.channelId,
- threadTs: thread.data.threadTs,
- payload: data.payload,
- },
- });
+ try {
+ // Check if Slack integration is enabled for this company
+ const { data: integration } = await serviceRole
+ .from("companyIntegration")
+ .select("metadata")
+ .eq("companyId", data.companyId)
+ .eq("active", true)
+ .single();
+
+ if (!integration?.metadata) {
+ console.log("Slack integration not active for company", data.companyId);
+ return {
+ data: { success: true, message: "Slack integration not active" },
+ error: null,
+ };
+ }
+
+ const metadata = integration.metadata as Record<string, unknown>;
+
+ // Check if notifications are enabled for this document type
+ const notificationKey = `${data.documentType}_notifications_enabled`;
+ if (metadata[notificationKey] === false) {
+ console.log(
+ `${data.documentType} notifications disabled for company`,
+ data.companyId
+ );
+ return {
+ data: {
+ success: true,
+ message: `${data.documentType} notifications disabled`,
+ },
+ error: null,
+ };
+ }
+
+ // Trigger the appropriate Trigger.dev job
+ let result;
+ switch (data.type) {
+ case "created":
+ result = await tasks.trigger<typeof slackDocumentCreated>(
+ "slack-document-created",
+ {
+ documentType: data.documentType,
+ documentId: data.documentId,
+ companyId: data.companyId,
+ channelId: thread.data.channelId,
+ threadTs: thread.data.threadTs,
+ }
+ );
+ break;
+
+ case "status-update":
+ result = await tasks.trigger<typeof slackDocumentStatusUpdate>(
+ "slack-document-status-update",
+ {
+ documentType: data.documentType,
+ documentId: data.documentId,
+ companyId: data.companyId,
+ previousStatus: data.payload.previousStatus,
+ newStatus: data.payload.newStatus,
+ updatedBy: slackUserId || data.payload.updatedBy,
+ }
+ );
+ break;
+
+ case "task-update":
+ result = await tasks.trigger<typeof slackDocumentTaskUpdate>(
+ "slack-document-task-update",
+ {
+ documentType: data.documentType,
+ documentId: data.documentId,
+ companyId: data.companyId,
+ taskType: data.payload.taskType,
+ taskName: data.payload.taskName,
+ status: data.payload.status,
+ assignedTo: data.payload.assignedTo,
+ completedBy: data.payload.completedBy || slackUserId,
+ completedAt: data.payload.completedAt,
+ notes: data.payload.notes,
+ }
+ );
+ break;
+
+ case "assignment-update":
+ result = await tasks.trigger<typeof slackDocumentAssignmentUpdate>(
+ "slack-document-assignment-update",
+ {
+ documentType: data.documentType,
+ documentId: data.documentId,
+ companyId: data.companyId,
+ previousAssignee: data.payload.previousAssignee,
+ newAssignee: data.payload.newAssignee,
+ updatedBy: slackUserId || data.payload.updatedBy,
+ }
+ );
+ break;
+
+ case "custom":
+ // For now, just log custom updates
+ console.log(`Custom update for ${data.documentType}:`, data.payload);
+ return { data: { success: true }, error: null };
+
+ default:
+ throw new Error(`Invalid type ${data.type}`);
+ }
+
+ return { data: { success: true, taskId: result.id }, error: null };
+ } catch (error) {
+ console.error("slack-document-sync error:", error);
+ return {
+ data: null,
+ error: error instanceof Error ? error.message : "Unknown error",
+ };
+ }
}
return { data: null, error: null };
@@ -363,6 +486,7 @@ export async function syncDocumentCreatedToSlack(
documentType: DocumentType;
documentId: string;
companyId: string;
+ userId: string;
channelId: string;
threadTs: string;
metadata?: Record<string, any>;
@@ -372,6 +496,7 @@ export async function syncDocumentCreatedToSlack(
documentType: data.documentType,
documentId: data.documentId,
companyId: data.companyId,
+ userId: data.userId,
type: "created",
payload: {
channelId: data.channelId,
@@ -387,9 +512,9 @@ export async function syncDocumentStatusToSlack(
documentType: DocumentType;
documentId: string;
companyId: string;
+ userId: string;
previousStatus: string;
newStatus: string;
- updatedBy: string;
reason?: string;
metadata?: Record<string, any>;
}
@@ -398,11 +523,13 @@ export async function syncDocumentStatusToSlack(
documentType: data.documentType,
documentId: data.documentId,
companyId: data.companyId,
+ userId: data.userId,
type: "status-update",
payload: {
previousStatus: data.previousStatus,
newStatus: data.newStatus,
- updatedBy: data.updatedBy,
+ updatedBy: data.userId,
+ reason: data.reason,
metadata: data.metadata,
},
});
@@ -414,9 +541,9 @@ export async function syncDocumentAssignmentToSlack(
documentType: DocumentType;
documentId: string;
companyId: string;
+ userId: string;
previousAssignee?: string;
newAssignee: string;
- updatedBy: string;
metadata?: Record<string, any>;
}
) {
@@ -424,11 +551,12 @@ export async function syncDocumentAssignmentToSlack(
documentType: data.documentType,
documentId: data.documentId,
companyId: data.companyId,
+ userId: data.userId,
type: "assignment-update",
payload: {
previousAssignee: data.previousAssignee,
newAssignee: data.newAssignee,
- updatedBy: data.updatedBy,
+ updatedBy: data.userId,
metadata: data.metadata,
},
});
@@ -440,6 +568,7 @@ export async function syncDocumentCustomToSlack(
documentType: DocumentType;
documentId: string;
companyId: string;
+ userId: string;
customType: string;
payload: Record<string, any>;
}
@@ -448,6 +577,7 @@ export async function syncDocumentCustomToSlack(
documentType: data.documentType,
documentId: data.documentId,
companyId: data.companyId,
+ userId: data.userId,
type: "custom",
payload: {
customType: data.customType,
@@ -461,9 +591,9 @@ export async function syncIssueStatusToSlack(
data: {
nonConformanceId: string;
companyId: string;
+ userId: string;
previousStatus: string;
newStatus: string;
- updatedBy: string;
reason?: string;
}
) {
@@ -471,9 +601,10 @@ export async function syncIssueStatusToSlack(
documentType: "nonConformance",
documentId: data.nonConformanceId,
companyId: data.companyId,
+ userId: data.userId,
previousStatus: data.previousStatus,
newStatus: data.newStatus,
- updatedBy: data.updatedBy,
+ reason: data.reason,
});
}
@@ -482,26 +613,27 @@ export async function syncIssueTaskToSlack(
data: {
nonConformanceId: string;
companyId: string;
+ userId: string;
taskType: "investigation" | "action" | "approval";
taskName: string;
status: string;
assignedTo?: string;
- completedBy?: string;
completedAt?: string;
notes?: string;
}
) {
- return syncDocumentCustomToSlack(client, {
+ return syncDocumentToSlack(client, {
documentType: "nonConformance",
documentId: data.nonConformanceId,
companyId: data.companyId,
- customType: "task-update",
+ userId: data.userId,
+ type: "task-update",
payload: {
taskType: data.taskType,
taskName: data.taskName,
status: data.status,
assignedTo: data.assignedTo,
- completedBy: data.completedBy,
+ completedBy: data.status === "Completed" ? data.userId : undefined,
completedAt: data.completedAt,
notes: data.notes,
},
@@ -513,18 +645,18 @@ export async function syncIssueAssignmentToSlack(
data: {
nonConformanceId: string;
companyId: string;
+ userId: string;
previousAssignee?: string;
newAssignee: string;
- updatedBy: string;
}
) {
return syncDocumentAssignmentToSlack(client, {
documentType: "nonConformance",
documentId: data.nonConformanceId,
companyId: data.companyId,
+ userId: data.userId,
previousAssignee: data.previousAssignee,
newAssignee: data.newAssignee,
- updatedBy: data.updatedBy,
});
}
diff --git a/packages/jobs/trigger/slack-document-sync.ts b/packages/jobs/trigger/slack-document-sync.ts
index f2a0e5481d..e35febe7af 100644
--- a/packages/jobs/trigger/slack-document-sync.ts
+++ b/packages/jobs/trigger/slack-document-sync.ts
@@ -501,9 +501,9 @@ async function postToSlackThread(params: {
text?: string;
}) {
const { token, channelId, threadTs, blocks, text } = params;
-
+
const client = new WebClient(token);
-
+
return await client.chat.postMessage({
channel: channelId,
thread_ts: threadTs,
@@ -515,23 +515,22 @@ async function postToSlackThread(params: {
/**
* Format document creation message for Slack
*/
-function formatDocumentCreated(
- data: DocumentData,
- baseUrl: string
-): any[] {
+function formatDocumentCreated(data: DocumentData, baseUrl: string): any[] {
const blocks: any[] = [];
-
+
if (data.documentType === "nonConformance") {
const ncData = data as NonConformanceData;
-
+
blocks.push({
type: "section",
text: {
type: "mrkdwn",
- text: `*Non-Conformance Created: ${ncData.nonConformanceId}*\n${ncData.title || "No title"}`,
+ text: `*Non-Conformance Created: ${ncData.nonConformanceId}*\n${
+ ncData.title || "No title"
+ }`,
},
});
-
+
if (ncData.description) {
blocks.push({
type: "section",
@@ -541,54 +540,56 @@ function formatDocumentCreated(
},
});
}
-
+
const fields: any[] = [];
-
+
if (ncData.status) {
fields.push({
type: "mrkdwn",
text: `*Status:*\n${ncData.status}`,
});
}
-
+
if (ncData.severity) {
fields.push({
type: "mrkdwn",
text: `*Severity:*\n${ncData.severity}`,
});
}
-
+
if (ncData.typeName) {
fields.push({
type: "mrkdwn",
text: `*Type:*\n${ncData.typeName}`,
});
}
-
+
if (ncData.workflowName) {
fields.push({
type: "mrkdwn",
text: `*Workflow:*\n${ncData.workflowName}`,
});
}
-
+
if (fields.length > 0) {
blocks.push({
type: "section",
fields,
});
}
-
+
if (ncData.investigationTypes && ncData.investigationTypes.length > 0) {
blocks.push({
type: "section",
text: {
type: "mrkdwn",
- text: `*Investigation Types:*\n${ncData.investigationTypes.join(", ")}`,
+ text: `*Investigation Types:*\n${ncData.investigationTypes.join(
+ ", "
+ )}`,
},
});
}
-
+
if (ncData.requiredActions && ncData.requiredActions.length > 0) {
blocks.push({
type: "section",
@@ -598,7 +599,7 @@ function formatDocumentCreated(
},
});
}
-
+
blocks.push({
type: "actions",
elements: [
@@ -614,11 +615,11 @@ function formatDocumentCreated(
],
});
}
-
+
blocks.push({
type: "divider",
});
-
+
return blocks;
}
@@ -631,9 +632,9 @@ function formatStatusUpdate(
update: StatusUpdate
): any[] {
const blocks: any[] = [];
-
+
const emoji = getStatusEmoji(update.newStatus);
-
+
blocks.push({
type: "section",
text: {
@@ -641,7 +642,7 @@ function formatStatusUpdate(
text: `${emoji} *Status Updated*\n${documentIdentifier}`,
},
});
-
+
blocks.push({
type: "section",
fields: [
@@ -655,7 +656,7 @@ function formatStatusUpdate(
},
],
});
-
+
if (update.reason) {
blocks.push({
type: "section",
@@ -665,17 +666,19 @@ function formatStatusUpdate(
},
});
}
-
+
blocks.push({
type: "context",
elements: [
{
type: "mrkdwn",
- text: `Updated by ${update.updatedBy} at <!date^${Math.floor(Date.now() / 1000)}^{date_short_pretty} {time}|${new Date().toISOString()}>`,
+ text: `Updated by <@${update.updatedBy}> at <!date^${Math.floor(
+ Date.now() / 1000
+ )}^{date_short_pretty} {time}|${new Date().toISOString()}>`,
},
],
});
-
+
return blocks;
}
@@ -688,13 +691,15 @@ function formatTaskUpdate(
update: TaskUpdate
): any[] {
const blocks: any[] = [];
-
+
const emoji = getTaskStatusEmoji(update.status);
- const taskTypeLabel =
- update.taskType === "investigation" ? "Investigation" :
- update.taskType === "action" ? "Action" :
- "Approval";
-
+ const taskTypeLabel =
+ update.taskType === "investigation"
+ ? "Investigation"
+ : update.taskType === "action"
+ ? "Action"
+ : "Approval";
+
blocks.push({
type: "section",
text: {
@@ -702,7 +707,7 @@ function formatTaskUpdate(
text: `${emoji} *${taskTypeLabel} Task Updated*\n${documentIdentifier}`,
},
});
-
+
const fields: any[] = [
{
type: "mrkdwn",
@@ -713,26 +718,26 @@ function formatTaskUpdate(
text: `*Status:*\n${update.status}`,
},
];
-
+
if (update.assignedTo) {
fields.push({
type: "mrkdwn",
text: `*Assigned To:*\n${update.assignedTo}`,
});
}
-
+
if (update.completedBy) {
fields.push({
type: "mrkdwn",
text: `*Completed By:*\n${update.completedBy}`,
});
}
-
+
blocks.push({
type: "section",
fields,
});
-
+
if (update.notes) {
blocks.push({
type: "section",
@@ -742,7 +747,7 @@ function formatTaskUpdate(
},
});
}
-
+
if (update.completedAt) {
blocks.push({
type: "context",
@@ -754,7 +759,7 @@ function formatTaskUpdate(
],
});
}
-
+
return blocks;
}
@@ -767,7 +772,7 @@ function formatAssignmentUpdate(
update: AssignmentUpdate
): any[] {
const blocks: any[] = [];
-
+
blocks.push({
type: "section",
text: {
@@ -775,36 +780,38 @@ function formatAssignmentUpdate(
text: `👤 *Assignment Updated*\n${documentIdentifier}`,
},
});
-
+
const fields: any[] = [];
-
+
if (update.previousAssignee) {
fields.push({
type: "mrkdwn",
text: `*Previous Assignee:*\n${update.previousAssignee}`,
});
}
-
+
fields.push({
type: "mrkdwn",
text: `*New Assignee:*\n${update.newAssignee}`,
});
-
+
blocks.push({
type: "section",
fields,
});
-
+
blocks.push({
type: "context",
elements: [
{
type: "mrkdwn",
- text: `Updated by ${update.updatedBy} at <!date^${Math.floor(Date.now() / 1000)}^{date_short_pretty} {time}|${new Date().toISOString()}>`,
+ text: `Updated by <@${update.updatedBy}> at <!date^${Math.floor(
+ Date.now() / 1000
+ )}^{date_short_pretty} {time}|${new Date().toISOString()}>`,
},
],
});
-
+
return blocks;
}
@@ -813,17 +820,23 @@ function formatAssignmentUpdate(
*/
function getStatusEmoji(status: string): string {
const statusLower = status.toLowerCase();
-
+
if (statusLower.includes("closed") || statusLower.includes("complete")) {
return "✅";
- } else if (statusLower.includes("progress") || statusLower.includes("review")) {
- return "🔄";
+ } else if (
+ statusLower.includes("progress") ||
+ statusLower.includes("review")
+ ) {
+ return "🚀";
} else if (statusLower.includes("pending") || statusLower.includes("open")) {
return "📋";
- } else if (statusLower.includes("rejected") || statusLower.includes("cancelled")) {
+ } else if (
+ statusLower.includes("rejected") ||
+ statusLower.includes("cancelled")
+ ) {
return "❌";
}
-
+
return "📌";
}
@@ -832,7 +845,7 @@ function getStatusEmoji(status: string): string {
*/
function getTaskStatusEmoji(status: string): string {
const statusLower = status.toLowerCase();
-
+
if (statusLower.includes("completed")) {
return "✅";
} else if (statusLower.includes("progress")) {
@@ -842,7 +855,7 @@ function getTaskStatusEmoji(status: string): string {
} else if (statusLower.includes("pending")) {
return "⏸️";
}
-
+
return "📝";
}