Skip to content

Commit

Permalink
fix(msgr-reply): enhance typing indicators and user experience (#18) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
vincejv authored Nov 2, 2022
1 parent a498ef5 commit fbfc813
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ public Uni<Void> process(MetaMsgEvtDto evt) {
return loginApi.webhookAuthenticate(login)
// process load
.chain(session -> processLoadQuery(login, session, evt))
// login failures
// login failures/query exceptions
.onFailure(ApiSvcEx.class).call(ex -> handleApiEx(evt, ex))
// failures to send messenger
// failures to send response to messenger
.onFailure().invoke(this::handleMsgEx)
.replaceWithVoid();
})
Expand Down Expand Up @@ -121,12 +121,20 @@ private void handleMsgEx(Throwable sendMsgEx) {
private Uni<Void> handleApiEx(MetaMsgEvtDto evt, Throwable ex) {
Log.error("Error while processing evt: " + evt.getMetaMsgId(), ex);
var apiSvcEx = (ApiSvcEx) ex;
Uni<Void> handleAction;

if (!HttpResponseStatus.INTERNAL_SERVER_ERROR.equals(apiSvcEx.getHttpResponseStatus())) {
return sendMsgrMsg(evt,
apiSvcEx.getJsonResponse(RespDto.class).getError());
var jsonResponse = apiSvcEx.getJsonResponse(RespDto.class);
if (jsonResponse != null && StringUtils.isNotBlank(jsonResponse.getError())) {
handleAction = sendMsgrMsg(evt, jsonResponse.getError());
} else {
handleAction = sendMsgrMsg(evt, "Error occurred, please try again");
}
} else {
return sendMsgrMsg(evt, "Error occurred, please try again");
handleAction = sendMsgrMsg(evt, "Error occurred, please try again");
}

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

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

0 comments on commit fbfc813

Please sign in to comment.