Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix: missing projectId in WS broadcast

tiran1333b60821cdf28
diff --git a/apps/api/src/task/controllers/import-tasks.ts b/apps/api/src/task/controllers/import-tasks.ts
index 1c5def3e6..dae49e3ab 100644
--- a/apps/api/src/task/controllers/import-tasks.ts
+++ b/apps/api/src/task/controllers/import-tasks.ts
@@ -20,7 +20,11 @@ export type ImportTask = {
userId?: string | null;
};
-async function importTasks(projectId: string, tasksToImport: ImportTask[]) {
+async function importTasks(
+ projectId: string,
+ tasksToImport: ImportTask[],
+ currentUserId?: string,
+) {
const project = await db.query.projectTable.findFirst({
where: eq(projectTable.id, projectId),
});
@@ -72,8 +76,10 @@ async function importTasks(projectId: string, tasksToImport: ImportTask[]) {
if (createdTask) {
await publishEvent("task.created", {
+ ...createdTask,
taskId: createdTask.id,
userId: createdTask.userId ?? "",
+ currentUserId: currentUserId ?? "",
type: "create",
content: "imported the task",
});
diff --git a/apps/api/src/task/index.ts b/apps/api/src/task/index.ts
index 503d0bff5..a1ed37776 100644
--- a/apps/api/src/task/index.ts
+++ b/apps/api/src/task/index.ts
@@ -409,8 +409,9 @@ const task = new Hono<{
async (c) => {
const { projectId } = c.req.valid("param");
const { tasks } = c.req.valid("json");
+ const currentUserId = c.get("userId");
- const result = await importTasks(projectId, tasks);
+ const result = await importTasks(projectId, tasks, currentUserId);
return c.json(result);
},
diff --git a/apps/api/src/ws/index.ts b/apps/api/src/ws/index.ts
index 0cd2dfc39..3f59ea4e8 100644
--- a/apps/api/src/ws/index.ts
+++ b/apps/api/src/ws/index.ts
@@ -244,6 +244,8 @@ for (const eventName of taskUpdateEvents) {
subscribeToEvent<TaskEvent>(eventName, async (data) => {
const { projectId, initiatorId } = data;
const taskId = data.taskId;
+
+ if (!projectId || !taskId) return;
let type: string;
switch (eventName) {
case "task.created":