Closed vaibhav-db closed 1 year ago
could accept return a CompletableFuture
? If we made it generic we could return the ResourceResponse in it
TeamsReasponseHandler.accept(Response t)
is Consumer<Response>
method, so we can't return CompletableFuture
. We have option to add ResourceResponse
in ThreadLocal
like we have Action
What do you think about the idea of changing to be a Function
instead of Consumer
?
We need to modify ResponseHandler extends Consumer<Response>, PriorityOrdered
It has huge impact. Many class like ButtonsResponseHandler, ChatListResponseHandler, UserListResponseHandler, ContentResponseConverter, CollectionResponseConverter, WorkResponseConverter,....
you're probably right - are you around next week? Maybe we can brainstorm a bit more then
Yes.. I am in.. If possible can we connect on Monday...
Hi @robmoffat ,
If Microsoft BDK throw error, we have three option:
private BiFunction<? super ResourceResponse, Throwable, ResourceResponse> handleErrorAndStorage(Object out, TeamsAddressable address, Map<String, Object> data, Response t) {
return (rr, e) -> {
if (e != null) {
.....
initErrorHandler();
eh.handleError(e);
Action.CURRENT_ACTION.set(Action.NULL_ACTION);
} else if(rr != null) {
.....
}
return rr;
};
}
Create our own ErrorResourceResponse and return in case of error.
private BiFunction<? super ResourceResponse, Throwable, ResourceResponse> handleErrorAndStorage(Object out, TeamsAddressable address, Map<String, Object> data, Response t) {
return (rr, e) -> {
if (e != null) {
...
initErrorHandler();
eh.handleError(e);
Action.CURRENT_ACTION.set(Action.NULL_ACTION);
rr = new **TeamsErrorResourceResponse**(address.getKey(), e);
} else if(rr != null) {
.....
}
return rr;
};
}
private BiFunction<? super ResourceResponse, Throwable, ResourceResponse> handleErrorAndStorage(Object out, TeamsAddressable address, Map<String, Object> data, Response t) {
return (rr, e) -> {
if (e != null) {
try {
.....
initErrorHandler();
eh.handleError(e);
Action.CURRENT_ACTION.set(Action.NULL_ACTION);
throw e;
}catch (Throwable e1) {
throw new RuntimeException("Passing on exception ", e1);
}
.....
return rr;
};
}
Hi @vaibhav-db,
As usual, it's pretty hard for me to get into the right headspace to figure this out without a call, but thanks for writing this up so clearly.
Can we wait until next Wednesday? Or do you want to do something sooner?
In either case, my suggested next step would be to make sure we have a unit test that we can use to ensure what whatever behaviour we agree on actually happens. We have the retry tests - is this enough? Or do we need some new ones?
speak soon
Hi @robmoffat ,
I think retry tests are enough for all scenario.
If possible can we connect tomorrow at same time? I have tested all three approach look like 2nd is suite for us.
Tomorrow we can connect 10 AM your time, or on Monday.
Raise PR for 2nd approach https://github.com/finos/spring-bot/pull/412
Added testcase.
For Teams return conversation id on message sent
Description of Problem:
When we used
message posted on give channel, but this method doesn't return. Many application want the posted message conversation id.
Potential Solutions:
In TeamsResponseHandler.accept method, we will add conversation id in LocalThread, similar like action then we can pull that conversation id from localThread.