|
@@ -316,7 +316,13 @@ async function processMessage(msg: Message) {
|
|
|
// --- 3. Prepare User Data for MongoDB Batch Update ---
|
|
// --- 3. Prepare User Data for MongoDB Batch Update ---
|
|
|
// userSetData will contain fields to be updated using $set for both new and existing documents.
|
|
// userSetData will contain fields to be updated using $set for both new and existing documents.
|
|
|
// 'project' is now excluded here as it will be handled by $setOnInsert only.
|
|
// 'project' is now excluded here as it will be handled by $setOnInsert only.
|
|
|
- const userSetData: Partial<IUser> = { lastActiveAt: lastActiveAtDateObj };
|
|
|
|
|
|
|
+ //const userSetData: Partial<IUser> = { lastActiveAt: lastActiveAtDateObj };
|
|
|
|
|
+ const userSetData: Partial<IUser> = {};
|
|
|
|
|
+
|
|
|
|
|
+ // 👇 关键修改:仅当事件类型不是 message_receive 时,才更新 lastActiveAt
|
|
|
|
|
+ if (eventType !== "message_receive") {
|
|
|
|
|
+ userSetData.lastActiveAt = lastActiveAtDateObj;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// SetOnInsert fields will only apply when a new document is created
|
|
// SetOnInsert fields will only apply when a new document is created
|
|
|
const setOnInsertFields: any = {
|
|
const setOnInsertFields: any = {
|