From 324e5370ecbf1a754d1a85ec35fd1d92b21e5809 Mon Sep 17 00:00:00 2001 From: Boubaker Khanfir Date: Tue, 9 Jul 2024 15:39:04 +0100 Subject: [PATCH 1/4] feat: Avoid loading Wallet Style in all pages - MEED-7237 - Meeds-io/MIPs#134 This change will allow to load Wallet PortalSkin CSS only when one of Wallet Portlets is defined in the page. --- .../main/webapp/WEB-INF/gatein-resources.xml | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/wallet-webapps/src/main/webapp/WEB-INF/gatein-resources.xml b/wallet-webapps/src/main/webapp/WEB-INF/gatein-resources.xml index 278357569..1c2543622 100644 --- a/wallet-webapps/src/main/webapp/WEB-INF/gatein-resources.xml +++ b/wallet-webapps/src/main/webapp/WEB-INF/gatein-resources.xml @@ -22,8 +22,51 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. wallet /skin/css/wallet.css 110 + true + + wallet + WalletAPI + Enterprise + wallet + + + + wallet + Wallet + Enterprise + wallet + + + + wallet + SpaceWallet + Enterprise + wallet + + + + wallet + WalletSettings + Enterprise + wallet + + + + wallet + WalletOverview + Enterprise + wallet + + + + wallet + RewardAdmin + Enterprise + wallet + + WalletAPI From f582fe78b5eed6b57a8b4c16ce88f806b94913d9 Mon Sep 17 00:00:00 2001 From: Boubaker Khanfir Date: Tue, 9 Jul 2024 19:30:21 +0100 Subject: [PATCH 2/4] feat: Upgrade resources XSD - MEED-7237 - Meeds-io/MIPs#134 --- wallet-webapps/src/main/webapp/WEB-INF/gatein-resources.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wallet-webapps/src/main/webapp/WEB-INF/gatein-resources.xml b/wallet-webapps/src/main/webapp/WEB-INF/gatein-resources.xml index 1c2543622..ec35736e2 100644 --- a/wallet-webapps/src/main/webapp/WEB-INF/gatein-resources.xml +++ b/wallet-webapps/src/main/webapp/WEB-INF/gatein-resources.xml @@ -15,7 +15,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --> - + Enterprise From 764ce9855a6ab8b4ba5d83888d35b782dea618e3 Mon Sep 17 00:00:00 2001 From: Boubaker Khanfir Date: Thu, 11 Jul 2024 15:00:43 +0100 Subject: [PATCH 3/4] feat: Retrieve Resource Bundle from extension context instead of Monolith - MEED-7237 - Meeds-io/MIPs#134 This change will allow to request the resource bundle from extension context using declared as a filter in the file. --- wallet-webapps/src/main/webapp/WEB-INF/web.xml | 1 + .../src/main/webapp/vue-app/notification-extension/main.js | 2 +- wallet-webapps/src/main/webapp/vue-app/wallet-admin/main.js | 2 +- .../src/main/webapp/vue-app/wallet-app/spaceWallet.js | 2 +- wallet-webapps/src/main/webapp/vue-app/wallet-app/wallet.js | 2 +- wallet-webapps/src/main/webapp/vue-app/wallet-app/walletAPI.js | 2 +- .../main/webapp/vue-app/wallet-common/wallet-overview/main.js | 2 +- .../main/webapp/vue-app/wallet-common/wallet-settings/main.js | 2 +- wallet-webapps/src/main/webapp/vue-app/wallet-reward/main.js | 2 +- .../src/main/webapp/vue-app/wallet-setup-admin/main.js | 2 +- 10 files changed, 10 insertions(+), 9 deletions(-) diff --git a/wallet-webapps/src/main/webapp/WEB-INF/web.xml b/wallet-webapps/src/main/webapp/WEB-INF/web.xml index 86258e0c9..06146325e 100644 --- a/wallet-webapps/src/main/webapp/WEB-INF/web.xml +++ b/wallet-webapps/src/main/webapp/WEB-INF/web.xml @@ -41,6 +41,7 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *.css *.js *.html + /i18n/* /images/* diff --git a/wallet-webapps/src/main/webapp/vue-app/notification-extension/main.js b/wallet-webapps/src/main/webapp/vue-app/notification-extension/main.js index ba8ac552a..264f1101e 100644 --- a/wallet-webapps/src/main/webapp/vue-app/notification-extension/main.js +++ b/wallet-webapps/src/main/webapp/vue-app/notification-extension/main.js @@ -21,7 +21,7 @@ import './initComponents.js'; import './extensions.js'; const lang = eXo.env.portal.language; -const url = `${eXo.env.portal.context}/${eXo.env.portal.rest}/i18n/bundle/locale.notification.WalletNotification-${lang}.json`; +const url = `/wallet/i18n/locale.notification.WalletNotification?lang=${lang}`; export function init() { return exoi18n.loadLanguageAsync(lang, url) diff --git a/wallet-webapps/src/main/webapp/vue-app/wallet-admin/main.js b/wallet-webapps/src/main/webapp/vue-app/wallet-admin/main.js index e40f3854f..850cf0061 100644 --- a/wallet-webapps/src/main/webapp/vue-app/wallet-admin/main.js +++ b/wallet-webapps/src/main/webapp/vue-app/wallet-admin/main.js @@ -20,7 +20,7 @@ import './initComponents.js'; const lang = (eXo && eXo.env && eXo.env.portal && eXo.env.portal.language) || 'en'; -const url = `${eXo.env.portal.context}/${eXo.env.portal.rest}/i18n/bundle/locale.addon.Wallet-${lang}.json`; +const url = `/wallet/i18n/locale.addon.Wallet?lang=${lang}`; const appId = 'WalletAdminApp'; Vue.use(WalletCommon); diff --git a/wallet-webapps/src/main/webapp/vue-app/wallet-app/spaceWallet.js b/wallet-webapps/src/main/webapp/vue-app/wallet-app/spaceWallet.js index 20b162e61..24702cf9e 100644 --- a/wallet-webapps/src/main/webapp/vue-app/wallet-app/spaceWallet.js +++ b/wallet-webapps/src/main/webapp/vue-app/wallet-app/spaceWallet.js @@ -20,7 +20,7 @@ import './initComponents.js'; Vue.use(WalletCommon); const lang = (eXo && eXo.env && eXo.env.portal && eXo.env.portal.language) || 'en'; -const url = `${eXo.env.portal.context}/${eXo.env.portal.rest}/i18n/bundle/locale.addon.Wallet-${lang}.json`; +const url = `/wallet/i18n/locale.addon.Wallet?lang=${lang}`; export function init() { exoi18n.loadLanguageAsync(lang, url).then(i18n => { diff --git a/wallet-webapps/src/main/webapp/vue-app/wallet-app/wallet.js b/wallet-webapps/src/main/webapp/vue-app/wallet-app/wallet.js index 87c3d68b7..86310ff98 100644 --- a/wallet-webapps/src/main/webapp/vue-app/wallet-app/wallet.js +++ b/wallet-webapps/src/main/webapp/vue-app/wallet-app/wallet.js @@ -20,7 +20,7 @@ import './initComponents.js'; Vue.use(WalletCommon); const lang = (eXo && eXo.env && eXo.env.portal && eXo.env.portal.language) || 'en'; -const url = `${eXo.env.portal.context}/${eXo.env.portal.rest}/i18n/bundle/locale.addon.Wallet-${lang}.json`; +const url = `/wallet/i18n/locale.addon.Wallet?lang=${lang}`; export function init(generatedToken) { exoi18n.loadLanguageAsync(lang, url).then(i18n => { diff --git a/wallet-webapps/src/main/webapp/vue-app/wallet-app/walletAPI.js b/wallet-webapps/src/main/webapp/vue-app/wallet-app/walletAPI.js index 6ca920232..a759f2d0f 100644 --- a/wallet-webapps/src/main/webapp/vue-app/wallet-app/walletAPI.js +++ b/wallet-webapps/src/main/webapp/vue-app/wallet-app/walletAPI.js @@ -20,7 +20,7 @@ import './initComponents.js'; Vue.use(Vuetify); const lang = (eXo && eXo.env && eXo.env.portal && eXo.env.portal.language) || 'en'; -const url = `${eXo.env.portal.context}/${eXo.env.portal.rest}/i18n/bundle/locale.addon.Wallet-${lang}.json`; +const url = `/wallet/i18n/locale.addon.Wallet?lang=${lang}`; export function initAPI() { if (!window.walletAPIInitialized) { diff --git a/wallet-webapps/src/main/webapp/vue-app/wallet-common/wallet-overview/main.js b/wallet-webapps/src/main/webapp/vue-app/wallet-common/wallet-overview/main.js index 52052659b..dfec2ff50 100644 --- a/wallet-webapps/src/main/webapp/vue-app/wallet-common/wallet-overview/main.js +++ b/wallet-webapps/src/main/webapp/vue-app/wallet-common/wallet-overview/main.js @@ -30,7 +30,7 @@ Vue.use(Vuetify); const vuetify = new Vuetify(eXo.env.portal.vuetifyPreset); const lang = (eXo && eXo.env && eXo.env.portal && eXo.env.portal.language) || 'en'; -const url = `${eXo.env.portal.context}/${eXo.env.portal.rest}/i18n/bundle/locale.addon.Wallet-${lang}.json`; +const url = `/wallet/i18n/locale.addon.Wallet?lang=${lang}`; const appId = 'WalletOverview'; diff --git a/wallet-webapps/src/main/webapp/vue-app/wallet-common/wallet-settings/main.js b/wallet-webapps/src/main/webapp/vue-app/wallet-common/wallet-settings/main.js index b91089a0c..1e42b2f84 100644 --- a/wallet-webapps/src/main/webapp/vue-app/wallet-common/wallet-settings/main.js +++ b/wallet-webapps/src/main/webapp/vue-app/wallet-common/wallet-settings/main.js @@ -29,7 +29,7 @@ if (extensionRegistry) { Vue.use(WalletCommon); const lang = (eXo && eXo.env && eXo.env.portal && eXo.env.portal.language) || 'en'; -const url = `${eXo.env.portal.context}/${eXo.env.portal.rest}/i18n/bundle/locale.addon.Wallet-${lang}.json`; +const url = `/wallet/i18n/locale.addon.Wallet?lang=${lang}`; const appId = 'walletSettingsApp'; diff --git a/wallet-webapps/src/main/webapp/vue-app/wallet-reward/main.js b/wallet-webapps/src/main/webapp/vue-app/wallet-reward/main.js index 756904e09..e6b7ee17a 100644 --- a/wallet-webapps/src/main/webapp/vue-app/wallet-reward/main.js +++ b/wallet-webapps/src/main/webapp/vue-app/wallet-reward/main.js @@ -29,7 +29,7 @@ Vue.use(WalletCommon); const vuetify = new Vuetify(eXo.env.portal.vuetifyPreset); const lang = (eXo && eXo.env && eXo.env.portal && eXo.env.portal.language) || 'en'; -const url = `${eXo.env.portal.context}/${eXo.env.portal.rest}/i18n/bundle/locale.addon.Wallet-${lang}.json`; +const url = `/wallet/i18n/locale.addon.Wallet?lang=${lang}`; const appId = 'RewardApp'; diff --git a/wallet-webapps/src/main/webapp/vue-app/wallet-setup-admin/main.js b/wallet-webapps/src/main/webapp/vue-app/wallet-setup-admin/main.js index e34b6c12b..e5ae30cbb 100644 --- a/wallet-webapps/src/main/webapp/vue-app/wallet-setup-admin/main.js +++ b/wallet-webapps/src/main/webapp/vue-app/wallet-setup-admin/main.js @@ -20,7 +20,7 @@ import './initComponents.js'; const lang = window.eXo?.env?.portal?.language || 'en'; -const url = `${eXo.env.portal.context}/${eXo.env.portal.rest}/i18n/bundle/locale.addon.Wallet-${lang}.json`; +const url = `/wallet/i18n/locale.addon.Wallet?lang=${lang}`; const appId = 'WalletSetupAdmin'; Vue.use(WalletCommon); From 3b454f33ec30965d5e651c68fa49077517a02209 Mon Sep 17 00:00:00 2001 From: Boubaker Khanfir Date: Sun, 21 Jul 2024 15:50:52 +0100 Subject: [PATCH 4/4] feat: Implement Permanent Link API - Meeds-io/MIPs#134 --- .../exoplatform/wallet/utils/WalletUtils.java | 4 + .../plugin/WalletPermanentLinkPlugin.java | 91 +++++++++++++++++++ .../FundsRequestNotificationPlugin.java | 2 + .../WalletReceiverNotificationPlugin.java | 4 + .../WalletSenderNotificationPlugin.java | 2 + .../conf/portal/wallet-configuration.xml | 4 + 6 files changed, 107 insertions(+) create mode 100644 wallet-services/src/main/java/io/meeds/wallet/permlink/plugin/WalletPermanentLinkPlugin.java diff --git a/wallet-api/src/main/java/org/exoplatform/wallet/utils/WalletUtils.java b/wallet-api/src/main/java/org/exoplatform/wallet/utils/WalletUtils.java index d8deca886..9f8706b75 100644 --- a/wallet-api/src/main/java/org/exoplatform/wallet/utils/WalletUtils.java +++ b/wallet-api/src/main/java/org/exoplatform/wallet/utils/WalletUtils.java @@ -273,6 +273,8 @@ private WalletUtils() { public static final String AVATAR = "avatar"; + public static final String SENDER_ID = "senderIdentityId"; + public static final String SENDER = "sender"; public static final String USER = "userFullname"; @@ -283,6 +285,8 @@ private WalletUtils() { public static final String RECEIVER = "receiver"; + public static final String RECEIVER_ID = "receiverIdentityId"; + public static final String RECEIVER_URL = "receiverUrl"; public static final String FUNDS_ACCEPT_URL = "fundsAcceptUrl"; diff --git a/wallet-services/src/main/java/io/meeds/wallet/permlink/plugin/WalletPermanentLinkPlugin.java b/wallet-services/src/main/java/io/meeds/wallet/permlink/plugin/WalletPermanentLinkPlugin.java new file mode 100644 index 000000000..28b167fd3 --- /dev/null +++ b/wallet-services/src/main/java/io/meeds/wallet/permlink/plugin/WalletPermanentLinkPlugin.java @@ -0,0 +1,91 @@ +/** + * This file is part of the Meeds project (https://meeds.io/). + * + * Copyright (C) 2020 - 2024 Meeds Association contact@meeds.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package io.meeds.wallet.permlink.plugin; + +import org.exoplatform.commons.exception.ObjectNotFoundException; +import org.exoplatform.portal.config.UserPortalConfigService; +import org.exoplatform.services.security.Identity; +import org.exoplatform.social.core.space.model.Space; +import org.exoplatform.social.core.space.spi.SpaceService; +import org.exoplatform.wallet.model.Wallet; +import org.exoplatform.wallet.model.WalletType; +import org.exoplatform.wallet.service.WalletAccountService; +import org.exoplatform.wallet.utils.WalletUtils; + +import io.meeds.portal.permlink.model.PermanentLinkObject; +import io.meeds.portal.permlink.plugin.PermanentLinkPlugin; + +public class WalletPermanentLinkPlugin implements PermanentLinkPlugin { + + private static final String OBJECT_TYPE = "wallet"; + + public static final String URL_FORMAT = "/portal/%s/wallet"; + + private SpaceService spaceService; + + private WalletAccountService walletAccountService; + + private UserPortalConfigService portalConfigService; + + public WalletPermanentLinkPlugin(SpaceService spaceService, + WalletAccountService walletAccountService, + UserPortalConfigService portalConfigService) { + this.spaceService = spaceService; + this.walletAccountService = walletAccountService; + this.portalConfigService = portalConfigService; + } + + @Override + public String getObjectType() { + return OBJECT_TYPE; + } + + @Override + public boolean canAccess(PermanentLinkObject object, Identity identity) throws ObjectNotFoundException { + String identityId = object.getObjectId(); + Wallet wallet = walletAccountService.getWalletByIdentityId(Long.parseLong(identityId)); + return wallet != null && WalletUtils.canAccessWallet(wallet, identity.getUserId()); + } + + @Override + public String getDirectAccessUrl(PermanentLinkObject object) throws ObjectNotFoundException { + String identityId = object.getObjectId(); + Wallet wallet = walletAccountService.getWalletByIdentityId(Long.parseLong(identityId)); + String url = WalletType.isSpace(wallet.getType()) ? getSpaceUrl(spaceService.getSpaceByPrettyName(wallet.getName())) : + getProfileUrl(); + if (object.getParameters() != null && object.getParameters().containsKey("transactionHash")) { + url += "?hash=" + object.getParameters().get("transactionHash"); + } + return url; + } + + public String getSpaceUrl(Space space) { + StringBuilder spaceUrl = new StringBuilder("/portal/g/"); + spaceUrl.append(space.getGroupId().replace("/", ":")) + .append("/") + .append(space.getPrettyName()) + .append("/SpaceWallet"); + return spaceUrl.toString(); + } + + public String getProfileUrl() { + return String.format(URL_FORMAT, portalConfigService.getMetaPortal()); + } + +} diff --git a/wallet-services/src/main/java/org/exoplatform/wallet/notification/plugin/FundsRequestNotificationPlugin.java b/wallet-services/src/main/java/org/exoplatform/wallet/notification/plugin/FundsRequestNotificationPlugin.java index abc120b02..59f775173 100644 --- a/wallet-services/src/main/java/org/exoplatform/wallet/notification/plugin/FundsRequestNotificationPlugin.java +++ b/wallet-services/src/main/java/org/exoplatform/wallet/notification/plugin/FundsRequestNotificationPlugin.java @@ -94,7 +94,9 @@ protected NotificationInfo makeNotification(NotificationContext ctx) { .with(USER, requestSenderDetail.getName()) .with(USER_URL, getPermanentLink(requestSenderDetail)) .with(SENDER, requestSenderAccountDetail.getName()) + .with(SENDER_ID, String.valueOf(requestSenderAccountDetail.getTechnicalId())) .with(RECEIVER, requestReceiverAccountDetail.getName()) + .with(RECEIVER_ID, String.valueOf(requestReceiverAccountDetail.getTechnicalId())) .with(SYMBOL, symbol) .with(MESSAGE, message) .key(getKey()) diff --git a/wallet-services/src/main/java/org/exoplatform/wallet/notification/plugin/WalletReceiverNotificationPlugin.java b/wallet-services/src/main/java/org/exoplatform/wallet/notification/plugin/WalletReceiverNotificationPlugin.java index 16dabda2c..b8b7354f4 100644 --- a/wallet-services/src/main/java/org/exoplatform/wallet/notification/plugin/WalletReceiverNotificationPlugin.java +++ b/wallet-services/src/main/java/org/exoplatform/wallet/notification/plugin/WalletReceiverNotificationPlugin.java @@ -28,10 +28,12 @@ import static org.exoplatform.wallet.utils.WalletUtils.MESSAGE_PARAMETER; import static org.exoplatform.wallet.utils.WalletUtils.RECEIVER; import static org.exoplatform.wallet.utils.WalletUtils.RECEIVER_ACCOUNT_DETAIL_PARAMETER; +import static org.exoplatform.wallet.utils.WalletUtils.RECEIVER_ID; import static org.exoplatform.wallet.utils.WalletUtils.RECEIVER_TYPE; import static org.exoplatform.wallet.utils.WalletUtils.RECEIVER_URL; import static org.exoplatform.wallet.utils.WalletUtils.SENDER; import static org.exoplatform.wallet.utils.WalletUtils.SENDER_ACCOUNT_DETAIL_PARAMETER; +import static org.exoplatform.wallet.utils.WalletUtils.SENDER_ID; import static org.exoplatform.wallet.utils.WalletUtils.SENDER_URL; import static org.exoplatform.wallet.utils.WalletUtils.SYMBOL; import static org.exoplatform.wallet.utils.WalletUtils.SYMBOL_PARAMETER; @@ -114,7 +116,9 @@ protected NotificationInfo makeNotification(NotificationContext ctx) { .with(SENDER_URL, getPermanentLink(senderAccountDetail)) .with(RECEIVER_URL, getPermanentLink(receiverAccountDetail)) .with(SENDER, senderAccountDetail.getName()) + .with(SENDER_ID, String.valueOf(senderAccountDetail.getTechnicalId())) .with(RECEIVER, receiverAccountDetail.getName()) + .with(RECEIVER_ID, String.valueOf(receiverAccountDetail.getTechnicalId())) .key(getKey()) .end(); } diff --git a/wallet-services/src/main/java/org/exoplatform/wallet/notification/plugin/WalletSenderNotificationPlugin.java b/wallet-services/src/main/java/org/exoplatform/wallet/notification/plugin/WalletSenderNotificationPlugin.java index 59fc52c04..b8203f472 100644 --- a/wallet-services/src/main/java/org/exoplatform/wallet/notification/plugin/WalletSenderNotificationPlugin.java +++ b/wallet-services/src/main/java/org/exoplatform/wallet/notification/plugin/WalletSenderNotificationPlugin.java @@ -99,7 +99,9 @@ protected NotificationInfo makeNotification(NotificationContext ctx) { .with(SENDER_URL, getPermanentLink(senderAccountDetail)) .with(RECEIVER_URL, getPermanentLink(receiverAccountDetail)) .with(SENDER, senderAccountDetail.getName()) + .with(SENDER_ID, String.valueOf(senderAccountDetail.getTechnicalId())) .with(RECEIVER, receiverAccountDetail.getName()) + .with(RECEIVER_ID, String.valueOf(receiverAccountDetail.getTechnicalId())) .key(getKey()) .end(); } diff --git a/wallet-services/src/main/resources/conf/portal/wallet-configuration.xml b/wallet-services/src/main/resources/conf/portal/wallet-configuration.xml index 0fe7f7467..c447396c6 100644 --- a/wallet-services/src/main/resources/conf/portal/wallet-configuration.xml +++ b/wallet-services/src/main/resources/conf/portal/wallet-configuration.xml @@ -20,6 +20,10 @@ --> + + io.meeds.wallet.permlink.plugin.WalletPermanentLinkPlugin + + WalletMetamaskFeatureProperties org.exoplatform.container.ExtendedPropertyConfigurator