-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Gepardec/mega#735] Add endpoint for Mail automatism
- Loading branch information
Showing
3 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/com/gepardec/mega/rest/api/MailResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.gepardec.mega.rest.api; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.Response; | ||
import org.eclipse.microprofile.openapi.annotations.Operation; | ||
import org.eclipse.microprofile.openapi.annotations.tags.Tag; | ||
|
||
@Path("/mail") | ||
@Tag(name = "MailResource") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public interface MailResource { | ||
|
||
@Operation(operationId = "sendReminder", description = "Sends reminder emails to affected employees.") | ||
@GET | ||
@Path("/sendReminder") | ||
Response sendReminder(); | ||
|
||
@Operation(operationId = "retrieveZepEmailsFromInbox", description = "Webhook for new emails from ZEP to trigger comment creation.") | ||
@GET | ||
@Path("/retrieveZepEmails") | ||
Response retrieveZepEmailsFromInbox(); | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/com/gepardec/mega/rest/impl/MailResourceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.gepardec.mega.rest.impl; | ||
|
||
import com.gepardec.mega.notification.mail.ReminderEmailSender; | ||
import com.gepardec.mega.notification.mail.receiver.MailReceiver; | ||
import com.gepardec.mega.rest.api.MailResource; | ||
import jakarta.enterprise.context.RequestScoped; | ||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.core.Response; | ||
import org.slf4j.Logger; | ||
|
||
@RequestScoped | ||
public class MailResourceImpl implements MailResource { | ||
|
||
@Inject | ||
ReminderEmailSender reminderEmailSender; | ||
|
||
@Inject | ||
MailReceiver mailReceiver; | ||
|
||
@Inject | ||
Logger logger; | ||
|
||
@Override | ||
public Response sendReminder() { | ||
try { | ||
reminderEmailSender.sendReminder(); | ||
} catch (Exception e) { | ||
logger.error(e.getMessage()); | ||
return Response.serverError().entity(e.getMessage()).build(); | ||
} | ||
|
||
return Response.ok().build(); | ||
} | ||
|
||
@Override | ||
public Response retrieveZepEmailsFromInbox() { | ||
try { | ||
mailReceiver.retrieveZepEmailsFromInbox(); | ||
} catch (Exception e) { | ||
logger.error(e.getMessage()); | ||
return Response.serverError().entity(e.getMessage()).build(); | ||
} | ||
|
||
return Response.ok().build(); | ||
} | ||
} |