Skip to content

Commit

Permalink
feat: Add PWA notification - Meeds-io/MIPs#134
Browse files Browse the repository at this point in the history
  • Loading branch information
rdenarie committed Aug 23, 2024
1 parent c95e9bb commit 56caa0f
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 9 deletions.
20 changes: 19 additions & 1 deletion crowdin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,24 @@ files: [
"escape_special_characters": 0,
"escape_quotes" : 0,
},
{
"source" : "/webapp/src/main/resources/locale/commons/Commons_en.properties",

"translation" : "%original_path%/%file_name%!_%locale_with_underscore%.%file_extension%",
"translation_replace" : {
"_en!": "","ar_SA": "ar","ar_OM": "aro","az_AZ": "az","ca_ES": "ca","ceb_PH": "ceb",
"co_FR": "co","cs_CZ": "cs","de_DE": "de","el_GR": "el","en_US": "en","es_ES": "es_ES","eu_ES": "eu","fa_IR": "fa",
"fi_FI": "fi","fil_PH": "fil","fr_FR": "fr","hi_IN": "hi","hu_HU": "hu","id_ID": "id","it_IT": "it","ja_JP": "ja",
"kab_KAB": "kab","ko_KR": "ko","lt_LT": "lt","ms_MY": "ms","nl_NL": "nl","no_NO": "no","pcm_NG": "pcm","pl_PL": "pl",
"pt_BR": "pt_BR","pt_PT": "pt_PT","ro_RO": "ro","ru_RU": "ru","sk_SK": "sk","sl_SI": "sl","sq_AL": "sq",
"sv_SE": "sv_SE","th_TH": "th","tl_PH": "tl","tr_TR": "tr","uk_UA": "uk","ur_IN": "ur_IN","vi_VN": "vi",
"zh_CN": "zh_CN","zh_TW": "zh_TW",
},
"dest" : "add__ons/web__conferencing/Commons.properties",
"update_option" : "update_as_unapproved",
"escape_special_characters": 0,
"escape_quotes" : 0,
},
{
"source" : "/services/src/main/resources/locale/webconferencing/WebConferencingAdmin_en.properties",

Expand Down Expand Up @@ -123,4 +141,4 @@ files: [
"escape_special_characters": 0,
"escape_quotes" : 0,
},
]
]
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
<type>pom</type>
<scope>import</scope>
</dependency>

<!-- Video Calls extension -->
<dependency>
<groupId>${project.groupId}</groupId>
Expand Down
4 changes: 4 additions & 0 deletions services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
<artifactId>ecms-social-integration</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.meeds.pwa</groupId>
<artifactId>pwa-service</artifactId>
</dependency>
</dependencies>
<build>
<resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4025,12 +4025,25 @@ private void broacastCallEvent(String eventName, CallInfo call, String userId, D

public String getRecordingUrl(String identity, String fileName, String type) throws Exception {
if(!fileName.isEmpty()) {
DocumentService documentService = WCMCoreUtils.getService(DocumentService.class);
Node rootNode = getRootFolderNode(identity, type);
Node recordingsFolder = getRecordingsFolder(rootNode);
Node fileRecorded = recordingsFolder.getNode(fileName);
String shortLink = documentService.getShortLinkInDocumentsApp(fileRecorded.getSession().getWorkspace().getName(), ((NodeImpl) fileRecorded).getInternalIdentifier());
return CommonsUtils.getCurrentDomain() + shortLink;

Node rootNode = getRootFolderNode(identity, type);
Node recordingsFolder = getRecordingsFolder(rootNode);
Node fileRecorded = recordingsFolder.getNode(fileName);

StringBuilder stringBuilder = new StringBuilder();
String portalOwner = CommonsUtils.getCurrentPortalOwner();
String domain = CommonsUtils.getCurrentDomain();
stringBuilder.append(domain)
.append("/")
.append(LinkProvider.getPortalName(null)).append("/");

stringBuilder.append(portalOwner).append("/documents");
stringBuilder.append("?documentPreviewId=");

stringBuilder.append(((NodeImpl) fileRecorded).getIdentifier());
LOG.info("filename {} for user {}, with type {}, generate shortlink={}",fileRecorded.getPath(),identity,type,stringBuilder.toString());
return stringBuilder.toString();

} else {
return "#";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.exoplatform.commons.api.notification.model.PluginKey;
import org.exoplatform.commons.notification.impl.NotificationContextImpl;
import org.exoplatform.commons.utils.CommonsUtils;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.social.core.identity.model.Identity;
import org.exoplatform.social.core.identity.provider.OrganizationIdentityProvider;
import org.exoplatform.social.core.manager.IdentityManager;
Expand Down Expand Up @@ -75,6 +77,7 @@ public void onEvent(Event<CallInfo, Map<? extends String, ? extends String>> eve
}
NotificationContext ctx = NotificationContextImpl.cloneInstance();
String fileUrl = webConferencingService.getRecordingUrl(identity, fileName, callType);
fileUrl=fileUrl.replace(CommonsUtils.getCurrentDomain(),"");
ctx.append(NotificationConstants.RECORDED_FILE_URL, fileUrl);
ctx.append(NotificationConstants.CALL_PARTICIPANTS, participants);
ctx.append(NotificationConstants.FILE_NAME, fileName);
Expand All @@ -99,6 +102,7 @@ public void onEvent(Event<CallInfo, Map<? extends String, ? extends String>> eve
List<String> part = new ArrayList<>();
part.add(participant);
String fileUrl = webConferencingService.getRecordingUrl(participant, fileName, callType);
fileUrl=fileUrl.replace(CommonsUtils.getCurrentDomain(),"");
ctx.append(NotificationConstants.FILE_NAME, fileName);
ctx.append(NotificationConstants.RECORDING_STATUS, status);
ctx.append(NotificationConstants.RECORDED_FILE_URL, fileUrl);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* 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.webconferencing.notification.pwa;

import io.meeds.portal.permlink.service.PermanentLinkService;
import io.meeds.pwa.model.PwaNotificationMessage;
import io.meeds.pwa.plugin.PwaNotificationPlugin;
import org.exoplatform.commons.api.notification.model.NotificationInfo;
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.webconferencing.notification.utils.NotificationConstants;

public class CallRecordingPwaPlugin implements PwaNotificationPlugin {

public static final String ID = "CallRecordingPlugin";

private static final String TITLE_LABEL_KEY_OK = "pwa.notification.webconferencing.callrecording.success";
private static final String TITLE_LABEL_KEY_KO = "pwa.notification.webconferencing.callrecording.failed";

private static final Log LOG = ExoLogger.getLogger(PwaNotificationPlugin.class);

private ResourceBundleService resourceBundleService;

public CallRecordingPwaPlugin(ResourceBundleService resourceBundleService) {
this.resourceBundleService = resourceBundleService;
}

@Override
public String getId() {
return ID ;
}

@Override
public PwaNotificationMessage process(NotificationInfo notification, LocaleConfig localeConfig) {
PwaNotificationMessage notificationMessage = new PwaNotificationMessage();

String status = notification.getValueOwnerParameter(NotificationConstants.RECORDING_STATUS.getKey());
String title;
if (status.equals("ok")) {
title = resourceBundleService.getSharedString(TITLE_LABEL_KEY_OK, localeConfig.getLocale());
} else {
title = resourceBundleService.getSharedString(TITLE_LABEL_KEY_KO, localeConfig.getLocale());

}

notificationMessage.setTitle(title);
notificationMessage.setUrl(notification.getValueOwnerParameter(NotificationConstants.RECORDED_FILE_URL.getKey()));
return notificationMessage;
}

}
6 changes: 5 additions & 1 deletion services/src/main/resources/conf/portal/configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
xsi:schemaLocation="http://www.exoplatform.org/xml/ns/kernel_1_2.xsd http://www.exoplatform.org/xml/ns/kernel_1_2.xsd"
xmlns="http://www.exoplatform.org/xml/ns/kernel_1_2.xsd">


<component>
<type>org.exoplatform.webconferencing.notification.pwa.CallRecordingPwaPlugin</type>
</component>
<external-component-plugins>
<target-component>org.exoplatform.services.listener.ListenerService</target-component>
<component-plugin>
Expand All @@ -11,4 +15,4 @@
<type>org.exoplatform.webconferencing.listeners.CallRecordingNotificationListener</type>
</component-plugin>
</external-component-plugins>
</configuration>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pwa.notification.webconferencing.callrecording.success=Your web conference has been recorded successfully
pwa.notification.webconferencing.callrecording.failed=Your web conference recording has failed
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pwa.notification.webconferencing.callrecording.success=Votre visioconf\u00e9rence a \u00e9t\u00e9 enregistr\u00e9e avec succ\u00e8s
pwa.notification.webconferencing.callrecording.failed=L'enregistrement de votre visioconf\u00e9rence a \u00e9chou\u00e9

0 comments on commit 56caa0f

Please sign in to comment.