Skip to content

Commit

Permalink
fix(基础模块): 修复阿里云语音仅拨打一个用户号码的问题 (#597)
Browse files Browse the repository at this point in the history
Co-authored-by: fighter-wang <[email protected]>
  • Loading branch information
fighter-wang and fighter-wang authored Dec 18, 2024
1 parent 647f6ec commit 6e40f6f
Showing 1 changed file with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.jetlinks.community.notify.voice.VoiceProvider;
import org.jetlinks.core.Values;
import org.springframework.util.StringUtils;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;

Expand Down Expand Up @@ -76,17 +77,18 @@ public Provider getProvider() {
@Nonnull
public Mono<Void> send(@Nonnull AliyunVoiceTemplate template, @Nonnull Values context) {

return Mono.<Void>defer(() -> {
if (AliyunVoiceTemplate.TemplateType.voice == template.getTemplateType()) {
return convertVoiceRequest(template, context)
.flatMap(this::handleRequest);
} else {
return convertTtsRequest(template, context)
.flatMap(this::handleRequest);
}
}).doOnEach(ReactiveLogger.onError(err -> {
log.info("发起语音通知失败", err);
})).subscribeOn(Schedulers.boundedElastic());
return Flux.defer(() -> {
if (AliyunVoiceTemplate.TemplateType.voice == template.getTemplateType()) {
return convertVoiceRequest(template, context)
.flatMap(this::handleRequest);
} else {
return convertTtsRequest(template, context)
.flatMap(this::handleRequest);
}
}).doOnEach(ReactiveLogger.onError(err -> {
log.info("发起语音通知失败", err);
})).subscribeOn(Schedulers.boundedElastic())
.then();
}

@Override
Expand Down Expand Up @@ -116,10 +118,9 @@ private Mono<Void> handleRequest(CommonRequest request) {
}


Mono<CommonRequest> convertVoiceRequest(AliyunVoiceTemplate template, Values context){
Flux<CommonRequest> convertVoiceRequest(AliyunVoiceTemplate template, Values context){
return template
.getCalledNumber(context.getAllValues())
.next()
.map(calledNumber -> {
CommonRequest request = convert(template);
request.putQueryParameter("CalledNumber", calledNumber);
Expand Down

0 comments on commit 6e40f6f

Please sign in to comment.