diff --git a/cesium-plus-pod-assembly/pom.xml b/cesium-plus-pod-assembly/pom.xml index f6663b7b763af36b9480dd44f004e52621683917..e1aedde99a3fbaa52a3338835bed36bb0a290a11 100644 --- a/cesium-plus-pod-assembly/pom.xml +++ b/cesium-plus-pod-assembly/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.duniter.cesium</groupId> <artifactId>cesium-plus-pod</artifactId> - <version>1.10.7</version> + <version>1.10.8</version> </parent> <artifactId>cesium-plus-pod-assembly</artifactId> diff --git a/cesium-plus-pod-client/pom.xml b/cesium-plus-pod-client/pom.xml index dfdc1bdeab9b7325c5ac5378d792d4d0cb44ee24..2b031873ed4a05d732f8aa255a4376c75cd53244 100644 --- a/cesium-plus-pod-client/pom.xml +++ b/cesium-plus-pod-client/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.duniter.cesium</groupId> <artifactId>cesium-plus-pod</artifactId> - <version>1.10.7</version> + <version>1.10.8</version> </parent> <artifactId>cesium-plus-pod-client</artifactId> diff --git a/cesium-plus-pod-core/pom.xml b/cesium-plus-pod-core/pom.xml index 9ed354aa3d4646e7166625ba05138dedaf4b9042..3d473e4327d41c2f09ff6a3e27a2bc3508da6b87 100644 --- a/cesium-plus-pod-core/pom.xml +++ b/cesium-plus-pod-core/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.duniter.cesium</groupId> <artifactId>cesium-plus-pod</artifactId> - <version>1.10.7</version> + <version>1.10.8</version> </parent> <artifactId>cesium-plus-pod-core</artifactId> diff --git a/cesium-plus-pod-core/src/main/java/org/duniter/elasticsearch/service/WotService.java b/cesium-plus-pod-core/src/main/java/org/duniter/elasticsearch/service/WotService.java index 44298834d7829e08fee9774214958865f7d9c9f9..cb31fbd0b1a07b1e77c417ff9efd6ac7f081a10b 100644 --- a/cesium-plus-pod-core/src/main/java/org/duniter/elasticsearch/service/WotService.java +++ b/cesium-plus-pod-core/src/main/java/org/duniter/elasticsearch/service/WotService.java @@ -24,9 +24,11 @@ package org.duniter.elasticsearch.service; import com.google.common.collect.ImmutableList; import com.google.common.collect.Maps; +import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.lang3.mutable.MutableInt; import org.duniter.core.client.model.bma.BlockchainParameters; import org.duniter.core.client.model.bma.WotRequirements; +import org.duniter.core.client.model.local.Identity; import org.duniter.core.client.model.local.Member; import org.duniter.core.client.repositories.CurrencyRepository; import org.duniter.core.client.service.bma.WotRemoteService; @@ -217,53 +219,78 @@ public class WotService extends AbstractService { } public boolean isOrWasMember(String pubkey) { + return Beans.getStream(currencyRepository.findAllIds()) + .anyMatch(currencyId -> this.isOrWasMember(currencyId, pubkey)); + } - - String[] currencyIds = Beans.getStream(currencyRepository.findAllIds()).toArray(String[]::new); - if (ArrayUtils.isEmpty(currencyIds)) return false; + public boolean isOrWasMember(String currency, String pubkey) { + final String currencyId = safeGetCurrency(currency); + if (StringUtils.isBlank(currencyId)) return false; SearchResponse response = client.prepareSearch() - .setIndices(currencyIds) - .setSize(0) // only need the total - .setTypes(MemberRepository.TYPE) - .setQuery(QueryBuilders.idsQuery().ids(pubkey)) - .setRequestCache(true) - .execute().actionGet(); + .setIndices(currencyId) + .setSize(0) // only need the total + .setTypes(MemberRepository.TYPE) + .setQuery(QueryBuilders.idsQuery().ids(pubkey)) + .setRequestCache(true) + .execute().actionGet(); return response.getHits() != null && response.getHits().getTotalHits() > 0; } public boolean isMember(String pubkey) { + return Beans.getStream(currencyRepository.findAllIds()) + .anyMatch(currencyId -> this.isMember(currencyId, pubkey)); + } - String[] currencyIds = Beans.getStream(currencyRepository.findAllIds()).toArray(String[]::new); - if (ArrayUtils.isEmpty(currencyIds)) return false; + public boolean isMember(String currency, String pubkey) { + + final String currencyId = safeGetCurrency(currency); QueryBuilder query = QueryBuilders.constantScoreQuery(QueryBuilders.boolQuery() - .filter(QueryBuilders.idsQuery().addIds(pubkey)) - .filter(QueryBuilders.termQuery(Member.Fields.IS_MEMBER, true)) + .filter(QueryBuilders.idsQuery().addIds(pubkey)) + .filter(QueryBuilders.termQuery(Member.Fields.IS_MEMBER, true)) ); SearchResponse response = client.prepareSearch() - .setIndices(currencyIds) - .setSize(0) // only need the total - .setTypes(MemberRepository.TYPE) - .setQuery(query) - .setRequestCache(true) - .execute().actionGet(); + .setIndices(currencyId) + .setSize(0) // only need the total + .setTypes(MemberRepository.TYPE) + .setQuery(query) + .setRequestCache(true) + .execute().actionGet(); return response.getHits() != null && response.getHits().getTotalHits() > 0; } public List<WotRequirements> getRequirements(String currency, String pubkey) { waitReady(); - final String currencyId = safeGetCurrency(currency); - return this.wotRemoteService.getRequirements(currencyId, pubkey); } - public Optional<Member> getMemberByPubkey(String currencyId, String pubkey) { - return this.memberRepository.getMemberByPubkey(currencyId, pubkey); + public Optional<Member> getMemberByPubkey(String currency, String pubkey) { + final String currencyId = safeGetCurrency(currency); + + if (isBlockchainReady(currencyId)) { + return this.memberRepository.getMemberByPubkey(currencyId, pubkey); + } + // Fallback to remote duniter node (e.g. Blockchain not yet indexed) + else { + Identity source = this.wotRemoteService.getIdentity(currencyId, pubkey); + if (source == null + || !currencyId.equals(source.getCurrency()) + || (!source.getIsMember() && source.getWasMember())) return Optional.empty(); // Not a member + + Member target = new Member(); + target.setPubkey(pubkey); + target.setCurrency(currencyId); + target.setUid(source.getUid()); + target.setIsMember(source.getIsMember()); + target.setWasMember(source.getWasMember()); + target.setTimestamp(source.getTimestamp()); + return Optional.of(target); + } } /* -- protected methods -- */ diff --git a/cesium-plus-pod-model/pom.xml b/cesium-plus-pod-model/pom.xml index f8c9c3f87439194b001a700d64e67cc984203822..6fe640416286494b5e93e2782fffe22817ef667a 100644 --- a/cesium-plus-pod-model/pom.xml +++ b/cesium-plus-pod-model/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.duniter.cesium</groupId> <artifactId>cesium-plus-pod</artifactId> - <version>1.10.7</version> + <version>1.10.8</version> </parent> <artifactId>cesium-plus-pod-model</artifactId> diff --git a/cesium-plus-pod-subscription/pom.xml b/cesium-plus-pod-subscription/pom.xml index 4cf0b45fe9cd6ef3f074e34ebfe443dd78c2f38d..7a212a3487d7ad18bec1e047ac42df19375e6eb3 100644 --- a/cesium-plus-pod-subscription/pom.xml +++ b/cesium-plus-pod-subscription/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.duniter.cesium</groupId> <artifactId>cesium-plus-pod</artifactId> - <version>1.10.7</version> + <version>1.10.8</version> </parent> <artifactId>cesium-plus-pod-subscription</artifactId> diff --git a/cesium-plus-pod-test/pom.xml b/cesium-plus-pod-test/pom.xml index 5bca76441828ba0931ec32e2a30b2b1d22c61d78..4d672e6384be7b950b1948edeec894850d4a3007 100644 --- a/cesium-plus-pod-test/pom.xml +++ b/cesium-plus-pod-test/pom.xml @@ -3,7 +3,7 @@ <parent> <groupId>org.duniter.cesium</groupId> <artifactId>cesium-plus-pod</artifactId> - <version>1.10.7</version> + <version>1.10.8</version> </parent> <modelVersion>4.0.0</modelVersion> diff --git a/cesium-plus-pod-user/pom.xml b/cesium-plus-pod-user/pom.xml index cb08d01718a1626642c7191d020e13437e639632..e72357eed03d7610067eacf50a027563fb7a8539 100644 --- a/cesium-plus-pod-user/pom.xml +++ b/cesium-plus-pod-user/pom.xml @@ -3,7 +3,7 @@ <parent> <artifactId>cesium-plus-pod</artifactId> <groupId>org.duniter.cesium</groupId> - <version>1.10.7</version> + <version>1.10.8</version> </parent> <modelVersion>4.0.0</modelVersion> diff --git a/pom.xml b/pom.xml index 34dde6c04958af3ee0a073f70766198415d35248..74e31d98d723ce8d94b4881a3b23a8ff3db0b337 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ <groupId>org.duniter.cesium</groupId> <artifactId>cesium-plus-pod</artifactId> - <version>1.10.7</version> + <version>1.10.8</version> <packaging>pom</packaging> <name>Cesium+ pod</name> <description>Cesium+ pod :: An ElasticSearch cluster for Duniter network</description> @@ -20,13 +20,12 @@ </prerequisites> <properties> + <!-- source file encoding --> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <file.encoding>UTF-8</file.encoding> <!-- Project properties --> <javaVersion>11</javaVersion> - <signatureArtifactId>java18</signatureArtifactId> - <signatureVersion>1.0</signatureVersion> <!-- Commons versions --> <duniter4j.version>1.5.10</duniter4j.version> @@ -109,7 +108,7 @@ <!-- I18n configuration --> <i18n.bundles>fr_FR,en_GB</i18n.bundles> <i18n.silent>true</i18n.silent> - + <!-- by default, use maven 2 source base dir --> <maven.src.dir>${basedir}/src</maven.src.dir> @@ -475,8 +474,7 @@ <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> - <version>1.5.0</version> - + <version>${execPluginVersion}</version> </plugin> <plugin> diff --git a/src/scripts/release-to-github.sh b/src/scripts/release-to-github.sh index b17d894390cf5fee3c6b9da90a57074c536be90b..430570fabc2a557509c14f2b932111ef94e0b2a1 100755 --- a/src/scripts/release-to-github.sh +++ b/src/scripts/release-to-github.sh @@ -112,7 +112,7 @@ case "$task" in result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: application/zip' -T "${ZIP_FILE}" "${upload_url}?name=${ZIP_BASENAME}") browser_download_url=`echo "$result" | grep -P "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+"` ZIP_SHA256=$(sha256sum "${ZIP_FILE}" | sed 's/ /\n/gi' | head -n 1) - echo " - $browser_download_url | SHA256: ${SHA256}" + echo " - $browser_download_url | SHA256: ${ZIP_SHA256}" # Send Checksum file SHA_BASENAME=${ZIP_BASENAME}.sha256 diff --git a/src/scripts/release.sh b/src/scripts/release.sh index 43c267672e95d77f48f81a17e082f7d9cf12c117..c934641fb74ff4bd28056b235cf0d7c44616c0a8 100755 --- a/src/scripts/release.sh +++ b/src/scripts/release.sh @@ -69,7 +69,7 @@ echo "" echo "---- Removing local release branch ..." echo "" git branch -d "release/$version" -# NOTE: can fail, but continu +# NOTE: can fail, but continue echo "---- Uploading artifacts to Github..." echo ""