MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / isDuplicate

Function isDuplicate

packages/node-runtime/src/import/incremental-importer.ts:100–114  ·  view source on GitHub ↗
(
  msg: { platformMessageId?: string; timestamp: number; senderPlatformId: string; content: string | null },
  existingPlatformMsgIds: Set<string>,
  existingKeys: Set<string>
)

Source from the content-addressed store, hash-verified

98}
99
100function isDuplicate(
101 msg: { platformMessageId?: string; timestamp: number; senderPlatformId: string; content: string | null },
102 existingPlatformMsgIds: Set<string>,
103 existingKeys: Set<string>
104): boolean {
105 if (msg.platformMessageId) {
106 if (existingPlatformMsgIds.has(msg.platformMessageId)) return true
107 existingPlatformMsgIds.add(msg.platformMessageId)
108 return false
109 }
110 const key = generateMessageKey(msg.timestamp, msg.senderPlatformId, msg.content)
111 if (existingKeys.has(key)) return true
112 existingKeys.add(key)
113 return false
114}
115
116function normalizeTimestamp(timestamp: unknown): number | null {
117 const value = typeof timestamp === 'string' && timestamp.trim() !== '' ? Number(timestamp) : timestamp

Callers 2

analyzeIncrementalImportFunction · 0.85
incrementalImportFunction · 0.85

Calls 2

generateMessageKeyFunction · 0.90
addMethod · 0.45

Tested by

no test coverage detected