-
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.
Merge pull request #85 from Gepardec/feature/735
Feature/735
- Loading branch information
Showing
50 changed files
with
971 additions
and
373 deletions.
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
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
51 changes: 51 additions & 0 deletions
51
src/main/java/com/gepardec/mega/application/configuration/GoogleCloudConfig.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,51 @@ | ||
package com.gepardec.mega.application.configuration; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Inject; | ||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
|
||
import java.util.List; | ||
|
||
@ApplicationScoped | ||
public class GoogleCloudConfig { | ||
|
||
@Inject | ||
@ConfigProperty(name = "mega.google.service-account-key") | ||
String serviceAccountKey; | ||
|
||
@Inject | ||
@ConfigProperty(name = "mega.google.gmail.api.application-name") | ||
String applicationName; | ||
|
||
@Inject | ||
@ConfigProperty(name = "mega.google.gmail.api.workspace-user") | ||
String workspaceUser; | ||
|
||
@Inject | ||
@ConfigProperty(name = "mega.google.gmail.api.label-filter") | ||
List<String> labelFilter; | ||
|
||
@Inject | ||
@ConfigProperty(name = "mega.google.pubsub.topic") | ||
String topicName; | ||
|
||
public String getServiceAccountKey() { | ||
return serviceAccountKey; | ||
} | ||
|
||
public String getApplicationName() { | ||
return applicationName; | ||
} | ||
|
||
public String getWorkspaceUser() { | ||
return workspaceUser; | ||
} | ||
|
||
public List<String> getLabelFilter() { | ||
return labelFilter; | ||
} | ||
|
||
public String getTopicName() { | ||
return topicName; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/gepardec/mega/application/filter/MegaCronSecuritySchemaOASFilter.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,18 @@ | ||
package com.gepardec.mega.application.filter; | ||
|
||
import org.eclipse.microprofile.config.ConfigProvider; | ||
import org.eclipse.microprofile.openapi.OASFilter; | ||
import org.eclipse.microprofile.openapi.models.security.SecurityScheme; | ||
|
||
public class MegaCronSecuritySchemaOASFilter implements OASFilter { | ||
|
||
@Override | ||
public SecurityScheme filterSecurityScheme(SecurityScheme securityScheme) { | ||
if (securityScheme.getType() == SecurityScheme.Type.OAUTH2) { | ||
securityScheme.getFlows().getClientCredentials().tokenUrl(ConfigProvider.getConfig().getConfigValue("mega.oauth.issuer").getValue() + "/protocol/openid-connect/token"); | ||
return OASFilter.super.filterSecurityScheme(securityScheme); | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
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
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
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
27 changes: 27 additions & 0 deletions
27
src/main/java/com/gepardec/mega/application/producer/GoogleCredentialsProducer.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,27 @@ | ||
package com.gepardec.mega.application.producer; | ||
|
||
import com.gepardec.mega.application.configuration.GoogleCloudConfig; | ||
import com.google.api.services.gmail.GmailScopes; | ||
import com.google.auth.oauth2.GoogleCredentials; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.inject.Produces; | ||
import jakarta.inject.Inject; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.IOException; | ||
import java.util.Collections; | ||
|
||
@ApplicationScoped | ||
public class GoogleCredentialsProducer { | ||
|
||
@Inject | ||
GoogleCloudConfig googleCloudConfig; | ||
|
||
@Produces | ||
@ApplicationScoped | ||
public GoogleCredentials produceGoogleCredentials() throws IOException { | ||
return GoogleCredentials.fromStream(new ByteArrayInputStream(googleCloudConfig.getServiceAccountKey().getBytes())) | ||
.createScoped(Collections.singleton(GmailScopes.GMAIL_READONLY)) | ||
.createDelegated(googleCloudConfig.getWorkspaceUser()); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/gepardec/mega/application/schedule/MailSchedules.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,33 @@ | ||
package com.gepardec.mega.application.schedule; | ||
|
||
import com.gepardec.mega.notification.mail.ReminderEmailSender; | ||
import com.gepardec.mega.service.api.GmailService; | ||
import io.quarkus.scheduler.Scheduled; | ||
import jakarta.enterprise.context.Dependent; | ||
import jakarta.inject.Inject; | ||
|
||
@Dependent | ||
public class MailSchedules { | ||
|
||
@Inject | ||
ReminderEmailSender reminderEmailSender; | ||
|
||
@Inject | ||
GmailService gmailService; | ||
|
||
@Scheduled( | ||
identity = "Send E-Mail reminder to users", | ||
cron = "0 0 7 ? * MON-FRI" | ||
) | ||
void sendReminder() { | ||
reminderEmailSender.sendReminder(); | ||
} | ||
|
||
@Scheduled( | ||
identity = "Renew the mailbox watch for the Gmail API every day at 06:00", | ||
cron = "0 0 6 * * ? *" | ||
) | ||
void renewMailboxWatch() { | ||
gmailService.watchInbox(); | ||
} | ||
} |
Oops, something went wrong.