Skip to content

Commit

Permalink
Added Deep Stone Crypt encounter maps (#63)
Browse files Browse the repository at this point in the history
* First commit

* This new branch will be the one with the actual changes

* deleted old packages and database related stuff

* created new directory for deep stone crypt raid. Added maps for each encounter

* fixed units/some integrations tests

* Finished setting up the raid-stats command

* fixed merge conflicts. Deleted 'generated' directory

---------

Co-authored-by: Daniel Villavicencio <danielvillavicencio@Daniels-MBP.attlocal.net>
  • Loading branch information
JVilla1997 and Daniel Villavicencio authored Feb 16, 2024
1 parent 4c5b101 commit 5952b9e
Show file tree
Hide file tree
Showing 109 changed files with 1,179 additions and 1,710 deletions.
11 changes: 0 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ plugins {
id 'org.springframework.boot' version '3.2.0'
id 'io.spring.dependency-management' version '1.1.3'
id 'org.asciidoctor.jvm.convert' version '3.3.2'
id 'org.flywaydb.flyway' version '10.0.0'
}

group = 'com.danielvm'
Expand Down Expand Up @@ -57,36 +56,26 @@ jar {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-data-r2dbc'
implementation 'org.springframework.session:spring-session-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-devtools'
implementation "net.i2p.crypto:eddsa:${i2pCryptoVersion}"
implementation "commons-io:commons-io:${IOCommonsVersion}"
implementation "org.projectlombok:lombok:${lombokVersion}"
implementation "org.aspectj:aspectjrt:${aspectJRTVersion}"
implementation "org.flywaydb:flyway-core:${flywayCoreVersion}"
implementation "org.postgresql:postgresql:${postgresqlVersion}"
implementation "org.postgresql:r2dbc-postgresql:${postgresR2dbcVersion}"
implementation "org.aspectj:aspectjweaver:${aspectJWeaverVersion}"
implementation "commons-codec:commons-codec:${commonsCodecVersion}"
implementation "software.pando.crypto:salty-coffee:${pandoCryptoVersion}"
implementation "org.apache.commons:commons-collections4:${apacheCollectionsVersion}"
implementation "org.flywaydb:flyway-database-postgresql:${flywayPostgresVersion}"
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.cloud:spring-cloud-starter-contract-stub-runner'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation "org.testcontainers:jdbc:${tcJdbcVersion}"
testImplementation "org.testcontainers:r2dbc:${tcR2dbcVersion}"
testImplementation "org.testcontainers:postgresql:${tcPostgresVersion}"
testImplementation "org.testcontainers:junit-jupiter:${tcJunitVersion}"
testImplementation "io.projectreactor:reactor-test:${reactorTestVersion}"
testImplementation "org.testcontainers:testcontainers:${testContainersVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${junitJupiterParamsVersion}"
testImplementation "org.flywaydb.flyway-test-extensions:flyway-spring-test:${flywayTestVersion}"
}

dependencyManagement {
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/com/danielvm/destiny2bot/Destiny2botApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

import com.danielvm.destiny2bot.exception.ExternalServiceException;
import com.danielvm.destiny2bot.exception.InternalServerException;
import com.danielvm.destiny2bot.filter.CachingRequestBodyFilter;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import java.nio.charset.StandardCharsets;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
Expand Down Expand Up @@ -44,14 +42,6 @@ CacheManager inMemoryCacheManager() {
return new ConcurrentMapCacheManager();
}

@Bean
public FilterRegistrationBean<CachingRequestBodyFilter> signatureValidationFilterBean() {
FilterRegistrationBean<CachingRequestBodyFilter> registrationBean = new FilterRegistrationBean<>();
registrationBean.setFilter(new CachingRequestBodyFilter());
registrationBean.addUrlPatterns("/interactions");
return registrationBean;
}

/**
* Prepares a WebClient.Builder bean that has standard status handlers
*
Expand Down

This file was deleted.

36 changes: 32 additions & 4 deletions src/main/java/com/danielvm/destiny2bot/client/BungieClient.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package com.danielvm.destiny2bot.client;

import com.danielvm.destiny2bot.dto.destiny.GenericResponse;
import com.danielvm.destiny2bot.dto.destiny.ActivitiesResponse;
import com.danielvm.destiny2bot.dto.destiny.BungieResponse;
import com.danielvm.destiny2bot.dto.destiny.MemberGroupResponse;
import com.danielvm.destiny2bot.dto.destiny.PostGameCarnageReport;
import com.danielvm.destiny2bot.dto.destiny.SearchResult;
import com.danielvm.destiny2bot.dto.destiny.UserGlobalSearchBody;
import com.danielvm.destiny2bot.dto.destiny.characters.CharactersResponse;
import com.danielvm.destiny2bot.dto.destiny.manifest.ResponseFields;
import com.danielvm.destiny2bot.dto.destiny.membership.MembershipResponse;
Expand All @@ -10,8 +15,11 @@
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.service.annotation.GetExchange;
import org.springframework.web.service.annotation.PostExchange;
import reactor.core.publisher.Mono;

/**
Expand Down Expand Up @@ -47,7 +55,7 @@ Mono<MembershipResponse> getMembershipInfoForCurrentUser(
* @return {@link Mono} of {@link ResponseFields}
*/
@GetExchange("/Destiny2/Manifest/{entityType}/{hashIdentifier}/")
Mono<GenericResponse<ResponseFields>> getManifestEntityRx(
Mono<BungieResponse<ResponseFields>> getManifestEntityRx(
@PathVariable(value = "entityType") String entityType,
@PathVariable(value = "hashIdentifier") String hashIdentifier);

Expand All @@ -57,7 +65,7 @@ Mono<GenericResponse<ResponseFields>> getManifestEntityRx(
* @return {@link Mono} of Map of {@link MilestoneEntry}
*/
@GetExchange("/Destiny2/Milestones/")
Mono<GenericResponse<Map<String, MilestoneEntry>>> getPublicMilestonesRx();
Mono<BungieResponse<Map<String, MilestoneEntry>>> getPublicMilestonesRx();

/**
* Get a user characters
Expand All @@ -67,9 +75,29 @@ Mono<GenericResponse<ResponseFields>> getManifestEntityRx(
* @return {@link Mono} containing {@link CharactersResponse}
*/
@GetExchange("/Destiny2/{membershipType}/Profile/{destinyMembershipId}/?components=200")
Mono<GenericResponse<CharactersResponse>> getUserCharacters(
Mono<BungieResponse<CharactersResponse>> getUserCharacters(
@PathVariable Integer membershipType,
@PathVariable String destinyMembershipId
);

@PostExchange("/User/Search/GlobalName/{page}/")
Mono<BungieResponse<SearchResult>> searchByGlobalName(
@RequestBody UserGlobalSearchBody searchBody,
@PathVariable Integer page);

@GetExchange("/GroupV2/User/{membershipType}/{membershipId}/{filter}/{groupType}/")
Mono<BungieResponse<MemberGroupResponse>> getGroupsForMember(
@PathVariable Integer membershipType, @PathVariable String membershipId,
@PathVariable Integer filter, @PathVariable Integer groupType
);

@GetExchange("/Destiny2/{membershipType}/Account/{destinyMembershipId}/Character/{characterId}/Stats/Activities/")
Mono<BungieResponse<ActivitiesResponse>> getActivityHistory(@PathVariable Integer membershipType,
@PathVariable String destinyMembershipId, @PathVariable String characterId,
@RequestParam Integer count, @RequestParam Integer mode, @RequestParam Integer page);

@GetExchange("/Destiny2/Stats/PostGameCarnageReport/{activityId}/")
Mono<BungieResponse<PostGameCarnageReport>> getPostGameCarnageReport(
@PathVariable Long activityId
);
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
package com.danielvm.destiny2bot.client;

import com.danielvm.destiny2bot.dto.destiny.GenericResponse;
import com.danielvm.destiny2bot.dto.destiny.BungieResponse;
import com.danielvm.destiny2bot.dto.destiny.manifest.ResponseFields;
import com.danielvm.destiny2bot.enums.ManifestEntity;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;

@Service
@RequiredArgsConstructor
@Slf4j
public class BungieClientWrapper {

private final BungieClient bungieClient;
private final BungieClient defaultBungieClient;

public BungieClientWrapper(BungieClient defaultBungieClient) {
this.defaultBungieClient = defaultBungieClient;
}

/**
* Wraps the client call to the Manifest with a Cacheable method
*
* @param entityType The entity type (see
* {@link ManifestEntity})
* @param entityType The entity type (see {@link ManifestEntity})
* @param hashIdentifier The hash identifier
* @return {@link GenericResponse} of {@link ResponseFields}
* @return {@link BungieResponse} of {@link ResponseFields}
*/
@Cacheable(cacheNames = "entity", cacheManager = "inMemoryCacheManager")
public Mono<GenericResponse<ResponseFields>> getManifestEntityRx(
public Mono<BungieResponse<ResponseFields>> getManifestEntityRx(
ManifestEntity entityType, String hashIdentifier) {
return bungieClient.getManifestEntityRx(entityType.getId(), hashIdentifier).cache();
return defaultBungieClient.getManifestEntityRx(entityType.getId(), hashIdentifier).cache();
}

}
12 changes: 11 additions & 1 deletion src/main/java/com/danielvm/destiny2bot/client/DiscordClient.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.danielvm.destiny2bot.client;

import com.danielvm.destiny2bot.dto.discord.DiscordUserResponse;
import com.danielvm.destiny2bot.dto.discord.InteractionResponseData;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.service.annotation.GetExchange;
import org.springframework.web.service.annotation.PatchExchange;
import reactor.core.publisher.Mono;

/**
Expand All @@ -21,4 +25,10 @@ public interface DiscordClient {
@GetExchange("/users/@me")
Mono<DiscordUserResponse> getUser(
@RequestHeader(HttpHeaders.AUTHORIZATION) String bearerToken);

@PatchExchange(value = "/webhooks/{applicationId}/{interactionToken}/messages/@original", contentType = MediaType.APPLICATION_JSON_VALUE)
Mono<Void> editOriginalInteraction(
@PathVariable Long applicationId,
@PathVariable String interactionToken,
@RequestBody InteractionResponseData data);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.client.reactive.ClientHttpConnector;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.reactive.function.client.support.WebClientAdapter;
import org.springframework.web.service.invoker.HttpServiceProxyFactory;
Expand Down Expand Up @@ -39,6 +43,11 @@ public class BungieConfiguration implements OAuth2Configuration {
*/
private String baseUrl;

/**
* Base URL for stats endpoint
*/
private String statsBaseUrl;

/**
* Url for Bungie Token endpoint
*/
Expand All @@ -54,11 +63,29 @@ public class BungieConfiguration implements OAuth2Configuration {
*/
private String callbackUrl;

@Bean
@Bean("defaultBungieClient")
public BungieClient bungieCharacterClient(WebClient.Builder builder) {
var webClient = builder
.baseUrl(this.baseUrl)
.defaultHeader(API_KEY_HEADER_NAME, this.key)
.codecs(clientCodecConfigurer -> clientCodecConfigurer.defaultCodecs()
.maxInMemorySize(1024 * 1024))
.build();
return HttpServiceProxyFactory.builder()
.exchangeAdapter(WebClientAdapter.create(webClient))
.build()
.createClient(BungieClient.class);
}

@Bean(name = "pgcrBungieClient")
public BungieClient pgcrBungieClient(WebClient.Builder builder) {
var webClient = builder
.baseUrl(this.statsBaseUrl)
.defaultHeader(API_KEY_HEADER_NAME, this.key)
.defaultHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.codecs(clientCodecConfigurer -> clientCodecConfigurer.defaultCodecs()
.maxInMemorySize(1024 * 1024 * 15))
.build();
return HttpServiceProxyFactory.builder()
.exchangeAdapter(WebClientAdapter.create(webClient))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public class DiscordConfiguration implements OAuth2Configuration {
*/
private List<String> scopes;

/**
* The applicationId for the discord bot
*/
private Long applicationId;

@Bean
public DiscordClient discordClient(WebClient.Builder defaultBuilder) {
var webClient = defaultBuilder
Expand Down

This file was deleted.

Loading

0 comments on commit 5952b9e

Please sign in to comment.