MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / isDuplicatedEvent

Function isDuplicatedEvent

apps/api/src/utils/deduplicate.ts:4–34  ·  view source on GitHub ↗
({
  ip,
  origin,
  payload,
  projectId,
}: {
  ip: string;
  origin: string;
  payload: Record<string, any>;
  projectId: string;
})

Source from the content-addressed store, hash-verified

2import fastJsonStableHash from 'fast-json-stable-hash';
3
4export async function isDuplicatedEvent({
5 ip,
6 origin,
7 payload,
8 projectId,
9}: {
10 ip: string;
11 origin: string;
12 payload: Record<string, any>;
13 projectId: string;
14}) {
15 const locked = await getLock(
16 `fastify:deduplicate:${fastJsonStableHash.hash(
17 {
18 ...payload,
19 ip,
20 origin,
21 projectId,
22 },
23 'md5',
24 )}`,
25 '1',
26 100,
27 );
28
29 if (locked) {
30 return false;
31 }
32
33 return true;
34}

Callers 1

duplicateHookFunction · 0.90

Calls 1

getLockFunction · 0.90

Tested by

no test coverage detected