-
Notifications
You must be signed in to change notification settings - Fork 0
feat: ajout des notifications #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
emt-coder
wants to merge
5
commits into
stage_2026
Choose a base branch
from
notifications_preferences
base: stage_2026
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
26a6d99
feat: ajout des notifications
emt-coder 2c99fd3
chore: ajout des licences
emt-coder 57acfb3
feat: finalisation des notifications du MCE
emt-coder d8c3931
feat: ajout des licences
emt-coder 00ea2c6
feat: modification des notifications
emt-coder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
80 changes: 80 additions & 0 deletions
80
src/main/java/fr/recia/mce/api/escomceapi/aop/notification/NotificationAspect.java
This file contains hidden or 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,80 @@ | ||
| /* | ||
| * Copyright (C) 2023 GIP-RECIA, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package fr.recia.mce.api.escomceapi.aop.notification; | ||
|
|
||
| import fr.recia.mce.api.escomceapi.aop.notification.configuration.NotificationAspectConfig; | ||
| import fr.recia.notifications.event_rest_client_kafka.HttpNotificationClient; | ||
| import fr.recia.notifications.model_kafka.model.*; | ||
| import lombok.Data; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.aspectj.lang.annotation.After; | ||
| import org.aspectj.lang.annotation.Aspect; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| import java.time.ZonedDateTime; | ||
| import java.time.format.DateTimeFormatter; | ||
| import java.util.List; | ||
| import java.util.Locale; | ||
|
|
||
|
|
||
| @Component | ||
| @Aspect | ||
| @Slf4j | ||
| @Data | ||
| public class NotificationAspect { | ||
| private final HttpNotificationClient notificationClient; | ||
| private final NotificationAspectConfig notificationAspectConfig; | ||
|
|
||
|
|
||
| private static final DateTimeFormatter DATE_TIME_FORMATTER = | ||
| DateTimeFormatter.ofPattern("dd/MM/yyyy 'à' HH:mm", Locale.FRENCH); | ||
|
|
||
| private String buildMessage(String template) { | ||
| return template + ZonedDateTime.now().format(DATE_TIME_FORMATTER); | ||
| } | ||
|
|
||
| @After("execution(* fr.recia.mce.api.escomceapi.ldap.repository.LdapUserDaoImp.updatePassword(..)) && args(uid, newHashedPassword)") | ||
| public void notifPasswordChange(String uid, String newHashedPassword) { | ||
| try { | ||
| final String title = notificationAspectConfig.getTitleMdp(); | ||
| final String message = buildMessage(notificationAspectConfig.getMessageMdp()); | ||
| final List<Channel> channel = List.of(Channel.WEB); | ||
| final String idLink = ""; | ||
| final Priority priority = Priority.HIGH; | ||
| final TargetType targetType = TargetType.UID; | ||
| notificationClient.sendNotification(title, message, idLink, uid, channel, priority, targetType); | ||
| log.debug("Notification pour changement de mot de passe de {} a été mis à jour", uid); | ||
| } catch (Exception e) { | ||
| log.error("Erreur: la notification n'a pas pu être envoyée", e); | ||
| } | ||
| } | ||
|
|
||
| @After("execution(* fr.recia.mce.api.escomceapi.services.PersonneService.updateEmail(..)) && args(uid, ..)") | ||
| public void notifEmailChange(String uid) { | ||
| try { | ||
| final String title = notificationAspectConfig.getTitleMail(); | ||
| final String message = buildMessage(notificationAspectConfig.getMessageMail()); | ||
| final List<Channel> channel = List.of(Channel.WEB); | ||
| final String idLink = ""; | ||
| final Priority priority = Priority.HIGH ; | ||
| final TargetType targetType = TargetType.UID; | ||
| notificationClient.sendNotification(title, message, idLink, uid, channel, priority, targetType); | ||
| log.info("Notification pour changement de mail {} a été envoyé", uid); | ||
| } catch (Exception e) { | ||
| log.error("Erreur: la notification n'a pas pu être envoyée", e); | ||
| } | ||
| } | ||
| } | ||
40 changes: 40 additions & 0 deletions
40
.../fr/recia/mce/api/escomceapi/aop/notification/configuration/NotificationAspectConfig.java
This file contains hidden or 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,40 @@ | ||
| /* | ||
| * Copyright (C) 2023 GIP-RECIA, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package fr.recia.mce.api.escomceapi.aop.notification.configuration; | ||
|
|
||
| import fr.recia.notifications.event_rest_client_kafka.HttpNotificationClient; | ||
| import lombok.Data; | ||
| import org.springframework.boot.context.properties.ConfigurationProperties; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
|
|
||
| @Data | ||
| @Configuration | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Faire avec un |
||
| @ConfigurationProperties(prefix = "notification-api") | ||
| public class NotificationAspectConfig { | ||
| private String url; | ||
| private String serviceName; | ||
| private String apiKey; | ||
| private String titleMdp; | ||
| private String messageMdp; | ||
| private String titleMail; | ||
| private String messageMail; | ||
|
|
||
| @Bean | ||
| public HttpNotificationClient notificationClient() { | ||
| return new HttpNotificationClient(url, serviceName, apiKey); | ||
| } | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
est-ce que le
@Dataest nécéssaire car on expose pas de getter/setter ? à tester