-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into snyk-upgrade-521c3c3d2b1962bd04474e1c255c…
…dbc5
- Loading branch information
Showing
66 changed files
with
2,357 additions
and
743 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
31 changes: 31 additions & 0 deletions
31
...in/java/org/exoplatform/agenda/notification/pwa/AgendaCancelledNotificationPwaPlugin.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,31 @@ | ||
/* | ||
* 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.agenda.notification.pwa; | ||
|
||
import org.exoplatform.container.xml.InitParams; | ||
import org.exoplatform.services.resources.ResourceBundleService; | ||
import org.exoplatform.social.core.space.spi.SpaceService; | ||
|
||
public class AgendaCancelledNotificationPwaPlugin extends AgendaNotificationPwaPlugin { | ||
public AgendaCancelledNotificationPwaPlugin(InitParams initParams, | ||
ResourceBundleService resourceBundleService, SpaceService spaceService) { | ||
super(initParams, resourceBundleService, spaceService); | ||
} | ||
|
||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...main/java/org/exoplatform/agenda/notification/pwa/AgendaCreatedNotificationPwaPlugin.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,30 @@ | ||
/* | ||
* 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.agenda.notification.pwa; | ||
|
||
import org.exoplatform.container.xml.InitParams; | ||
import org.exoplatform.services.resources.ResourceBundleService; | ||
import org.exoplatform.social.core.space.spi.SpaceService; | ||
|
||
public class AgendaCreatedNotificationPwaPlugin extends AgendaNotificationPwaPlugin { | ||
public AgendaCreatedNotificationPwaPlugin(InitParams initParams, | ||
ResourceBundleService resourceBundleService, SpaceService spaceService) { | ||
super(initParams, resourceBundleService, spaceService); | ||
} | ||
|
||
|
||
} |
117 changes: 117 additions & 0 deletions
117
...es/src/main/java/org/exoplatform/agenda/notification/pwa/AgendaNotificationPwaPlugin.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,117 @@ | ||
/* | ||
* 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.agenda.notification.pwa; | ||
|
||
import io.meeds.pwa.model.PwaNotificationMessage; | ||
import io.meeds.pwa.plugin.PwaNotificationPlugin; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.exoplatform.commons.api.notification.model.NotificationInfo; | ||
import org.exoplatform.commons.utils.CommonsUtils; | ||
import org.exoplatform.container.xml.InitParams; | ||
import org.exoplatform.container.xml.ValueParam; | ||
import org.exoplatform.services.log.ExoLogger; | ||
import org.exoplatform.services.log.Log; | ||
import org.exoplatform.services.resources.LocaleConfig; | ||
import org.exoplatform.services.resources.ResourceBundleService; | ||
import org.exoplatform.social.core.space.spi.SpaceService; | ||
|
||
import static org.exoplatform.agenda.util.NotificationUtils.STORED_EVENT_MODIFICATION_TYPE; | ||
import static org.exoplatform.agenda.util.NotificationUtils.STORED_PARAMETER_EVENT_STATUS; | ||
import static org.exoplatform.agenda.util.NotificationUtils.STORED_PARAMETER_EVENT_TITLE; | ||
import static org.exoplatform.agenda.util.NotificationUtils.STORED_PARAMETER_EVENT_URL; | ||
|
||
|
||
public class AgendaNotificationPwaPlugin implements PwaNotificationPlugin { | ||
private static final String AGENDA_NOTIFICATION_PLUGIN_NAME = "agenda.notification.plugin.key"; | ||
private static final String TITLE_LABEL_KEY = "pwa.notification.AgendaNotificationPwaPlugin.title"; | ||
|
||
private static final Log LOG = ExoLogger.getLogger(AgendaNotificationPwaPlugin.class); | ||
|
||
private String notificationId; | ||
|
||
private ResourceBundleService resourceBundleService; | ||
|
||
public AgendaNotificationPwaPlugin(InitParams initParams, | ||
ResourceBundleService resourceBundleService, SpaceService spaceService) { | ||
this.resourceBundleService = resourceBundleService; | ||
ValueParam notificationIdParam = initParams.getValueParam(AGENDA_NOTIFICATION_PLUGIN_NAME); | ||
if (notificationIdParam == null || StringUtils.isBlank(notificationIdParam.getValue())) { | ||
throw new IllegalStateException("'agenda.notification.plugin.key' parameter is mandatory"); | ||
} | ||
this.notificationId = notificationIdParam.getValue(); | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return this.notificationId; | ||
} | ||
|
||
@Override | ||
public PwaNotificationMessage process(NotificationInfo notification, LocaleConfig localeConfig) { | ||
PwaNotificationMessage notificationMessage = new PwaNotificationMessage(); | ||
|
||
String key = TITLE_LABEL_KEY; | ||
String type = notification.getValueOwnerParameter(STORED_EVENT_MODIFICATION_TYPE); | ||
String eventStatus = notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_STATUS); | ||
switch (type) { | ||
case "ADDED": | ||
key += ".created"; | ||
break; | ||
case "DATES_UPDATED": | ||
if (eventStatus.equals("CONFIRMED")) { | ||
key += ".dates.updated"; | ||
} else if (eventStatus.equals("TENTATIVE")){ | ||
key += ".datePoll.dates.updated"; | ||
} else { | ||
key += ".canceled"; | ||
} | ||
break; | ||
case "UPDATED": | ||
if (eventStatus.equals("TENTATIVE")) { | ||
key += ".datePoll.updated"; | ||
} else { | ||
key += ".updated"; | ||
} | ||
break; | ||
case "SWITCHED_EVENT_TO_DATE_POLL": | ||
key += ".switchedToDatePoll"; | ||
break; | ||
case "SWITCHED_DATE_POLL_TO_EVENT": | ||
key += ".switchedToEvent"; | ||
break; | ||
case "DELETED": | ||
if (eventStatus.equals("TENTATIVE")) { | ||
key += ".datePoll.updated"; | ||
} else { | ||
key += ".canceled"; | ||
} | ||
break; | ||
default: | ||
key += ".canceled"; | ||
break; | ||
} | ||
String title = resourceBundleService.getSharedString(key, localeConfig.getLocale()) | ||
.replace("{0}",notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_TITLE)); | ||
|
||
notificationMessage.setTitle(title); | ||
notificationMessage.setBody(notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_TITLE)); | ||
|
||
String url = notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_URL).replace(CommonsUtils.getCurrentDomain(), ""); | ||
notificationMessage.setUrl(url); | ||
return notificationMessage; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...main/java/org/exoplatform/agenda/notification/pwa/AgendaUpdatedNotificationPwaPlugin.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,30 @@ | ||
/* | ||
* 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.agenda.notification.pwa; | ||
|
||
import org.exoplatform.container.xml.InitParams; | ||
import org.exoplatform.services.resources.ResourceBundleService; | ||
import org.exoplatform.social.core.space.spi.SpaceService; | ||
|
||
public class AgendaUpdatedNotificationPwaPlugin extends AgendaNotificationPwaPlugin { | ||
public AgendaUpdatedNotificationPwaPlugin(InitParams initParams, | ||
ResourceBundleService resourceBundleService, SpaceService spaceService) { | ||
super(initParams, resourceBundleService, spaceService); | ||
} | ||
|
||
|
||
} |
69 changes: 69 additions & 0 deletions
69
.../src/main/java/org/exoplatform/agenda/notification/pwa/DatePollNotificationPwaPlugin.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.agenda.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.services.log.ExoLogger; | ||
import org.exoplatform.services.log.Log; | ||
import org.exoplatform.services.resources.LocaleConfig; | ||
import org.exoplatform.services.resources.ResourceBundleService; | ||
|
||
import static org.exoplatform.agenda.util.NotificationUtils.STORED_PARAMETER_EVENT_CREATOR; | ||
import static org.exoplatform.agenda.util.NotificationUtils.STORED_PARAMETER_EVENT_TITLE; | ||
import static org.exoplatform.agenda.util.NotificationUtils.STORED_PARAMETER_EVENT_URL; | ||
|
||
public class DatePollNotificationPwaPlugin implements PwaNotificationPlugin { | ||
private static final Log LOG = ExoLogger.getLogger(DatePollNotificationPwaPlugin.class); | ||
|
||
private static final String TITLE_LABEL_KEY = "pwa.notification.DatePollNotificationPwaPlugin.title"; | ||
|
||
private String notificationId = "DatePollNotificationPlugin"; | ||
|
||
private ResourceBundleService resourceBundleService; | ||
|
||
|
||
public DatePollNotificationPwaPlugin(ResourceBundleService resourceBundleService) { | ||
this.resourceBundleService = resourceBundleService; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return this.notificationId; | ||
} | ||
|
||
|
||
@Override | ||
public PwaNotificationMessage process(NotificationInfo notification, LocaleConfig localeConfig) { | ||
PwaNotificationMessage notificationMessage = new PwaNotificationMessage(); | ||
|
||
String key = TITLE_LABEL_KEY; | ||
String creatorName = notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_CREATOR); | ||
|
||
String title = resourceBundleService.getSharedString(key, localeConfig.getLocale()) | ||
.replace("{0}",creatorName); | ||
|
||
notificationMessage.setTitle(title); | ||
notificationMessage.setBody(notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_TITLE)); | ||
|
||
String url = notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_URL).replace(CommonsUtils.getCurrentDomain(), ""); | ||
notificationMessage.setUrl(url); | ||
return notificationMessage; | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
...main/java/org/exoplatform/agenda/notification/pwa/EventReminderNotificationPwaPlugin.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,83 @@ | ||
/* | ||
* 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.agenda.notification.pwa; | ||
|
||
import io.meeds.pwa.model.PwaNotificationMessage; | ||
import io.meeds.pwa.plugin.PwaNotificationPlugin; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.exoplatform.agenda.model.Calendar; | ||
import org.exoplatform.agenda.model.Event; | ||
import org.exoplatform.agenda.model.EventReminder; | ||
import org.exoplatform.agenda.service.AgendaCalendarService; | ||
import org.exoplatform.agenda.service.AgendaEventService; | ||
import org.exoplatform.commons.api.notification.NotificationContext; | ||
import org.exoplatform.commons.api.notification.model.NotificationInfo; | ||
import org.exoplatform.commons.utils.CommonsUtils; | ||
import org.exoplatform.container.xml.InitParams; | ||
import org.exoplatform.container.xml.ValueParam; | ||
import org.exoplatform.services.log.ExoLogger; | ||
import org.exoplatform.services.log.Log; | ||
import org.exoplatform.services.resources.LocaleConfig; | ||
import org.exoplatform.services.resources.ResourceBundleService; | ||
import org.exoplatform.social.core.space.spi.SpaceService; | ||
|
||
import static org.exoplatform.agenda.util.NotificationUtils.STORED_PARAMETER_EVENT_OWNER_ID; | ||
import static org.exoplatform.agenda.util.NotificationUtils.STORED_PARAMETER_EVENT_TITLE; | ||
import static org.exoplatform.agenda.util.NotificationUtils.STORED_PARAMETER_EVENT_URL; | ||
|
||
public class EventReminderNotificationPwaPlugin implements PwaNotificationPlugin { | ||
private static final Log LOG = ExoLogger.getLogger(EventReminderNotificationPwaPlugin.class); | ||
|
||
private String notificationId = "EventReminderNotificationPlugin"; | ||
private static final String TITLE_LABEL_KEY = "pwa.notification.EventReminderNotificationPwaPlugin.title"; | ||
|
||
private ResourceBundleService resourceBundleService; | ||
private SpaceService spaceService; | ||
|
||
public EventReminderNotificationPwaPlugin(ResourceBundleService resourceBundleService, SpaceService spaceService) { | ||
this.spaceService = spaceService; | ||
this.resourceBundleService = resourceBundleService; | ||
} | ||
|
||
@Override | ||
public SpaceService getSpaceService() { | ||
return this.spaceService; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return this.notificationId; | ||
} | ||
|
||
@Override | ||
public PwaNotificationMessage process(NotificationInfo notification, LocaleConfig localeConfig) { | ||
PwaNotificationMessage notificationMessage = new PwaNotificationMessage(); | ||
|
||
String key = TITLE_LABEL_KEY; | ||
String spaceId = notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_OWNER_ID); | ||
String title = resourceBundleService.getSharedString(key, localeConfig.getLocale()) | ||
.replace("{0}",getSpaceName(spaceId)); | ||
|
||
notificationMessage.setTitle(title); | ||
notificationMessage.setBody(notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_TITLE)); | ||
|
||
String url = notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_URL).replace(CommonsUtils.getCurrentDomain(), ""); | ||
notificationMessage.setUrl(url); | ||
return notificationMessage; | ||
} | ||
|
||
} |
Oops, something went wrong.