Replace Logger with Lombok's @Slf4j annotation in ContactEndpoint and update log method calls.

This commit is contained in:
akastijn 2025-08-08 21:01:34 +02:00
parent 81b53cd1f8
commit 003c75c391

View File

@ -3,6 +3,7 @@ package com.alttd.communication.contact;
import com.alttd.AltitudeBot; import com.alttd.AltitudeBot;
import com.alttd.communication.formData.ContactFormData; import com.alttd.communication.formData.ContactFormData;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageEmbed; import net.dv8tion.jda.api.entities.MessageEmbed;
@ -14,26 +15,25 @@ import org.springframework.web.bind.annotation.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@Slf4j
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@RestController @RestController
@RequestMapping("/api/contact") @RequestMapping("/api/contact")
public class ContactEndpoint { public class ContactEndpoint {
private static final Logger logger = LoggerFactory.getLogger(ContactEndpoint.class);
@PostMapping("/submitContactForm") @PostMapping("/submitContactForm")
public CompletableFuture<ResponseEntity<String>> sendFormToDiscord(@Valid @RequestBody ContactFormData formData) { public CompletableFuture<ResponseEntity<String>> sendFormToDiscord(@Valid @RequestBody ContactFormData formData) {
logger.debug("Sending form to Discord: " + formData); log.debug("Sending form to Discord: {}", formData);
MessageEmbed messageEmbed = formData.toMessageEmbed(); MessageEmbed messageEmbed = formData.toMessageEmbed();
Guild guild = AltitudeBot.getInstance().getJDA().getGuildById(514920774923059209L); Guild guild = AltitudeBot.getInstance().getJDA().getGuildById(514920774923059209L);
if (guild == null) { if (guild == null) {
logger.error("Unable to retrieve staff guild"); log.error("Unable to retrieve staff guild");
return CompletableFuture.completedFuture(ResponseEntity.internalServerError().body("Failed to submit form to Discord")); return CompletableFuture.completedFuture(ResponseEntity.internalServerError().body("Failed to submit form to Discord"));
} }
TextChannel channel = guild.getChannelById(TextChannel.class, 514922567883292673L); TextChannel channel = guild.getChannelById(TextChannel.class, 514922567883292673L);
if (channel == null) { if (channel == null) {
logger.error("Unable to retrieve contact form channel"); log.error("Unable to retrieve contact form channel");
return CompletableFuture.completedFuture(ResponseEntity.internalServerError().body("Failed to submit form to Discord")); return CompletableFuture.completedFuture(ResponseEntity.internalServerError().body("Failed to submit form to Discord"));
} }
@ -43,7 +43,7 @@ public class ContactEndpoint {
if (complete != null) if (complete != null)
return ResponseEntity.ok(""); return ResponseEntity.ok("");
} catch (Exception exception) { } catch (Exception exception) {
logger.error("Failed to send message to Discord", exception); log.error("Failed to send message to Discord", exception);
} }
return ResponseEntity.internalServerError().body("Failed to submit form to Discord"); return ResponseEntity.internalServerError().body("Failed to submit form to Discord");
}); });