Skip to content

Commit 8020a03

Browse files
d-gubertCopilot
andcommitted
fix: message sent count
Co-authored-by: Copilot <copilot@github.com>
1 parent 7ce9c75 commit 8020a03

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

apps/meteor/app/lib/server/lib/processDirectEmail.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ export const processDirectEmail = async function (email: ParsedMail): Promise<vo
109109
}
110110
}
111111

112-
metrics.messagesSent.inc(); // TODO This line needs to be moved to it's proper place. See the comments on: https://github.com/RocketChat/Rocket.Chat/pull/5736
113-
metrics.messagesSentTotal.inc();
114-
115112
const message: Pick<IMessage, 'ts' | 'msg' | 'groupable' | 'rid' | 'sentByEmail' | 'tmid'> = {
116113
ts: tsDiff < 10000 ? ts : new Date(),
117114
msg,
@@ -121,5 +118,10 @@ export const processDirectEmail = async function (email: ParsedMail): Promise<vo
121118
rid: prevMessage.rid,
122119
};
123120

124-
return sendMessage(user, message, roomInfo);
121+
const result = await sendMessage(user, message, roomInfo);
122+
123+
metrics.messagesSent.inc();
124+
metrics.messagesSentTotal.inc();
125+
126+
return result;
125127
};

apps/meteor/app/lib/server/methods/sendMessage.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,12 @@ export async function executeSendMessage(
105105
}
106106
}
107107

108-
metrics.messagesSent.inc(); // TODO This line needs to be moved to it's proper place. See the comments on: https://github.com/RocketChat/Rocket.Chat/pull/5736
108+
const result = await sendMessage(user, message, room, { previewUrls: extraInfo?.previewUrls });
109+
110+
metrics.messagesSent.inc();
109111
metrics.messagesSentTotal.inc();
110-
return await sendMessage(user, message, room, { previewUrls: extraInfo?.previewUrls });
112+
113+
return result;
111114
} catch (err: any) {
112115
SystemLogger.error({ msg: 'Error sending message:', err });
113116

0 commit comments

Comments
 (0)