-
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.
feat: Add Pwa Notifications - Meeds-io/MIPs#134
- Loading branch information
Showing
9 changed files
with
247 additions
and
3 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
68 changes: 68 additions & 0 deletions
68
...ices/src/main/java/org/exoplatform/processes/notification/pwa/CancelRequestPwaPlugin.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,68 @@ | ||
/* | ||
* Copyright (C) 2024 eXo Platform SAS. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.exoplatform.processes.notification.pwa; | ||
|
||
import io.meeds.pwa.model.PwaNotificationMessage; | ||
import io.meeds.pwa.plugin.PwaNotificationPlugin; | ||
import org.exoplatform.commons.api.notification.model.NotificationInfo; | ||
import org.exoplatform.commons.utils.CommonsUtils; | ||
import org.exoplatform.processes.notification.utils.NotificationArguments; | ||
import org.exoplatform.services.resources.LocaleConfig; | ||
import org.exoplatform.services.resources.ResourceBundleService; | ||
import org.exoplatform.social.core.identity.model.Identity; | ||
import org.exoplatform.social.core.manager.IdentityManager; | ||
|
||
public class CancelRequestPwaPlugin implements PwaNotificationPlugin { | ||
|
||
public final static String ID = "CancelRequestPlugin"; | ||
private static final String TITLE_LABEL_KEY = "pwa.notification.CancelRequestPwaPlugin.title"; | ||
|
||
private ResourceBundleService resourceBundleService; | ||
|
||
private IdentityManager identityManager; | ||
|
||
public CancelRequestPwaPlugin(ResourceBundleService resourceBundleService, IdentityManager identityManager) { | ||
this.resourceBundleService = resourceBundleService; | ||
this.identityManager = identityManager; | ||
} | ||
|
||
@Override | ||
public IdentityManager getIdentityManager() { | ||
return this.identityManager; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return ID; | ||
} | ||
|
||
@Override | ||
public PwaNotificationMessage process(NotificationInfo notification, LocaleConfig localeConfig) { | ||
PwaNotificationMessage notificationMessage = new PwaNotificationMessage(); | ||
|
||
String userFullName = getFullName(notification.getValueOwnerParameter(NotificationArguments.REQUEST_CREATOR.getKey())); | ||
|
||
String title = resourceBundleService.getSharedString(TITLE_LABEL_KEY, localeConfig.getLocale()) | ||
.replace("{0}",userFullName) | ||
.replace("{1}",notification.getValueOwnerParameter(NotificationArguments.REQUEST_PROCESS.getKey())); | ||
notificationMessage.setTitle(title); | ||
String url = notification.getValueOwnerParameter(NotificationArguments.PROCESS_URL.getKey()); | ||
url = url.replace(CommonsUtils.getCurrentDomain(), ""); | ||
notificationMessage.setUrl(url); | ||
return notificationMessage; | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
...ices/src/main/java/org/exoplatform/processes/notification/pwa/CreateRequestPwaPlugin.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,69 @@ | ||
/* | ||
* Copyright (C) 2024 eXo Platform SAS. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.exoplatform.processes.notification.pwa; | ||
|
||
import io.meeds.pwa.model.PwaNotificationMessage; | ||
import io.meeds.pwa.plugin.PwaNotificationPlugin; | ||
import org.exoplatform.commons.api.notification.model.NotificationInfo; | ||
import org.exoplatform.commons.utils.CommonsUtils; | ||
import org.exoplatform.processes.notification.utils.NotificationArguments; | ||
import org.exoplatform.services.resources.LocaleConfig; | ||
import org.exoplatform.services.resources.ResourceBundleService; | ||
import org.exoplatform.social.core.manager.IdentityManager; | ||
|
||
public class CreateRequestPwaPlugin implements PwaNotificationPlugin { | ||
|
||
public final static String ID = "CreateRequestPlugin"; | ||
private static final String TITLE_LABEL_KEY = "pwa.notification.CreateRequestPwaPlugin.title"; | ||
|
||
|
||
private ResourceBundleService resourceBundleService; | ||
private IdentityManager identityManager; | ||
|
||
public CreateRequestPwaPlugin(ResourceBundleService resourceBundleService, IdentityManager identityManager) { | ||
this.resourceBundleService = resourceBundleService; | ||
this.identityManager = identityManager; | ||
|
||
|
||
} | ||
|
||
@Override | ||
public IdentityManager getIdentityManager() { | ||
return this.identityManager; | ||
} | ||
@Override | ||
public String getId() { | ||
return ID; | ||
} | ||
|
||
@Override | ||
public PwaNotificationMessage process(NotificationInfo notification, LocaleConfig localeConfig) { | ||
PwaNotificationMessage notificationMessage = new PwaNotificationMessage(); | ||
|
||
String userFullName = getFullName(notification.getValueOwnerParameter(NotificationArguments.REQUEST_CREATOR.getKey())); | ||
|
||
String title = resourceBundleService.getSharedString(TITLE_LABEL_KEY, localeConfig.getLocale()) | ||
.replace("{0}",userFullName) | ||
.replace("{1}",notification.getValueOwnerParameter(NotificationArguments.REQUEST_PROCESS.getKey())); | ||
notificationMessage.setTitle(title); | ||
String url = notification.getValueOwnerParameter(NotificationArguments.REQUEST_URL.getKey()); | ||
url = url.replace(CommonsUtils.getCurrentDomain(), ""); | ||
notificationMessage.setUrl(url); | ||
return notificationMessage; | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...ces/src/main/java/org/exoplatform/processes/notification/pwa/RequestCommentPwaPlugin.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,68 @@ | ||
/* | ||
* Copyright (C) 2024 eXo Platform SAS. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.exoplatform.processes.notification.pwa; | ||
|
||
import io.meeds.pwa.model.PwaNotificationMessage; | ||
import io.meeds.pwa.plugin.PwaNotificationPlugin; | ||
import org.exoplatform.commons.api.notification.model.NotificationInfo; | ||
import org.exoplatform.commons.utils.CommonsUtils; | ||
import org.exoplatform.processes.notification.utils.NotificationArguments; | ||
import org.exoplatform.services.resources.LocaleConfig; | ||
import org.exoplatform.services.resources.ResourceBundleService; | ||
import org.exoplatform.social.core.manager.IdentityManager; | ||
|
||
public class RequestCommentPwaPlugin implements PwaNotificationPlugin { | ||
|
||
public static final String ID = "RequestCommentPlugin"; | ||
private static final String TITLE_LABEL_KEY = "pwa.notification.RequestCommentPwaPlugin.title"; | ||
|
||
private ResourceBundleService resourceBundleService; | ||
private IdentityManager identityManager; | ||
|
||
|
||
public RequestCommentPwaPlugin(ResourceBundleService resourceBundleService, IdentityManager identityManager) { | ||
this.resourceBundleService = resourceBundleService; | ||
this.identityManager = identityManager; | ||
|
||
} | ||
@Override | ||
public IdentityManager getIdentityManager() { | ||
return this.identityManager; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return ID; | ||
} | ||
|
||
@Override | ||
public PwaNotificationMessage process(NotificationInfo notification, LocaleConfig localeConfig) { | ||
PwaNotificationMessage notificationMessage = new PwaNotificationMessage(); | ||
|
||
String userFullName = getFullName(notification.getValueOwnerParameter(NotificationArguments.REQUEST_COMMENT_AUTHOR.getKey())); | ||
|
||
String title = resourceBundleService.getSharedString(TITLE_LABEL_KEY, localeConfig.getLocale()) | ||
.replace("{0}",userFullName) | ||
.replace("{1}",notification.getValueOwnerParameter(NotificationArguments.REQUEST_TITLE.getKey())) | ||
.replace("{2}",notification.getValueOwnerParameter(NotificationArguments.REQUEST_PROCESS.getKey())); | ||
notificationMessage.setTitle(title); | ||
String url = notification.getValueOwnerParameter(NotificationArguments.REQUEST_COMMENT_URL.getKey()); | ||
url = url.replace(CommonsUtils.getCurrentDomain(), ""); | ||
notificationMessage.setUrl(url); | ||
return notificationMessage; | ||
} | ||
} |
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
3 changes: 3 additions & 0 deletions
3
processes-webapp/src/main/resources/locale/commons/Commons_en.properties
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,3 @@ | ||
pwa.notification.CreateRequestPwaPlugin.title={0} has created a new request on the {1} process | ||
pwa.notification.CancelRequestPwaPlugin.title={0} has cancelled the request | ||
pwa.notification.RequestCommentPwaPlugin.title={0} has commented on your request {1} in {2} process |
3 changes: 3 additions & 0 deletions
3
processes-webapp/src/main/resources/locale/commons/Commons_fr.properties
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,3 @@ | ||
pwa.notification.CreateRequestPwaPlugin.title={0} a cr\u00e9\u00e9 une nouvelle demande sur le process {1} | ||
pwa.notification.CancelRequestPwaPlugin.title={0} a annul\u00e9 sa demande | ||
pwa.notification.RequestCommentPwaPlugin.title={0} a comment\u00e9 votre demande {1} dans le processus {2} |
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