Skip to content

Commit b0c5fa9

Browse files
committed
only add cv reference number to cache if it was matched
1 parent 770150b commit b0c5fa9

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ Example input
9494

9595
Ok Response
9696

97+
*The content represents if a match was made*
98+
9799
```json
98-
{"type":"ok"}
100+
{"type":"ok","content":true}
99101
```
100102

101103
### `get_secret`

main.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,20 +255,34 @@ func LoopAction(api *API, inputJSON string) (msgType MessageType, msgContent int
255255
return MessageTypeOk, nil
256256
}
257257

258-
api.Cache[referenceNr] = time.Now()
259-
260-
if !api.MockMode {
258+
hasMatch := false
259+
if api.MockMode {
260+
api.Cache[referenceNr] = time.Now()
261+
hasMatch = true
262+
} else {
261263
scanCVBody := json.RawMessage(`{"cv":` + string(input.Content) + `}`)
262264

263-
for _, conn := range api.connections {
264-
err = conn.Post("/api/v1/scraper/scanCV", scanCVBody, nil)
265+
for idx, conn := range api.connections {
266+
var response struct {
267+
HasMatches bool `json:"hasMatches"`
268+
}
269+
270+
err = conn.Post("/api/v1/scraper/scanCV", scanCVBody, &response)
265271
if err != nil {
266272
return returnErr(err)
267273
}
274+
275+
if idx == api.primaryConnection {
276+
hasMatch = response.HasMatches
277+
if hasMatch {
278+
// Only cache the CVs that where matched to something
279+
api.Cache[referenceNr] = time.Now()
280+
}
281+
}
268282
}
269283
}
270284

271-
return MessageTypeOk, nil
285+
return MessageTypeOk, hasMatch
272286
case "get_secret", "get_users_secret", "get_user_secret":
273287
getSecretArgs := struct {
274288
Key string `json:"key"`

0 commit comments

Comments
 (0)