Skip to content

Commit

Permalink
fix(webhooks): fix duplicate logging (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincejv authored Nov 2, 2022
1 parent fbfc813 commit c54fe3b
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,11 @@ public Uni<Void> process(MetaMsgEvtDto evt) {
// process load
.chain(session -> processLoadQuery(login, session, evt))
// login failures/query exceptions
.onFailure(ApiSvcEx.class).call(ex -> handleApiEx(evt, ex))
// failures to send response to messenger
.onFailure().invoke(this::handleMsgEx)
.replaceWithVoid();
.onFailure(ApiSvcEx.class).recoverWithUni(ex -> handleApiEx(evt, ex));
})
.onFailure(ex -> ex instanceof MongoWriteException wEx &&
wEx.getError().getCategory().equals(ErrorCategory.DUPLICATE_KEY))
.invoke(throwable ->
.recoverWithNull().invoke(throwable ->
Log.warn("Received duplicate mid: " + evt.getMetaMsgId())
);
})
Expand Down Expand Up @@ -134,7 +131,8 @@ private Uni<Void> handleApiEx(MetaMsgEvtDto evt, Throwable ex) {
handleAction = sendMsgrMsg(evt, "Error occurred, please try again");
}

return handleAction.chain(() -> metaMsgrSvc.sendTypingIndicator(evt.getSender(), false).replaceWithVoid());
return handleAction.chain(() -> metaMsgrSvc.sendTypingIndicator(
evt.getSender(), false).replaceWithVoid());
}

private Uni<Void> sendMsgrMsg(MetaMsgEvtDto evt, String msg) {
Expand Down

0 comments on commit c54fe3b

Please sign in to comment.