Skip to content

Commit

Permalink
Merge branch 'release/1.10.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
blavenie committed Sep 15, 2023
2 parents af8097e + e7caa56 commit f0c6ddc
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 38 deletions.
2 changes: 1 addition & 1 deletion cesium-plus-pod-assembly/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion cesium-plus-pod-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion cesium-plus-pod-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@

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;
Expand Down Expand Up @@ -217,53 +219,78 @@ public void onChange(ChangeEvent change) {
}

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 -- */
Expand Down
2 changes: 1 addition & 1 deletion cesium-plus-pod-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion cesium-plus-pod-subscription/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion cesium-plus-pod-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion cesium-plus-pod-user/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
10 changes: 4 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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>

Expand Down Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/release-to-github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down

0 comments on commit f0c6ddc

Please sign in to comment.