Skip to content
Snippets Groups Projects
Commit f0c6ddc4 authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

Merge branch 'release/1.10.8'

parents af8097ec e7caa565
No related branches found
No related tags found
No related merge requests found
Pipeline #33297 failed
......@@ -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>
......
......@@ -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>
......
......@@ -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>
......
......@@ -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 -- */
......
......@@ -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>
......
......@@ -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>
......
......@@ -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>
......
......@@ -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>
......
......@@ -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>
......
......@@ -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
......
......@@ -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 ""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment