fix gmail scan null results
This commit is contained in:
@@ -3,11 +3,9 @@ package com.safeqr.app.qrcode.controller;
|
|||||||
import static com.safeqr.app.constants.APIConstants.*;
|
import static com.safeqr.app.constants.APIConstants.*;
|
||||||
import static com.safeqr.app.constants.CommonConstants.*;
|
import static com.safeqr.app.constants.CommonConstants.*;
|
||||||
import com.safeqr.app.qrcode.dto.request.QRCodePayload;
|
import com.safeqr.app.qrcode.dto.request.QRCodePayload;
|
||||||
import com.safeqr.app.qrcode.dto.RedirectCountResponse;
|
|
||||||
import com.safeqr.app.qrcode.dto.response.BaseScanResponse;
|
import com.safeqr.app.qrcode.dto.response.BaseScanResponse;
|
||||||
import com.safeqr.app.qrcode.entity.QRCodeTypeEntity;
|
import com.safeqr.app.qrcode.entity.QRCodeTypeEntity;
|
||||||
import com.safeqr.app.qrcode.service.QRCodeTypeService;
|
import com.safeqr.app.qrcode.service.QRCodeTypeService;
|
||||||
import com.safeqr.app.qrcode.service.RedirectCountService;
|
|
||||||
import com.safeqr.app.qrcode.service.URLVerificationService;
|
import com.safeqr.app.qrcode.service.URLVerificationService;
|
||||||
import com.safeqr.app.qrcode.service.VirusTotalService;
|
import com.safeqr.app.qrcode.service.VirusTotalService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -35,9 +33,6 @@ public class QRCodeTypeController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private VirusTotalService virusTotalService;
|
private VirusTotalService virusTotalService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RedirectCountService redirectCountService;
|
|
||||||
|
|
||||||
@GetMapping(value = API_URL_QRCODE_GET_ALL)
|
@GetMapping(value = API_URL_QRCODE_GET_ALL)
|
||||||
public ResponseEntity<List<QRCodeTypeEntity>> getAllTypes() {
|
public ResponseEntity<List<QRCodeTypeEntity>> getAllTypes() {
|
||||||
return ResponseEntity.ok(qrCodeTypeService.getAllTypes());
|
return ResponseEntity.ok(qrCodeTypeService.getAllTypes());
|
||||||
@@ -79,9 +74,5 @@ public class QRCodeTypeController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(API_URL_QRCODE_REDIRECT_COUNT)
|
|
||||||
public ResponseEntity<RedirectCountResponse> checkRedirects(@RequestBody QRCodePayload payload) {
|
|
||||||
return ResponseEntity.ok(redirectCountService.countRedirects(payload).block());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.safeqr.app.qrcode.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class RedirectCountResponse {
|
|
||||||
private int redirectCount;
|
|
||||||
private String message;
|
|
||||||
}
|
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
package com.safeqr.app.qrcode.entity;
|
package com.safeqr.app.qrcode.entity;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
@@ -39,6 +40,7 @@ public class QRCodeEntity {
|
|||||||
@Column(name = "created_at", insertable = false, updatable = false)
|
@Column(name = "created_at", insertable = false, updatable = false)
|
||||||
private LocalDateTime createdAt;
|
private LocalDateTime createdAt;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||||
@Column(name = "result_category")
|
@Column(name = "result_category")
|
||||||
private String result = CLASSIFY_UNKNOWN;
|
private String result = CLASSIFY_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import java.util.UUID;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class URLEntity {
|
public class URLEntity {
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||||
@Column(name="classifications")
|
@Column(name="classifications")
|
||||||
private String classifications;
|
private String classifications;
|
||||||
|
|
||||||
|
|||||||
@@ -138,6 +138,9 @@ public class QRCodeTypeService {
|
|||||||
QRCodeModel<?> qrCodeModel = qrCodeFactoryProvider.createQRCodeInstance(scannedQR);
|
QRCodeModel<?> qrCodeModel = qrCodeFactoryProvider.createQRCodeInstance(scannedQR);
|
||||||
qrCodeModel.setDetails();
|
qrCodeModel.setDetails();
|
||||||
|
|
||||||
|
// Get classifications based on verifications
|
||||||
|
scannedQR.setResult(qrCodeModel.retrieveClassification());
|
||||||
|
|
||||||
return qrCodeModel;
|
return qrCodeModel;
|
||||||
}
|
}
|
||||||
// Returns Default type as text if it does not fit into any of the category
|
// Returns Default type as text if it does not fit into any of the category
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
|
|
||||||
package com.safeqr.app.qrcode.service;
|
|
||||||
|
|
||||||
import com.safeqr.app.qrcode.dto.request.QRCodePayload;
|
|
||||||
import com.safeqr.app.qrcode.dto.RedirectCountResponse;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
|
||||||
import reactor.core.publisher.Mono;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class RedirectCountService {
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(RedirectCountService.class);
|
|
||||||
|
|
||||||
public Mono<RedirectCountResponse> countRedirects(QRCodePayload payload) {
|
|
||||||
String url = payload.getData();
|
|
||||||
logger.info("RedirectCountService: countRedirects: url={}", url);
|
|
||||||
|
|
||||||
return WebClient.create()
|
|
||||||
.get()
|
|
||||||
.uri("https://google.com")// replace with url when logic is complete
|
|
||||||
.exchangeToMono(response -> {
|
|
||||||
RedirectCountResponse redirectCountResponse = new RedirectCountResponse();
|
|
||||||
redirectCountResponse.setRedirectCount(response.cookies().size());
|
|
||||||
redirectCountResponse.setMessage("Redirect count calculated.");
|
|
||||||
return Mono.just(redirectCountResponse);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -31,6 +31,10 @@ public class SMSVerificationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void parseSMSString(SMSEntity smsEntity, String smsto) throws IllegalArgumentException{
|
public void parseSMSString(SMSEntity smsEntity, String smsto) throws IllegalArgumentException{
|
||||||
|
// Validate the string format
|
||||||
|
if (smsto == null || smsto.isEmpty()) {
|
||||||
|
throw new InvalidFormatExceptions("sms cannot be null or empty.");
|
||||||
|
}
|
||||||
// Remove the "SMSTO:" prefix
|
// Remove the "SMSTO:" prefix
|
||||||
String data = smsto.substring(6);
|
String data = smsto.substring(6);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user