Исправление бага в AnswerSaveAction

This commit is contained in:
Struchkov Mark 2023-05-23 16:32:35 +03:00
parent 4ab042c611
commit b4d5999d98
Signed by: upagge
GPG Key ID: D3018BE7BA428CA6

View File

@ -24,28 +24,30 @@ public class AnswerSaveAction<D> implements ActionUnit<AnswerSave<Message, D>, M
final AnswerSave<Message, D> answerSave = unitRequest.getUnit(); final AnswerSave<Message, D> answerSave = unitRequest.getUnit();
final Message message = unitRequest.getMessage(); final Message message = unitRequest.getMessage();
final AnswerSavePreservable<D> preservable = answerSave.getPreservable();
final String personId = message.getFromPersonId();
final CheckSave<Message> checkSave = answerSave.getCheckSave(); final CheckSave<Message> checkSave = answerSave.getCheckSave();
if (checkNotNull(checkSave)) { if (checkNotNull(checkSave)) {
return Uni.createFrom().voidItem() return Uni.createFrom().voidItem()
.onItem().transformToUni( .onItem().transformToUni(
v -> checkSave.check(message) v -> checkSave.check(message)
.onItem().transform( .onItem().ifNotNull().transformToUni(
unit -> { unit -> {
if (checkNotNull(unit)) { if (checkNotNull(unit)) {
return UnitRequest.of(unit, message); return Uni.createFrom().item(UnitRequest.of(unit, message));
} }
return UnitRequest.of(answerSave, message); return getUnitRequestUni(answerSave, message);
} }
) )
); );
} }
return getUnitRequestUni(answerSave, message);
}
private Uni<UnitRequest<MainUnit, Message>> getUnitRequestUni(AnswerSave<Message, D> answerSave, Message message) {
final String personId = message.getFromPersonId();
final AnswerSavePreservable<D> preservable = answerSave.getPreservable();
final PreservableData<D, Message> preservableData = answerSave.getPreservableData(); final PreservableData<D, Message> preservableData = answerSave.getPreservableData();
final Pusher<D> pusher = answerSave.getPusher(); final Pusher<D> pusher = answerSave.getPusher();
return Uni.createFrom().voidItem() return Uni.createFrom().voidItem()
.onItem().transformToUni( .onItem().transformToUni(
v -> { v -> {