diff --git a/server/logging/logger.ts b/server/logging/logger.ts index 2fce9c034..44d0c1dcc 100644 --- a/server/logging/logger.ts +++ b/server/logging/logger.ts @@ -1,4 +1,5 @@ import chalk from "chalk"; +import { isEmpty } from "lodash"; import winston from "winston"; import env from "@server/env"; import Metrics from "@server/logging/metrics"; @@ -32,10 +33,10 @@ class Logger { : winston.format.combine( winston.format.colorize(), winston.format.printf( - ({ message, level, label }) => + ({ message, level, label, ...extra }) => `${level}: ${ label ? chalk.bold("[" + label + "] ") : "" - }${message}` + }${message} ${isEmpty(extra) ? "" : JSON.stringify(extra)}` ) ), }) diff --git a/server/queues/processors/BaseProcessor.ts b/server/queues/processors/BaseProcessor.ts index b07706824..72c379ce0 100644 --- a/server/queues/processors/BaseProcessor.ts +++ b/server/queues/processors/BaseProcessor.ts @@ -1,7 +1,7 @@ import { Event } from "@server/types"; export default abstract class BaseProcessor { - static applicableEvents: Event["name"][] = []; + static applicableEvents: (Event["name"] | "*")[] = []; public abstract perform(event: Event): Promise; } diff --git a/server/queues/processors/WebsocketsProcessor.ts b/server/queues/processors/WebsocketsProcessor.ts index bd20f9b84..ed7337d51 100644 --- a/server/queues/processors/WebsocketsProcessor.ts +++ b/server/queues/processors/WebsocketsProcessor.ts @@ -294,7 +294,7 @@ export default class WebsocketsProcessor { } case "collections.add_group": { - const group = await Group.findByPk(event.data.groupId); + const group = await Group.findByPk(event.modelId); if (!group) { return; } @@ -320,7 +320,7 @@ export default class WebsocketsProcessor { } case "collections.remove_group": { - const group = await Group.findByPk(event.data.groupId); + const group = await Group.findByPk(event.modelId); if (!group) { return; } diff --git a/server/queues/tasks/InviteReminderTask.ts b/server/queues/tasks/InviteReminderTask.ts index 0b127e964..b10623f73 100644 --- a/server/queues/tasks/InviteReminderTask.ts +++ b/server/queues/tasks/InviteReminderTask.ts @@ -2,14 +2,12 @@ import { subDays } from "date-fns"; import { Op } from "sequelize"; import { sequelize } from "@server/database/sequelize"; import InviteReminderEmail from "@server/emails/templates/InviteReminderEmail"; -import { APM } from "@server/logging/tracing"; import { User } from "@server/models"; import { UserFlag } from "@server/models/User"; import BaseTask, { TaskPriority } from "./BaseTask"; type Props = undefined; -@APM.trace() export default class InviteReminderTask extends BaseTask { public async perform() { const users = await User.scope("invited").findAll({ diff --git a/server/routes/api/collections.ts b/server/routes/api/collections.ts index a76837df6..41781d565 100644 --- a/server/routes/api/collections.ts +++ b/server/routes/api/collections.ts @@ -194,9 +194,9 @@ router.post("collections.add_group", auth(), async (ctx) => { collectionId: collection.id, teamId: collection.teamId, actorId: ctx.state.user.id, + modelId: groupId, data: { name: group.name, - groupId, }, ip: ctx.request.ip, }); @@ -229,9 +229,9 @@ router.post("collections.remove_group", auth(), async (ctx) => { collectionId: collection.id, teamId: collection.teamId, actorId: ctx.state.user.id, + modelId: groupId, data: { name: group.name, - groupId, }, ip: ctx.request.ip, }); diff --git a/server/services/worker.ts b/server/services/worker.ts index b684f91f9..41659892c 100644 --- a/server/services/worker.ts +++ b/server/services/worker.ts @@ -46,7 +46,10 @@ export default function init() { // websockets are a special case on their own queue because they must // only be consumed by the websockets service rather than workers. await websocketQueue.add(job.data); - } else if (ProcessorClass.applicableEvents.includes(event.name)) { + } else if ( + ProcessorClass.applicableEvents.includes(event.name) || + ProcessorClass.applicableEvents.includes("*") + ) { await processorEventQueue.add({ event, name }); } } catch (error) { diff --git a/server/types.ts b/server/types.ts index 38d4d1b2c..a53862a15 100644 --- a/server/types.ts +++ b/server/types.ts @@ -174,9 +174,9 @@ export type CollectionEvent = collectionId: string; teamId: string; actorId: string; + modelId: string; data: { name: string; - groupId: string; }; ip: string; }