[ADD] AVANCES

parent 29d3aef0
FROM openjdk:21
ARG JAR_FILE=target/*.war
COPY ${JAR_FILE} app.war
ENTRYPOINT ["java","-jar","/app.war"]
\ No newline at end of file
ENTRYPOINT ["java","-jar","app.war"]
\ No newline at end of file
......@@ -35,7 +35,7 @@ public class WhatsappRest {
}
@GetMapping("qr")
public ResponseEntity<?> getQR() {
public ResponseEntity<?> getQR() throws ExecutionException, InterruptedException, TimeoutException {
Whatsapp w = whatsappBean.getWhatsapp();
WhatsappUtils utils = new WhatsappUtils();
......@@ -43,6 +43,7 @@ public class WhatsappRest {
return ResponseEntity.status(Response.SC_OK).body(utils.generateQR());
}
w.connect().get(5, TimeUnit.SECONDS);
if (w.isConnected()) {
return ResponseEntity.status(Response.SC_OK).body("Already connected");
}
......@@ -85,7 +86,8 @@ public class WhatsappRest {
return ResponseEntity.status(Response.SC_OK).body("Not connected");
}
try{
w.connect().get(10, TimeUnit.SECONDS);
w.reconnect().get(5, TimeUnit.SECONDS);
System.out.println(w.store().about());
if (w.isConnected()) {
whatsappService.send(payload, files, w);
return ResponseEntity.status(Response.SC_OK).body(payload);
......
package sacooliveros.whatsappweb.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.lang.NonNull;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class MVCConfig
implements WebMvcConfigurer {
@Override
public void addCorsMappings(@NonNull CorsRegistry registry) {
registry.addMapping("/**")
.allowedMethods("HEAD", "GET", "PUT", "POST", "DELETE", "PATCH");
}
}
\ No newline at end of file
spring.application.name=whatsappweb
server.port=8083
\ No newline at end of file
#server.address=127.0.0.1
server.port=8082
server.address=0.0.0.0
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment