@gonzih/cc-tg 0.9.8 → 0.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/notifier.js +7 -3
- package/package.json +1 -1
package/dist/notifier.js
CHANGED
|
@@ -90,10 +90,13 @@ export function startNotifier(bot, chatId, namespace, redis, handleUserMessage,
|
|
|
90
90
|
}
|
|
91
91
|
if (channel === incomingChannel) {
|
|
92
92
|
let content = message;
|
|
93
|
+
let originalTimestamp;
|
|
93
94
|
try {
|
|
94
95
|
const parsed = JSON.parse(message);
|
|
95
96
|
if (parsed.content)
|
|
96
97
|
content = parsed.content;
|
|
98
|
+
if (parsed.timestamp)
|
|
99
|
+
originalTimestamp = parsed.timestamp;
|
|
97
100
|
}
|
|
98
101
|
catch {
|
|
99
102
|
// raw string message — use as-is
|
|
@@ -105,13 +108,14 @@ export function startNotifier(bot, chatId, namespace, redis, handleUserMessage,
|
|
|
105
108
|
bot.sendMessage(targetChatId, `📱 [from UI]: ${content}`).catch((err) => {
|
|
106
109
|
log("warn", "sendMessage (UI echo) failed:", err.message);
|
|
107
110
|
});
|
|
108
|
-
// Log the incoming message
|
|
111
|
+
// Log the incoming message — preserve original timestamp from UI if present
|
|
109
112
|
const inMsg = {
|
|
110
113
|
id: `ui-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
|
|
111
|
-
source: "ui",
|
|
114
|
+
source: "ui", // 'ui' distinguishes this from telegram/claude messages
|
|
112
115
|
role: "user",
|
|
113
116
|
content,
|
|
114
|
-
|
|
117
|
+
// ISO 8601 — matches cc-agent-ui /chat/send format; preserve original if present
|
|
118
|
+
timestamp: originalTimestamp ?? new Date().toISOString(),
|
|
115
119
|
chatId: targetChatId,
|
|
116
120
|
};
|
|
117
121
|
writeChatLog(redis, namespace, inMsg);
|