Uses JWT, fixes some endpoints, adds base services

This commit is contained in:
Guillaume Tâche
2025-04-24 20:38:09 +02:00
parent 8a05f63687
commit a8e7a62b0c
113 changed files with 1625 additions and 380 deletions

View File

@@ -15,6 +15,7 @@
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id> <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.21.2</quarkus.platform.version> <quarkus.platform.version>3.21.2</quarkus.platform.version>
<skipITs>true</skipITs> <skipITs>true</skipITs>
<jwt.version>4.5.0</jwt.version>
<steamworks.version>1.9.0</steamworks.version> <steamworks.version>1.9.0</steamworks.version>
<surefire-plugin.version>3.5.2</surefire-plugin.version> <surefire-plugin.version>3.5.2</surefire-plugin.version>
</properties> </properties>
@@ -42,6 +43,11 @@
<artifactId>steamworks4j-server</artifactId> <artifactId>steamworks4j-server</artifactId>
<version>${steamworks.version}</version> <version>${steamworks.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>${jwt.version}</version>
</dependency>
<dependency> <dependency>
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
<artifactId>quarkus-rest</artifactId> <artifactId>quarkus-rest</artifactId>

View File

@@ -0,0 +1,31 @@
package ch.gtache.elderscrollslegends.service;
import ch.gtache.elderscrollslegends.service.account.AccountService;
import jakarta.ws.rs.NotAuthorizedException;
import java.util.Objects;
public class BaseEndpoints {
private final AccountService accountService;
protected BaseEndpoints(final AccountService accountService) {
this.accountService = Objects.requireNonNull(accountService);
}
protected AccountService accountService() {
return accountService;
}
protected String authenticateOrThrow(final String bearerToken) {
if (bearerToken == null || !bearerToken.startsWith("Bearer ")) {
throw new NotAuthorizedException("Invalid token", "Bearer");
}
final var token = bearerToken.replace("Bearer ", "");
final var steamID = accountService.getSteamIDFromToken(token);
if (steamID == null) {
throw new NotAuthorizedException("Invalid token", "Bearer");
}
return steamID;
}
}

View File

@@ -0,0 +1,17 @@
package ch.gtache.elderscrollslegends.service;
import javax.sql.DataSource;
import java.util.Objects;
public class BaseService {
private final DataSource dataSource;
protected BaseService(final DataSource dataSource) {
this.dataSource = Objects.requireNonNull(dataSource);
}
protected DataSource dataSource() {
return dataSource;
}
}

View File

@@ -0,0 +1,4 @@
package ch.gtache.elderscrollslegends.service;
public record Card(int hash) {
}

View File

@@ -0,0 +1,20 @@
package ch.gtache.elderscrollslegends.service;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javax.sql.DataSource;
@ApplicationScoped
public class CardService extends BaseService {
@Inject
CardService(final DataSource dataSource) {
super(dataSource);
}
public Card getCard(final int hash) {
// TODO
return new Card(hash);
}
}

View File

@@ -0,0 +1,20 @@
package ch.gtache.elderscrollslegends.service;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javax.sql.DataSource;
@ApplicationScoped
public class ClassService extends BaseService {
@Inject
ClassService(final DataSource dataSource) {
super(dataSource);
}
public Clazz getClass(final int hash) {
// TODO
return new Clazz(hash);
}
}

View File

@@ -0,0 +1,4 @@
package ch.gtache.elderscrollslegends.service;
public record Clazz(int hash) {
}

View File

@@ -0,0 +1,20 @@
package ch.gtache.elderscrollslegends.service;
import ch.gtache.elderscrollslegends.service.inventory.Deck;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javax.sql.DataSource;
@ApplicationScoped
public class DeckService extends BaseService {
@Inject
DeckService(final DataSource dataSource) {
super(dataSource);
}
public Deck getDeck(final String steamID, final long deckID) {
return null;
}
}

View File

@@ -1,12 +1,25 @@
package ch.gtache.elderscrollslegends.service; package ch.gtache.elderscrollslegends.service;
import com.codedisaster.steamworks.*; import com.codedisaster.steamworks.SteamAPI;
import com.codedisaster.steamworks.SteamAuth;
import com.codedisaster.steamworks.SteamAuthTicket;
import com.codedisaster.steamworks.SteamException;
import com.codedisaster.steamworks.SteamGameServer;
import com.codedisaster.steamworks.SteamGameServerAPI;
import com.codedisaster.steamworks.SteamGameServerCallback;
import com.codedisaster.steamworks.SteamID;
import com.codedisaster.steamworks.SteamResult;
import com.codedisaster.steamworks.SteamUser;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.Arrays; import java.util.Arrays;
import java.util.HexFormat; import java.util.HexFormat;
public class Main { public final class Main {
private Main() {
}
public static void main(String[] args) throws SteamException, InterruptedException { public static void main(String[] args) throws SteamException, InterruptedException {
SteamGameServerAPI.loadLibraries(); SteamGameServerAPI.loadLibraries();

View File

@@ -0,0 +1,21 @@
package ch.gtache.elderscrollslegends.service;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.ws.rs.Produces;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import java.time.Duration;
@ApplicationScoped
class Providers {
Providers() {
}
@Produces
@ApplicationScoped
static Duration providesTimeToLive(@ConfigProperty(name = "jwt.token.ttl.seconds") final int ttl) {
return Duration.ofSeconds(ttl);
}
}

View File

@@ -1,4 +0,0 @@
package ch.gtache.elderscrollslegends.service.account;
public record ABTestingSet(String setKey, String groupKey) {
}

View File

@@ -1,10 +1,10 @@
package ch.gtache.elderscrollslegends.service.account; package ch.gtache.elderscrollslegends.service.account;
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
import ch.gtache.elderscrollslegends.service.SteamService; import ch.gtache.elderscrollslegends.service.SteamService;
import ch.gtache.elderscrollslegends.service.account.auth.AuthBNETGamecodeRequest; import ch.gtache.elderscrollslegends.service.account.auth.AuthBNETGamecodeRequest;
import ch.gtache.elderscrollslegends.service.account.auth.AuthBNETSteamRequest; import ch.gtache.elderscrollslegends.service.account.auth.AuthBNETSteamRequest;
import ch.gtache.elderscrollslegends.service.account.auth.AuthResult; import ch.gtache.elderscrollslegends.service.account.auth.AuthResult;
import ch.gtache.elderscrollslegends.service.account.auth.LogoutSteamRequest;
import ch.gtache.elderscrollslegends.service.account.check.CheckEmailRequest; import ch.gtache.elderscrollslegends.service.account.check.CheckEmailRequest;
import ch.gtache.elderscrollslegends.service.account.check.CheckEmailResponse; import ch.gtache.elderscrollslegends.service.account.check.CheckEmailResponse;
import ch.gtache.elderscrollslegends.service.account.check.CheckEmailResponseBody; import ch.gtache.elderscrollslegends.service.account.check.CheckEmailResponseBody;
@@ -27,17 +27,16 @@ import java.util.List;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;
@Path("/account") @Path("/account")
public class AccountEndpoints { public class AccountEndpoints extends BaseEndpoints {
private static final Logger logger = Logger.getLogger(AccountEndpoints.class); private static final Logger logger = Logger.getLogger(AccountEndpoints.class);
private final SteamService steamService; private final SteamService steamService;
private final AccountService accountService;
@Inject @Inject
AccountEndpoints(final SteamService steamService, final AccountService accountService) { AccountEndpoints(final AccountService accountService, final SteamService steamService) {
super(accountService);
this.steamService = requireNonNull(steamService); this.steamService = requireNonNull(steamService);
this.accountService = requireNonNull(accountService);
} }
@POST @POST
@@ -49,7 +48,7 @@ public class AccountEndpoints {
try { try {
if (steamService.authenticate(request.sessionTicket(), request.steamId())) { if (steamService.authenticate(request.sessionTicket(), request.steamId())) {
logger.info("SteamLogin succeeded for " + request); logger.info("SteamLogin succeeded for " + request);
final var data = accountService.authenticate(request.steamId()); final var data = accountService().authenticate(request.steamId());
return new AuthResult(data, 0, null, List.of()); return new AuthResult(data, 0, null, List.of());
} else { } else {
return new AuthResult(null, 2, "SteamLogin failed", List.of()); return new AuthResult(null, 2, "SteamLogin failed", List.of());
@@ -63,9 +62,11 @@ public class AccountEndpoints {
@POST @POST
@Path("bnetSteamLogout") @Path("bnetSteamLogout")
@Consumes("application/json") @Consumes("application/json")
public void steamLogout(final LogoutSteamRequest request) { public void steamLogout(@HeaderParam("Authorization") final String authentication) {
logger.info("SteamLogout called : " + request); logger.info("SteamLogout called");
steamService.endAuthSession(request.steamId()); final var steamID = authenticateOrThrow(authentication);
logger.info("SteamLogout called by " + steamID);
steamService.endAuthSession(steamID);
} }
@POST @POST
@@ -74,7 +75,7 @@ public class AccountEndpoints {
@Produces("application/json") @Produces("application/json")
public AuthResult gamecodeLogin(final AuthBNETGamecodeRequest request) { public AuthResult gamecodeLogin(final AuthBNETGamecodeRequest request) {
logger.info("GamecodeLogin called : " + request); logger.info("GamecodeLogin called : " + request);
return null; return new AuthResult(null, 1, "GamecodeLogin not implemented", List.of());
} }
@POST @POST
@@ -83,7 +84,7 @@ public class AccountEndpoints {
@Produces("application/json") @Produces("application/json")
public CheckUsernameResponse checkUsername(final CheckUsernameRequest request) { public CheckUsernameResponse checkUsername(final CheckUsernameRequest request) {
logger.info("CheckUsername called : " + request); logger.info("CheckUsername called : " + request);
if (accountService.exists(request.username())) { if (accountService().exists(request.username())) {
return new CheckUsernameResponse(new CheckUsernameResponseBody(true, true, 0)); return new CheckUsernameResponse(new CheckUsernameResponseBody(true, true, 0));
} else { } else {
return new CheckUsernameResponse(new CheckUsernameResponseBody(false, false, 1)); return new CheckUsernameResponse(new CheckUsernameResponseBody(false, false, 1));
@@ -96,7 +97,7 @@ public class AccountEndpoints {
@Produces("application/json") @Produces("application/json")
public CheckEmailResponse checkEmail(final CheckEmailRequest request) { public CheckEmailResponse checkEmail(final CheckEmailRequest request) {
logger.info("CheckEmail called : " + request); logger.info("CheckEmail called : " + request);
if (accountService.exists(request.email())) { if (accountService().exists(request.email())) {
return new CheckEmailResponse(new CheckEmailResponseBody(true, 0)); return new CheckEmailResponse(new CheckEmailResponseBody(true, 0));
} else { } else {
return new CheckEmailResponse(new CheckEmailResponseBody(false, 1)); return new CheckEmailResponse(new CheckEmailResponseBody(false, 1));
@@ -107,10 +108,13 @@ public class AccountEndpoints {
@Path("bnetRefreshSession") @Path("bnetRefreshSession")
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public RefreshSessionResponse refreshSession(final RefreshSessionRequest request) { public RefreshSessionResponse refreshSession(@HeaderParam("Authorization") final String authentication,
final RefreshSessionRequest request) {
logger.info("RefreshSession called : " + request); logger.info("RefreshSession called : " + request);
final var token = accountService.refresh(request.bnetKeyPlatform()); final var steamID = authenticateOrThrow(authentication);
final var timeToRefresh = Duration.between(java.time.Instant.now(), token.expirationTimestamp()).getSeconds(); final var token = accountService().refreshToken(steamID);
final var timeToRefresh = Duration.between(java.time.Instant.now(), token.expirationTimestamp())
.minus(Duration.ofMinutes(5)).getSeconds();
return new RefreshSessionResponse((int) timeToRefresh, token.token()); return new RefreshSessionResponse((int) timeToRefresh, token.token());
} }
@@ -121,7 +125,8 @@ public class AccountEndpoints {
public LegalDocumentsResponse getLegalDocumentsForUser(@HeaderParam("Authorization") final String authentication, public LegalDocumentsResponse getLegalDocumentsForUser(@HeaderParam("Authorization") final String authentication,
final GetLegalDocumentsForUserRequest request) { final GetLegalDocumentsForUserRequest request) {
logger.info("GetLegalDocumentsForUser called : " + request); logger.info("GetLegalDocumentsForUser called : " + request);
return null; final var steamID = authenticateOrThrow(authentication);
return new LegalDocumentsResponse(List.of());
} }
@POST @POST
@@ -130,6 +135,7 @@ public class AccountEndpoints {
public void acceptLegalDocument(@HeaderParam("Authorization") final String authentication, public void acceptLegalDocument(@HeaderParam("Authorization") final String authentication,
final AcceptLegalDocumentRequest request) { final AcceptLegalDocumentRequest request) {
logger.info("acceptLegalDocument called : " + request); logger.info("acceptLegalDocument called : " + request);
authenticateOrThrow(authentication);
} }
@POST @POST
@@ -138,6 +144,6 @@ public class AccountEndpoints {
@Produces("application/json") @Produces("application/json")
public LegalDocumentsResponse getAllLegalDocuments(final GetAllLegalDocumentsRequest request) { public LegalDocumentsResponse getAllLegalDocuments(final GetAllLegalDocumentsRequest request) {
logger.info("GetAllLegalDocuments called : " + request); logger.info("GetAllLegalDocuments called : " + request);
return null; return new LegalDocumentsResponse(List.of());
} }
} }

View File

@@ -1,5 +1,6 @@
package ch.gtache.elderscrollslegends.service.account; package ch.gtache.elderscrollslegends.service.account;
import ch.gtache.elderscrollslegends.service.BaseService;
import ch.gtache.elderscrollslegends.service.SteamService; import ch.gtache.elderscrollslegends.service.SteamService;
import ch.gtache.elderscrollslegends.service.Token; import ch.gtache.elderscrollslegends.service.Token;
import ch.gtache.elderscrollslegends.service.account.auth.AuthData; import ch.gtache.elderscrollslegends.service.account.auth.AuthData;
@@ -15,24 +16,25 @@ import java.util.List;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;
@ApplicationScoped @ApplicationScoped
public class AccountService { public class AccountService extends BaseService {
private static final Logger logger = Logger.getLogger(AccountService.class); private static final Logger logger = Logger.getLogger(AccountService.class);
private final JWTService jwtService;
private final SteamService steamService; private final SteamService steamService;
private final DataSource dataSource;
@Inject @Inject
AccountService(final SteamService steamService, final DataSource dataSource) { AccountService(final DataSource dataSource, final JWTService jwtService, final SteamService steamService) {
super(dataSource);
this.jwtService = requireNonNull(jwtService);
this.steamService = requireNonNull(steamService); this.steamService = requireNonNull(steamService);
this.dataSource = requireNonNull(dataSource);
} }
AuthData authenticate(final String steamID) {
public AuthData authenticate(final String steamID) {
if (!exists(steamID)) { if (!exists(steamID)) {
final var longId = Long.parseLong(steamID); final var longId = Long.parseLong(steamID);
final var name = steamService.getName(steamID); final var name = steamService.getName(steamID);
try (final var connection = dataSource.getConnection(); try (final var connection = dataSource().getConnection();
final var statement = connection.prepareStatement("INSERT INTO player (steam_id, name) VALUES (?, ?)")) { final var statement = connection.prepareStatement("INSERT INTO player (steam_id, name) VALUES (?, ?)")) {
statement.setLong(1, longId); statement.setLong(1, longId);
statement.setString(2, name); statement.setString(2, name);
@@ -43,14 +45,14 @@ public class AccountService {
} }
} }
updateNameIfNeeded(steamID); updateNameIfNeeded(steamID);
final var token = getOrCreateToken(steamID); final var token = jwtService.createToken(steamID);
return getAuthData(steamID, token); return getAuthData(steamID, token);
} }
private void updateNameIfNeeded(final String steamID) { private void updateNameIfNeeded(final String steamID) {
final var longId = Long.parseLong(steamID); final var longId = Long.parseLong(steamID);
final var name = steamService.getName(steamID); final var name = steamService.getName(steamID);
try (final var connection = dataSource.getConnection(); try (final var connection = dataSource().getConnection();
final var statement = connection.prepareStatement("UPDATE player SET name=? WHERE steam_id=?")) { final var statement = connection.prepareStatement("UPDATE player SET name=? WHERE steam_id=?")) {
statement.setString(1, name); statement.setString(1, name);
statement.setLong(2, longId); statement.setLong(2, longId);
@@ -60,47 +62,19 @@ public class AccountService {
} }
} }
private Token getOrCreateToken(final String steamID) {
final var longId = Long.parseLong(steamID);
try (final var connection = dataSource.getConnection();
final var statement = connection.prepareStatement("SELECT token, expiration FROM token WHERE player_id=(SELECT id FROM player WHERE steam_id=?)")) {
statement.setLong(1, longId);
try (final var rs = statement.executeQuery()) {
if (rs.next()) {
final var token = rs.getString(1);
final var expiration = rs.getTimestamp(2).toInstant();
if (expiration.isAfter(java.time.Instant.now())) {
return new Token(token, expiration);
}
}
}
} catch (final SQLException e) {
logger.error("Error checking for player " + steamID, e);
}
try (final var connection = dataSource.getConnection();
final var statement = connection.prepareStatement("INSERT INTO token (player_id) VALUES ((SELECT id FROM player WHERE steam_id=?)) RETURNING token, expiration")) {
statement.setLong(1, longId);
try (final var rs = statement.executeQuery()) {
return rs.next() ? new Token(rs.getString(1), rs.getTimestamp(2).toInstant()) : null;
}
} catch (final SQLException e) {
logger.error("Error inserting player " + steamID, e);
}
return null;
}
private AuthData getAuthData(final String steamID, final Token token) { private AuthData getAuthData(final String steamID, final Token token) {
if (token != null) { if (token != null) {
final var longId = Long.parseLong(steamID); final var longId = Long.parseLong(steamID);
try (final var connection = dataSource.getConnection(); try (final var connection = dataSource().getConnection();
final var statement = connection.prepareStatement("SELECT 1 FROM player WHERE steam_id=?")) { final var statement = connection.prepareStatement("SELECT name FROM player WHERE steam_id=?")) {
statement.setLong(1, longId); statement.setLong(1, longId);
try (final var rs = statement.executeQuery()) { try (final var rs = statement.executeQuery()) {
if (rs.next()) { if (rs.next()) {
final var uuid = token.token(); final var uuid = token.token();
final var name = rs.getString(1);
final var timeToRefresh = Duration.between(java.time.Instant.now(), token.expirationTimestamp()).getSeconds(); final var timeToRefresh = Duration.between(java.time.Instant.now(), token.expirationTimestamp()).getSeconds();
return new AuthData(uuid, "", "", "", "", steamID, steamID, steamID, return new AuthData(uuid, "", "steam", "", uuid, steamID, steamID, steamID,
"", steamID, "CH", false, false, (int) timeToRefresh, "", name, "US", false, false, (int) timeToRefresh,
5, 5, false, "", "", 5, 5, false, "", "",
0, List.of(), false); 0, List.of(), false);
} }
@@ -112,9 +86,9 @@ public class AccountService {
return null; return null;
} }
public boolean exists(final String steamID) { boolean exists(final String steamID) {
final var longId = Long.parseLong(steamID); final var longId = Long.parseLong(steamID);
try (final var connection = dataSource.getConnection(); try (final var connection = dataSource().getConnection();
final var statement = connection.prepareStatement("SELECT 1 FROM player WHERE steam_id=?")) { final var statement = connection.prepareStatement("SELECT 1 FROM player WHERE steam_id=?")) {
statement.setLong(1, longId); statement.setLong(1, longId);
try (final var rs = statement.executeQuery()) { try (final var rs = statement.executeQuery()) {
@@ -126,19 +100,11 @@ public class AccountService {
return false; return false;
} }
public Token refresh(final String steamID) { Token refreshToken(final String steamID) {
if (exists(steamID)) { return jwtService.createToken(steamID);
final var longId = Long.parseLong(steamID); }
try (final var connection = dataSource.getConnection();
final var statement = connection.prepareStatement("DELETE FROM token WHERE player_id=(SELECT id FROM player WHERE steam_id=?)")) { public String getSteamIDFromToken(final String token) {
statement.setLong(1, longId); return jwtService.getSteamID(token);
statement.executeUpdate();
} catch (final SQLException e) {
logger.error("Error checking for player " + steamID, e);
}
return getOrCreateToken(steamID);
} else {
return null;
}
} }
} }

View File

@@ -0,0 +1,62 @@
package ch.gtache.elderscrollslegends.service.account;
import ch.gtache.elderscrollslegends.service.Token;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTVerificationException;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.jboss.logging.Logger;
import java.time.Duration;
import java.time.Instant;
import java.util.Objects;
@ApplicationScoped
class JWTService {
private static final Logger logger = Logger.getLogger(JWTService.class.getName());
private static final String ISSUER = "TESL";
private final Duration timeToLive;
private final Algorithm algorithm;
private final JWTVerifier verifier;
@Inject
JWTService(@ConfigProperty(name = "jwt.hs256.key.secret") final String key, final Duration timeToLive) {
this.timeToLive = Objects.requireNonNull(timeToLive);
this.algorithm = Algorithm.HMAC256(key);
this.verifier = JWT.require(algorithm).withIssuer(ISSUER).build();
}
public String getSteamID(final String token) {
try {
final var decoded = verifier.verify(token);
return decoded.getSubject();
} catch (final JWTVerificationException e) {
logger.warn("Invalid token " + token, e);
return null;
}
}
public boolean isValid(final String token) {
try {
verifier.verify(token);
return true;
} catch (final JWTVerificationException e) {
return false;
}
}
Token createToken(final String steamID) {
final var expiration = Instant.now().plus(timeToLive);
final var token = JWT.create()
.withSubject(steamID)
.withIssuer(ISSUER)
.withIssuedAt(Instant.now())
.withExpiresAt(expiration).sign(algorithm);
return new Token(token, expiration);
}
}

View File

@@ -1,4 +1,4 @@
package ch.gtache.elderscrollslegends.service.account.auth; package ch.gtache.elderscrollslegends.service.account.auth;
public record LogoutSteamRequest(String steamId) { record ABTestingSet(String setKey, String groupKey) {
} }

View File

@@ -1,7 +1,5 @@
package ch.gtache.elderscrollslegends.service.account.auth; package ch.gtache.elderscrollslegends.service.account.auth;
import ch.gtache.elderscrollslegends.service.account.ABTestingSet;
import java.util.List; import java.util.List;
public record AuthData(String token, public record AuthData(String token,

View File

@@ -1,4 +1,4 @@
package ch.gtache.elderscrollslegends.service.account.transfer; package ch.gtache.elderscrollslegends.service.account.transfer;
public record LegalDocEntry(String doctype, String full_name, int id, String url) { record LegalDocEntry(String doctype, String full_name, int id, String url) {
} }

View File

@@ -1,10 +1,10 @@
package ch.gtache.elderscrollslegends.service.account.transfer; package ch.gtache.elderscrollslegends.service.account.transfer;
import ch.gtache.elderscrollslegends.service.inventory.SelectedItem; import ch.gtache.elderscrollslegends.service.inventory.InventorySelectedItem;
import ch.gtache.elderscrollslegends.service.profile.ProfileStruct; import ch.gtache.elderscrollslegends.service.profile.ProfileStruct;
import java.util.List; import java.util.List;
record TransferResponse_Phase0(List<LegalDocEntry> items, String buid, String sessionToken, boolean hasTeslUserData, record TransferResponse_Phase0(List<LegalDocEntry> items, String buid, String sessionToken, boolean hasTeslUserData,
ProfileStruct profile, List<SelectedItem> categories) { ProfileStruct profile, List<InventorySelectedItem> categories) {
} }

View File

@@ -1,4 +0,0 @@
package ch.gtache.elderscrollslegends.service.analytics;
public record AnalysticsEventPayload(AnalyticsEventType eventType, String data) {
}

View File

@@ -1,5 +1,8 @@
package ch.gtache.elderscrollslegends.service.analytics; package ch.gtache.elderscrollslegends.service.analytics;
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
import ch.gtache.elderscrollslegends.service.account.AccountService;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET; import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam; import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST; import jakarta.ws.rs.POST;
@@ -7,32 +10,42 @@ import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import java.util.Objects;
@Path("/analytics") @Path("/analytics")
public class AnalyticsEndpoints { public class AnalyticsEndpoints extends BaseEndpoints {
private static final Logger logger = Logger.getLogger(AnalyticsEndpoints.class); private static final Logger logger = Logger.getLogger(AnalyticsEndpoints.class);
private final AnalyticsService analyticsService;
@Inject
AnalyticsEndpoints(final AccountService accountService, final AnalyticsService analyticsService) {
super(accountService);
this.analyticsService = Objects.requireNonNull(analyticsService);
}
@POST @POST
@Path("/clientEvent") @Path("/clientEvent")
public void newAnalytics(@HeaderParam("Authorization") final String authentication, public void newAnalytics(@HeaderParam("Authorization") final String authentication,
final AnalyticsEvent analyticsEvent) { final AnalyticsEvent analyticsEvent) {
logger.info("Report analytics called by " + authentication + " : " + analyticsEvent); final var steamID = authenticateOrThrow(authentication);
//Do nothing logger.info("Report analytics called by " + steamID + " : " + analyticsEvent);
analyticsService.newAnalytics(steamID, analyticsEvent);
} }
@POST @POST
@Path("/clientEventPA") @Path("/clientEventPA")
public void newAnalyticsPA(@HeaderParam("Authorization") final String authentication, public void newAnalyticsPA(final AnalyticsEvent analyticsEvent) {
final AnalyticsEvent analyticsEvent) { logger.info("Report analyticsPA called : " + analyticsEvent);
logger.info("Report analyticsPA called by " + authentication + " : " + analyticsEvent); analyticsService.newAnalytics(analyticsEvent);
//Do nothing
} }
@GET @GET
@Path("/reportingConfig") @Path("/reportingConfig")
@Produces("application/json") @Produces("application/json")
public FetchResponse getReportingConfig(@HeaderParam("Authorization") final String authentication) { public AnalyticsFetchResponse getReportingConfig(@HeaderParam("Authorization") final String authentication) {
logger.info("ReportingConfig called by " + authentication); final var steamID = authenticateOrThrow(authentication);
return null; logger.info("ReportingConfig called by " + steamID);
return new AnalyticsFetchResponse(true);
} }
} }

View File

@@ -2,5 +2,5 @@ package ch.gtache.elderscrollslegends.service.analytics;
import java.util.List; import java.util.List;
public record AnalyticsEvent(int platformId, int clientVersion, String eventData, List<AnalysticsEventPayload> events) { public record AnalyticsEvent(int platformId, int clientVersion, String eventData, List<AnalyticsEventPayload> events) {
} }

View File

@@ -0,0 +1,4 @@
package ch.gtache.elderscrollslegends.service.analytics;
public record AnalyticsEventPayload(AnalyticsEventType eventType, String data) {
}

View File

@@ -0,0 +1,4 @@
package ch.gtache.elderscrollslegends.service.analytics;
public record AnalyticsFetchResponse(boolean enableReporting) {
}

View File

@@ -0,0 +1,24 @@
package ch.gtache.elderscrollslegends.service.analytics;
import ch.gtache.elderscrollslegends.service.BaseService;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javax.sql.DataSource;
@ApplicationScoped
class AnalyticsService extends BaseService {
@Inject
AnalyticsService(final DataSource dataSource) {
super(dataSource);
}
void newAnalytics(final AnalyticsEvent analyticsEvent) {
}
void newAnalytics(final String steamID, final AnalyticsEvent analyticsEvent) {
}
}

View File

@@ -1,4 +0,0 @@
package ch.gtache.elderscrollslegends.service.analytics;
public record FetchResponse(boolean enableReporting) {
}

View File

@@ -1,57 +1,95 @@
package ch.gtache.elderscrollslegends.service.arena; package ch.gtache.elderscrollslegends.service.arena;
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
import ch.gtache.elderscrollslegends.service.CardService;
import ch.gtache.elderscrollslegends.service.ClassService;
import ch.gtache.elderscrollslegends.service.account.AccountService;
import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes; import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET; import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam; import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST; import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
import org.jboss.logging.Logger;
import static java.util.Objects.requireNonNull;
@Path("/arena") @Path("/arena")
public class ArenaEndpoints { public class ArenaEndpoints extends BaseEndpoints {
private static final Logger logger = Logger.getLogger(ArenaEndpoints.class);
private final ArenaService arenaService;
private final CardService cardService;
private final ClassService classService;
@Inject
ArenaEndpoints(final AccountService accountService, final ArenaService arenaService,
final CardService cardService, final ClassService classService) {
super(accountService);
this.arenaService = requireNonNull(arenaService);
this.cardService = requireNonNull(cardService);
this.classService = requireNonNull(classService);
}
@Path("purchaseArena")
@POST @POST
@Path("purchaseArena")
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public FetchArenaInstancesResult purchaseArena(@HeaderParam("Authorization") final String authentication, public FetchArenaInstancesResult purchaseArena(@HeaderParam("Authorization") final String authentication,
final PurchaseArenaRequest request) { final PurchaseArenaRequest request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("purchaseArena called by " + steamID + " : " + request);
arenaService.purchaseArena(steamID, request.arenaType(), request.currencyType());
final var data = arenaService.getArenaClientData(steamID);
return new FetchArenaInstancesResult(data);
} }
@Path("resignArena")
@POST @POST
@Path("resignArena")
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public ResignArenaResult resignArena(@HeaderParam("Authorization") final String authentication, public ResignArenaResult resignArena(@HeaderParam("Authorization") final String authentication,
final ResignArenaRequest request) { final ResignArenaRequest request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("resignArena called by " + steamID + " : " + request);
arenaService.resignArena(steamID, request.arenaType());
return new ResignArenaResult();
} }
@Path("selectCard")
@POST @POST
@Path("selectCard")
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public SelectCardResult selectCard(@HeaderParam("Authorization") final String authentication, public SelectCardResult selectCard(@HeaderParam("Authorization") final String authentication,
final SelectCardRequest request) { final SelectCardRequest request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("selectCard called by " + steamID + " : " + request);
final var card = cardService.getCard(request.cardTypeHash());
arenaService.selectCard(steamID, request.arenaType(), card);
return new SelectCardResult(arenaService.getArenaClientData(steamID));
} }
@Path("selectClassType")
@POST @POST
@Path("selectClassType")
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public SelectClassResult selectClassType(@HeaderParam("Authorization") final String authentication, public SelectClassResult selectClassType(@HeaderParam("Authorization") final String authentication,
final SelectClassRequest request) { final SelectClassRequest request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("selectClassType called by " + steamID + " : " + request);
final var clazz = classService.getClass(request.classTypeHash());
arenaService.selectClass(steamID, request.arenaType(), clazz);
return new SelectClassResult(arenaService.getArenaClientData(steamID));
} }
@Path("fetchActiveArenaInstances")
@GET @GET
@Path("fetchActiveArenaInstances")
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public FetchArenaInstancesResult fetchActiveArenaInstances() { public FetchArenaInstancesResult fetchActiveArenaInstances(@HeaderParam("Authorization") final String authentication) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("fetchActiveArenaInstances called by " + steamID);
return new FetchArenaInstancesResult(arenaService.getArenaClientData(steamID));
} }
} }

View File

@@ -0,0 +1,36 @@
package ch.gtache.elderscrollslegends.service.arena;
import ch.gtache.elderscrollslegends.service.BaseService;
import ch.gtache.elderscrollslegends.service.Card;
import ch.gtache.elderscrollslegends.service.Clazz;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javax.sql.DataSource;
import java.util.List;
@ApplicationScoped
class ArenaService extends BaseService {
@Inject
ArenaService(final DataSource dataSource) {
super(dataSource);
}
public void purchaseArena(final String steamID, final ArenaType arenaType,
final ArenaPurchaseCurrencyType currencyType) {
}
public void resignArena(final String steamID, final ArenaType arenaType) {
}
public ArenaClientDataStruct getArenaClientData(final String steamID) {
return new ArenaClientDataStruct(0, 0, List.of());
}
void selectCard(final String steamID, final ArenaType arenaType, final Card card) {
}
void selectClass(final String steamID, final ArenaType arenaType, final Clazz clazz) {
}
}

View File

@@ -1,4 +0,0 @@
package ch.gtache.elderscrollslegends.service.arena;
public record PurchaseArenaResult(ArenaClientDataStruct clientData) {
}

View File

@@ -1,5 +1,8 @@
package ch.gtache.elderscrollslegends.service.campaign; package ch.gtache.elderscrollslegends.service.campaign;
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
import ch.gtache.elderscrollslegends.service.account.AccountService;
import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes; import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET; import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam; import jakarta.ws.rs.HeaderParam;
@@ -8,18 +11,28 @@ import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import java.util.Objects;
@Path("/campaign") @Path("/campaign")
public class CampaignEndpoints { public class CampaignEndpoints extends BaseEndpoints {
private static final Logger logger = Logger.getLogger(CampaignEndpoints.class); private static final Logger logger = Logger.getLogger(CampaignEndpoints.class);
private final CampaignService campaignService;
@Inject
CampaignEndpoints(final AccountService accountService, final CampaignService campaignService) {
super(accountService);
this.campaignService = Objects.requireNonNull(campaignService);
}
@POST @POST
@Path("checkCampaignProgress") @Path("checkCampaignProgress")
@Consumes("application/json") @Consumes("application/json")
public void checkCampaignProgress(@HeaderParam("Authorization") final String authentication, public void checkCampaignProgress(@HeaderParam("Authorization") final String authentication,
final CheckCampaignRequest request) { final CheckCampaignRequest request) {
logger.info("CheckCampaignProgress called by " + authentication + " : " + request); final var steamID = authenticateOrThrow(authentication);
//TODO logger.info("CheckCampaignProgress called by " + steamID + " : " + request);
campaignService.getCampaign(steamID, request.campaignId(), request.isMastery());
} }
@POST @POST
@@ -28,8 +41,8 @@ public class CampaignEndpoints {
@Produces("application/json") @Produces("application/json")
public void debugAddNextChapter(@HeaderParam("Authorization") final String authentication, public void debugAddNextChapter(@HeaderParam("Authorization") final String authentication,
final DebugAddNextChapterRequest request) { final DebugAddNextChapterRequest request) {
logger.info("DebugAddNextChapter called by " + authentication + " : " + request); final var steamID = authenticateOrThrow(authentication);
//Do nothing logger.info("DebugAddNextChapter called by " + steamID + " : " + request);
} }
@POST @POST
@@ -38,9 +51,8 @@ public class CampaignEndpoints {
@Produces("application/json") @Produces("application/json")
public void debugAddNextEvent(@HeaderParam("Authorization") final String authentication, public void debugAddNextEvent(@HeaderParam("Authorization") final String authentication,
final DebugAddNextEventRequest request) { final DebugAddNextEventRequest request) {
final var steamID = authenticateOrThrow(authentication);
logger.info("DebugAddNextEvent called by " + authentication + " : " + request); logger.info("DebugAddNextEvent called by " + steamID + " : " + request);
//Do nothing
} }
@POST @POST
@@ -49,9 +61,9 @@ public class CampaignEndpoints {
@Produces("application/json") @Produces("application/json")
public SetChapterDialogResult setChapterDialogStatus(@HeaderParam("Authorization") final String authentication, public SetChapterDialogResult setChapterDialogStatus(@HeaderParam("Authorization") final String authentication,
final SetChapterDialogStatusRequest request) { final SetChapterDialogStatusRequest request) {
logger.info("SetChapterDialogStatus called by " + authentication + " : " + request); final var steamID = authenticateOrThrow(authentication);
//TODO logger.info("SetChapterDialogStatus called by " + steamID + " : " + request);
return null; return new SetChapterDialogResult(campaignService.getRewards(steamID, request));
} }
@POST @POST
@@ -60,17 +72,17 @@ public class CampaignEndpoints {
@Produces("application/json") @Produces("application/json")
public SetChapterEventResult setChapterEventChoice(@HeaderParam("Authorization") final String authentication, public SetChapterEventResult setChapterEventChoice(@HeaderParam("Authorization") final String authentication,
final SetChapterEventChoiceRequest request) { final SetChapterEventChoiceRequest request) {
logger.info("SetChapterEventChoice called by " + authentication + " : " + request); final var steamID = authenticateOrThrow(authentication);
//TODO logger.info("SetChapterEventChoice called by " + steamID + " : " + request);
return null; return new SetChapterEventResult(campaignService.getRewards(steamID, request));
} }
@GET @GET
@Path("list") @Path("list")
@Produces("application/json") @Produces("application/json")
public ListCampaignsResponse getList(@HeaderParam("Authorization") final String authentication) { public ListCampaignsResponse getList(@HeaderParam("Authorization") final String authentication) {
logger.info("List called by " + authentication); final var steamID = authenticateOrThrow(authentication);
//TODO logger.info("List called by " + steamID);
return null; return new ListCampaignsResponse(campaignService.getCampaigns(steamID));
} }
} }

View File

@@ -0,0 +1,34 @@
package ch.gtache.elderscrollslegends.service.campaign;
import ch.gtache.elderscrollslegends.service.BaseService;
import ch.gtache.elderscrollslegends.service.reward.RewardDescription;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javax.sql.DataSource;
import java.util.List;
@ApplicationScoped
class CampaignService extends BaseService {
@Inject
CampaignService(final DataSource dataSource) {
super(dataSource);
}
UserCampaignData getCampaign(final String steamID, final int id, final boolean mastery) {
return null;
}
List<UserCampaignData> getCampaigns(final String steamID) {
return List.of();
}
List<RewardDescription> getRewards(final String steamID, final SetChapterEventChoiceRequest request) {
return List.of();
}
List<RewardDescription> getRewards(final String steamID, final SetChapterDialogStatusRequest request) {
return List.of();
}
}

View File

@@ -1,4 +1,6 @@
package ch.gtache.elderscrollslegends.service.campaign; package ch.gtache.elderscrollslegends.service.campaign;
public record ListCampaignsResponse(UserCampaignData campaignDatas) { import java.util.List;
public record ListCampaignsResponse(List<UserCampaignData> campaignDatas) {
} }

View File

@@ -1,5 +1,6 @@
package ch.gtache.elderscrollslegends.service.campaign; package ch.gtache.elderscrollslegends.service.campaign;
public record SetChapterEventChoiceRequest(int campaignId, int actId, int chapterId, int cinematicId, public record SetChapterEventChoiceRequest(int campaignId, int actId, int chapterId, int cinematicId,
boolean isMastery, DialogModalType modalType, UserCampaignChoice choiceType) { boolean isMastery, DialogModalType modalType,
UserCampaignChoice choiceType) {
} }

View File

@@ -3,5 +3,5 @@ package ch.gtache.elderscrollslegends.service.campaign;
import java.util.List; import java.util.List;
public record UserCampaignData(int campaignId, boolean isActive, int lastPlayedActIndex, int lastPlayedChapterIndex, public record UserCampaignData(int campaignId, boolean isActive, int lastPlayedActIndex, int lastPlayedChapterIndex,
int lastPlayedChapterEventINdex, List<UserActData> actData, List<Integer> ownedActs) { int lastPlayedChapterEventIndex, List<UserActData> actData, List<Integer> ownedActs) {
} }

View File

@@ -1,18 +1,35 @@
package ch.gtache.elderscrollslegends.service.chat; package ch.gtache.elderscrollslegends.service.chat;
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
import ch.gtache.elderscrollslegends.service.account.AccountService;
import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes; import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.HeaderParam; import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST; import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import org.jboss.logging.Logger;
import java.util.Objects;
@Path("/chat") @Path("/chat")
public class ChatEndpoints { public class ChatEndpoints extends BaseEndpoints {
private static final Logger logger = Logger.getLogger(ChatEndpoints.class);
private final ChatService chatService;
@Inject
ChatEndpoints(final AccountService accountService, final ChatService chatService) {
super(accountService);
this.chatService = Objects.requireNonNull(chatService);
}
@Path("sendChatMessage")
@POST @POST
@Path("sendChatMessage")
@Consumes("application/json") @Consumes("application/json")
public void sendChatMessage(@HeaderParam("Authorization") final String authentication, public void sendChatMessage(@HeaderParam("Authorization") final String authentication,
final OutgoingMessage message) { final OutgoingMessage message) {
//Do nothing final var steamID = authenticateOrThrow(authentication);
logger.info("SendChatMessage called by " + steamID + " : " + message);
chatService.sendMessage(steamID, message.toBuid(), message.message());
} }
} }

View File

@@ -0,0 +1,20 @@
package ch.gtache.elderscrollslegends.service.chat;
import ch.gtache.elderscrollslegends.service.BaseService;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javax.sql.DataSource;
@ApplicationScoped
class ChatService extends BaseService {
@Inject
ChatService(final DataSource dataSource) {
super(dataSource);
}
void sendMessage(final String senderID, final String receiverID, final String message) {
}
}

View File

@@ -0,0 +1,7 @@
package ch.gtache.elderscrollslegends.service.crafting;
import ch.gtache.elderscrollslegends.service.Card;
record CraftResult(Card card, int totalGems, int regularRemaining, int premiumRemaining) {
}

View File

@@ -1,38 +1,71 @@
package ch.gtache.elderscrollslegends.service.crafting; package ch.gtache.elderscrollslegends.service.crafting;
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
import ch.gtache.elderscrollslegends.service.CardService;
import ch.gtache.elderscrollslegends.service.account.AccountService;
import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes; import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.HeaderParam; import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST; import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
import org.jboss.logging.Logger;
import java.util.Objects;
@Path("/crafting") @Path("/crafting")
public class CraftingEndpoints { public class CraftingEndpoints extends BaseEndpoints {
private static final Logger logger = Logger.getLogger(CraftingEndpoints.class);
private final CraftingService craftingService;
private final CardService cardService;
@Inject
CraftingEndpoints(final AccountService accountService, final CraftingService craftingService,
final CardService cardService) {
super(accountService);
this.craftingService = Objects.requireNonNull(craftingService);
this.cardService = Objects.requireNonNull(cardService);
}
@Path("soulTrapExtras")
@POST @POST
@Path("soulTrapExtras")
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public SoulTrapExtrasResponse soulTrapExtras(@HeaderParam("Authorization") final String authentication, public SoulTrapExtrasResponse soulTrapExtras(@HeaderParam("Authorization") final String authentication,
final SoulTrapExtrasRequest request) { final SoulTrapExtrasRequest request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("SoulTrapExtras called by " + steamID + " : " + request);
final var soulTrapped = craftingService.soulTrap(steamID, request.priority());
return new SoulTrapExtrasResponse(soulTrapped);
} }
@Path("sell")
@POST @POST
@Path("sell")
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public CraftingResponse sell(@HeaderParam("Authorization") final String authentication, public CraftingResponse sell(@HeaderParam("Authorization") final String authentication,
final CraftingRequest request) { final CraftingRequest request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("Sell called by " + steamID + " : " + request);
final var card = cardService.getCard(request.typeHash());
final var result = craftingService.sell(steamID, card, request.amount(), request.isPremium());
return new CraftingResponse(card.hash(), result.totalGems(), result.regularRemaining(),
result.premiumRemaining(), false);
} }
@Path("purchase")
@POST @POST
@Path("purchase")
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public CraftingResponse purchase(@HeaderParam("Authorization") final String authentication, public CraftingResponse purchase(@HeaderParam("Authorization") final String authentication,
final CraftingRequest request) { final CraftingRequest request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("Purchase called by " + steamID + " : " + request);
final var card = cardService.getCard(request.typeHash());
final var result = craftingService.purchase(steamID, card, request.amount(), request.isPremium());
return new CraftingResponse(card.hash(), result.totalGems(), result.regularRemaining(),
result.premiumRemaining(), false);
} }
} }

View File

@@ -0,0 +1,29 @@
package ch.gtache.elderscrollslegends.service.crafting;
import ch.gtache.elderscrollslegends.service.BaseService;
import ch.gtache.elderscrollslegends.service.Card;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javax.sql.DataSource;
@ApplicationScoped
class CraftingService extends BaseService {
@Inject
CraftingService(final DataSource dataSource) {
super(dataSource);
}
int soulTrap(final String steamID, final String priority) {
return 0;
}
CraftResult sell(final String steamID, final Card card, final int amount, final boolean premium) {
return new CraftResult(card, 0, 0, 0);
}
CraftResult purchase(final String steamID, final Card card, final int amount, final boolean premium) {
return new CraftResult(card, 0, 0, 0);
}
}

View File

@@ -0,0 +1,4 @@
package ch.gtache.elderscrollslegends.service.dailyreward;
public record AcceptDailyRewardResponse(AcceptDailyRewardResult result) {
}

View File

@@ -0,0 +1,6 @@
package ch.gtache.elderscrollslegends.service.dailyreward;
import java.util.List;
public record AcceptDailyRewardResult(int xp, int gold, int gems, List<DailyItemType> items) {
}

View File

@@ -0,0 +1,4 @@
package ch.gtache.elderscrollslegends.service.dailyreward;
public record DailyItemType(String type, int typeId, int count, boolean isPremium) {
}

View File

@@ -0,0 +1,5 @@
package ch.gtache.elderscrollslegends.service.dailyreward;
public record DailyRewardDescription(String scheduleKey, PreRewardedVisibilityType preRewardedVisibility,
String displayKey, int amount, boolean delivered, boolean deliveredToday) {
}

View File

@@ -0,0 +1,47 @@
package ch.gtache.elderscrollslegends.service.dailyreward;
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
import ch.gtache.elderscrollslegends.service.account.AccountService;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import org.jboss.logging.Logger;
import java.util.Objects;
@Path("/dailyrewards")
public class DailyRewardsEndpoints extends BaseEndpoints {
private static final Logger logger = Logger.getLogger(DailyRewardsEndpoints.class);
private final DailyRewardsService dailyRewardsService;
@Inject
DailyRewardsEndpoints(final AccountService accountService, final DailyRewardsService dailyRewardsService) {
super(accountService);
this.dailyRewardsService = Objects.requireNonNull(dailyRewardsService);
}
@GET
@Path("list")
@Produces("application/json")
public ListDailyRewardsResponse list(@HeaderParam("Authorization") final String authentication) {
final var steamID = authenticateOrThrow(authentication);
logger.info("List called by " + steamID);
final var rewards = dailyRewardsService.listRewards(steamID);
return new ListDailyRewardsResponse(rewards);
}
@POST
@Path("acceptReward")
@Produces("application/json")
public AcceptDailyRewardResponse acceptReward(@HeaderParam("Authorization") final String authentication) {
final var steamID = authenticateOrThrow(authentication);
logger.info("AcceptReward called by " + steamID);
final var result = dailyRewardsService.acceptReward(steamID);
return new AcceptDailyRewardResponse(result);
}
}

View File

@@ -0,0 +1,25 @@
package ch.gtache.elderscrollslegends.service.dailyreward;
import ch.gtache.elderscrollslegends.service.BaseService;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javax.sql.DataSource;
import java.util.List;
@ApplicationScoped
class DailyRewardsService extends BaseService {
@Inject
DailyRewardsService(final DataSource dataSource) {
super(dataSource);
}
List<DailyRewardDescription> listRewards(final String steamID) {
return List.of();
}
AcceptDailyRewardResult acceptReward(final String steamID) {
return new AcceptDailyRewardResult(0, 0, 0, List.of());
}
}

View File

@@ -0,0 +1,6 @@
package ch.gtache.elderscrollslegends.service.dailyreward;
import java.util.List;
public record ListDailyRewardsResponse(List<DailyRewardDescription> rewards) {
}

View File

@@ -1,4 +1,4 @@
package ch.gtache.elderscrollslegends.service.dailyrewards; package ch.gtache.elderscrollslegends.service.dailyreward;
public enum PreRewardedVisibilityType { public enum PreRewardedVisibilityType {
Unknown, Unknown,

View File

@@ -1,4 +0,0 @@
package ch.gtache.elderscrollslegends.service.dailyrewards;
public record AcceptRewardResponse(AcceptRewardResult result) {
}

View File

@@ -1,6 +0,0 @@
package ch.gtache.elderscrollslegends.service.dailyrewards;
import java.util.List;
public record AcceptRewardResult(int xp, int gold, int gems, List<ItemType> items) {
}

View File

@@ -1,25 +0,0 @@
package ch.gtache.elderscrollslegends.service.dailyrewards;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
@Path("/dailyrewards")
public class DailyRewardsEndpoints {
@Path("list")
@GET
@Produces("application/json")
public ListRewardsResponse list(@HeaderParam("Authorization") final String authentication) {
return null;
}
@Path("acceptReward")
@POST
@Produces("application/json")
public AcceptRewardResponse acceptReward(@HeaderParam("Authorization") final String authentication) {
return null;
}
}

View File

@@ -1,4 +0,0 @@
package ch.gtache.elderscrollslegends.service.dailyrewards;
public record ItemType(String type, int typeId, int count, boolean isPremium) {
}

View File

@@ -1,6 +0,0 @@
package ch.gtache.elderscrollslegends.service.dailyrewards;
import java.util.List;
public record ListRewardsResponse(List<RewardDescription> rewards) {
}

View File

@@ -1,5 +0,0 @@
package ch.gtache.elderscrollslegends.service.dailyrewards;
public record RewardDescription(String scheduleKey, PreRewardedVisibilityType preRewardedVisibility,
String displayKey, int amount, boolean delivered, boolean deliveredToday) {
}

View File

@@ -1,5 +1,8 @@
package ch.gtache.elderscrollslegends.service.error; package ch.gtache.elderscrollslegends.service.error;
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
import ch.gtache.elderscrollslegends.service.account.AccountService;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET; import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam; import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST; import jakarta.ws.rs.POST;
@@ -8,21 +11,29 @@ import org.jboss.logging.Logger;
@Path("/errorreporting") @Path("/errorreporting")
public class ErrorEndpoints { public class ErrorEndpoints extends BaseEndpoints {
private static final Logger logger = Logger.getLogger(ErrorEndpoints.class); private static final Logger logger = Logger.getLogger(ErrorEndpoints.class);
private final ErrorService errorService;
@Inject
ErrorEndpoints(final AccountService accountService, final ErrorService errorService) {
super(accountService);
this.errorService = errorService;
}
@POST @POST
@Path("reportError") @Path("reportError")
public void reportError(@HeaderParam("Authorization") final String authentication, public void reportError(@HeaderParam("Authorization") final String authentication,
final ErrorReport errorReport) { final ErrorReport errorReport) {
logger.info("Report error called by " + authentication + " : " + errorReport); logger.info("Report error called by " + authentication + " : " + errorReport);
//Do nothing errorService.reportError(errorReport.report());
} }
@GET @GET
@Path("reportingConfig") @Path("reportingConfig")
public FetchResponse getReportingConfig(@HeaderParam("Authorization") final String authentication) { public FetchResponse getReportingConfig(@HeaderParam("Authorization") final String authentication) {
logger.info("ReportingConfig called by " + authentication); logger.info("ReportingConfig called by " + authentication);
return null; return new FetchResponse(true);
} }
} }

View File

@@ -0,0 +1,20 @@
package ch.gtache.elderscrollslegends.service.error;
import ch.gtache.elderscrollslegends.service.BaseService;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javax.sql.DataSource;
@ApplicationScoped
class ErrorService extends BaseService {
@Inject
ErrorService(final DataSource dataSource) {
super(dataSource);
}
void reportError(final String report) {
}
}

View File

@@ -0,0 +1,4 @@
package ch.gtache.elderscrollslegends.service.events;
public record Event(long id) {
}

View File

@@ -0,0 +1,6 @@
package ch.gtache.elderscrollslegends.service.events;
import java.util.List;
public record EventLeaderboard(Event event, long totalPages, long userPage, List<LeaderboardEntry> entries) {
}

View File

@@ -1,20 +1,44 @@
package ch.gtache.elderscrollslegends.service.events; package ch.gtache.elderscrollslegends.service.events;
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
import ch.gtache.elderscrollslegends.service.DeckService;
import ch.gtache.elderscrollslegends.service.account.AccountService;
import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes; import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET; import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam; import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST; import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
import org.jboss.logging.Logger;
import static java.util.Objects.requireNonNull;
@Path("events") @Path("events")
public class EventsEndpoints { public class EventsEndpoints extends BaseEndpoints {
private static final Logger logger = Logger.getLogger(EventsEndpoints.class);
private final EventsService eventsService;
private final DeckService deckService;
@Inject
EventsEndpoints(final AccountService accountService, final EventsService eventsService,
final DeckService deckService) {
super(accountService);
this.eventsService = requireNonNull(eventsService);
this.deckService = requireNonNull(deckService);
}
@POST @POST
@Path("finalizeEvent") @Path("finalizeEvent")
@Consumes("application/json") @Consumes("application/json")
public void finalizeEvent(@HeaderParam("Authorization") final String authentication, public void finalizeEvent(@HeaderParam("Authorization") final String authentication,
final FinalizeEventRequest request) { final FinalizeEventRequest request) {
final var steamID = authenticateOrThrow(authentication);
logger.info("finalizeEvent called by " + steamID + " : " + request);
final var event = eventsService.getEvent(request.eventId());
eventsService.finalizeEvent(steamID, event);
} }
@POST @POST
@@ -22,6 +46,10 @@ public class EventsEndpoints {
@Consumes("application/json") @Consumes("application/json")
public void finalizeEventRun(@HeaderParam("Authorization") final String authentication, public void finalizeEventRun(@HeaderParam("Authorization") final String authentication,
final FinalizeEventRunRequest request) { final FinalizeEventRunRequest request) {
final var steamID = authenticateOrThrow(authentication);
logger.info("finalizeEventRun called by " + steamID + " : " + request);
final var event = eventsService.getEvent(request.eventId());
eventsService.finalizeEventRun(steamID, event);
} }
@POST @POST
@@ -30,7 +58,12 @@ public class EventsEndpoints {
@Produces("application/json") @Produces("application/json")
public GetEventLeaderboardResponse getEventLeaderboard(@HeaderParam("Authorization") final String authentication, public GetEventLeaderboardResponse getEventLeaderboard(@HeaderParam("Authorization") final String authentication,
final GetEventLeaderboardRequest request) { final GetEventLeaderboardRequest request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("getEventLeaderboard called by " + steamID + " : " + request);
final var event = eventsService.getEvent(request.eventId());
final var leaderboard = eventsService.getEventLeaderboard(steamID, event);
return new GetEventLeaderboardResponse(event.id(), leaderboard.totalPages(),
leaderboard.userPage(), leaderboard.entries());
} }
@POST @POST
@@ -39,7 +72,11 @@ public class EventsEndpoints {
@Produces("application/json") @Produces("application/json")
public PurchaseEventResult purchaseEvent(@HeaderParam("Authorization") final String authentication, public PurchaseEventResult purchaseEvent(@HeaderParam("Authorization") final String authentication,
final PurchaseEventRequest request) { final PurchaseEventRequest request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("purchaseEvent called by " + steamID + " : " + request);
final var event = eventsService.getEvent(request.eventId());
eventsService.purchaseEvent(steamID, event, request.purchaseType());
return new PurchaseEventResult();
} }
@POST @POST
@@ -48,7 +85,11 @@ public class EventsEndpoints {
@Produces("application/json") @Produces("application/json")
public PurchaseEventRunResult purchaseEventRun(@HeaderParam("Authorization") final String authentication, public PurchaseEventRunResult purchaseEventRun(@HeaderParam("Authorization") final String authentication,
final PurchaseEventRunRequest request) { final PurchaseEventRunRequest request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("purchaseEvent called by " + steamID + " : " + request);
final var event = eventsService.getEvent(request.eventId());
eventsService.purchaseEventRun(steamID, event, request.purchaseType());
return new PurchaseEventRunResult();
} }
@POST @POST
@@ -56,6 +97,11 @@ public class EventsEndpoints {
@Consumes("application/json") @Consumes("application/json")
public void selectExplicitDeck(@HeaderParam("Authorization") final String authentication, public void selectExplicitDeck(@HeaderParam("Authorization") final String authentication,
final SelectExplicitDeckRequest request) { final SelectExplicitDeckRequest request) {
final var steamID = authenticateOrThrow(authentication);
logger.info("selectExplicitDeck called by " + steamID + " : " + request);
final var event = eventsService.getEvent(request.eventId());
final var deck = deckService.getDeck(steamID, request.deckTypeHash());
eventsService.selectExplicitDeck(steamID, event, deck);
} }
@POST @POST
@@ -64,13 +110,20 @@ public class EventsEndpoints {
@Produces("application/json") @Produces("application/json")
public UpdateEventLeaderboardRankResponse getEventLeaderboardRank(@HeaderParam("Authorization") final String authentication, public UpdateEventLeaderboardRankResponse getEventLeaderboardRank(@HeaderParam("Authorization") final String authentication,
final UpdateEventLeaderboardRankRequest request) { final UpdateEventLeaderboardRankRequest request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("getEventLeaderboardRank called by " + steamID + " : " + request);
final var event = eventsService.getEvent(request.eventId());
final var ranking = eventsService.updateEventLeaderboardRank(steamID, event);
return new UpdateEventLeaderboardRankResponse(event.id(), ranking);
} }
@GET @GET
@Path("fetch") @Path("fetch")
@Produces("application/json") @Produces("application/json")
public ListEventsResponse fetchEvents(@HeaderParam("Authorization") final String authentication) { public ListEventsResponse fetchEvents(@HeaderParam("Authorization") final String authentication) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("fetchEvents called by " + steamID);
final var events = eventsService.getEvents(steamID);
return new ListEventsResponse(events);
} }
} }

View File

@@ -0,0 +1,54 @@
package ch.gtache.elderscrollslegends.service.events;
import ch.gtache.elderscrollslegends.service.BaseService;
import ch.gtache.elderscrollslegends.service.inventory.Deck;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javax.sql.DataSource;
import java.util.List;
@ApplicationScoped
class EventsService extends BaseService {
@Inject
EventsService(final DataSource dataSource) {
super(dataSource);
}
Event getEvent(final long id) {
return new Event(id);
}
void finalizeEvent(final String steamID, final Event event) {
}
void finalizeEventRun(final String steamID, final Event event) {
}
EventLeaderboard getEventLeaderboard(final String steamID, final Event event) {
return new EventLeaderboard(event, 0, 0, List.of());
}
void purchaseEvent(final String steamID, final Event event, final PurchaseType purchaseType) {
}
void purchaseEventRun(final String steamID, final Event event, final PurchaseType purchaseType) {
}
void selectExplicitDeck(final String steamID, final Event event, final Deck deck) {
}
long updateEventLeaderboardRank(final String steamID, final Event event) {
return 0;
}
EventDescriptionStruct getEvents(final String steamID) {
return null;
}
}

View File

@@ -0,0 +1,4 @@
package ch.gtache.elderscrollslegends.service.friends;
public record BlockedItem(String buid, String username, String service_account_id, String platform) {
}

View File

@@ -0,0 +1,6 @@
package ch.gtache.elderscrollslegends.service.friends;
import java.util.List;
public record BlockedResponse(List<BlockedItem> blocked, int total_count, int start_keys) {
}

View File

@@ -1,14 +1,45 @@
package ch.gtache.elderscrollslegends.service.friends; package ch.gtache.elderscrollslegends.service.friends;
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
import ch.gtache.elderscrollslegends.service.account.AccountService;
import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes; import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam; import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST; import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam; import jakarta.ws.rs.QueryParam;
import org.jboss.logging.Logger;
import java.util.List;
@Path("/beam/social/v3/friends") @Path("/beam/social/v3/friends")
public class FriendsEndpoints { public class FriendsEndpoints extends BaseEndpoints {
private static final Logger logger = Logger.getLogger(FriendsEndpoints.class);
private final FriendsService friendsService;
@Inject
FriendsEndpoints(final AccountService accountService, final FriendsService friendsService) {
super(accountService);
this.friendsService = friendsService;
}
@GET
@Consumes("application/json")
@Produces("application/json")
public FriendsResponse get(@HeaderParam("Authorization") final String authentication,
@QueryParam("product_id") final String productId,
@QueryParam("start_keys") final int startKeys,
@QueryParam("size") final int size,
@QueryParam("language") final String language,
@QueryParam("detail") final String detail) {
final var steamID = authenticateOrThrow(authentication);
logger.info("get called by " + steamID + " : " + productId + " ; " + startKeys + " ; " + size + " ; " + language + " ; " + detail);
return new FriendsResponse(List.of(), 0, 0);
}
@POST @POST
@Path("/unfriend") @Path("/unfriend")
@@ -16,7 +47,27 @@ public class FriendsEndpoints {
@Produces("application/json") @Produces("application/json")
public ActionResponse unfriend(@HeaderParam("Authorization") final String authentication, public ActionResponse unfriend(@HeaderParam("Authorization") final String authentication,
final ActionBody request) { final ActionBody request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("unfriend called by " + steamID + " : " + request);
for (final var buid : request.buids()) {
friendsService.unfriend(steamID, buid);
}
return new ActionResponse(List.of());
}
@GET
@Path("/block")
@Consumes("application/json")
@Produces("application/json")
public BlockedResponse getBlocked(@HeaderParam("Authorization") final String authentication,
@QueryParam("product_id") final String productId,
@QueryParam("start_keys") final int startKeys,
@QueryParam("size") final int size,
@QueryParam("language") final String language,
@QueryParam("detail") final String detail) {
final var steamID = authenticateOrThrow(authentication);
logger.info("getBlocked called by " + steamID + " : " + productId + " ; " + startKeys + " ; " + size + " ; " + language + " ; " + detail);
return new BlockedResponse(List.of(), 0, 0);
} }
@POST @POST
@@ -25,7 +76,12 @@ public class FriendsEndpoints {
@Produces("application/json") @Produces("application/json")
public ActionResponse block(@HeaderParam("Authorization") final String authentication, public ActionResponse block(@HeaderParam("Authorization") final String authentication,
final ActionBody request) { final ActionBody request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("block called by " + steamID + " : " + request);
for (final var buid : request.buids()) {
friendsService.block(steamID, buid);
}
return new ActionResponse(List.of());
} }
@POST @POST
@@ -34,17 +90,46 @@ public class FriendsEndpoints {
@Produces("application/json") @Produces("application/json")
public ActionResponse unblock(@HeaderParam("Authorization") final String authentication, public ActionResponse unblock(@HeaderParam("Authorization") final String authentication,
final ActionBody request) { final ActionBody request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("unblock called by " + steamID + " : " + request);
for (final var buid : request.buids()) {
friendsService.unblock(steamID, buid);
}
return new ActionResponse(List.of());
}
/**
* Sends a friend request
*
* @param authentication
* @param startKeys
* @param size
* @return
*/
@GET
@Path("/requests")
@Consumes("application/json")
@Produces("application/json")
public RequestsResponse getRequests(@HeaderParam("Authorization") final String authentication,
@QueryParam("start_keys") final int startKeys,
@QueryParam("size") final int size) {
final var steamID = authenticateOrThrow(authentication);
logger.info("getRequests called by " + steamID + " : " + startKeys + " ; " + size);
return new RequestsResponse(List.of(), 0);
} }
@POST @POST
@Path("/requests") @Path("/requests")
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public ActionResponse getRequests(@HeaderParam("Authorization") final String authentication, public ActionResponse requests(@HeaderParam("Authorization") final String authentication,
@QueryParam("size") final int size, final ActionBody requests) {
final ActionBody request) { final var steamID = authenticateOrThrow(authentication);
return null; logger.info("requests called by " + steamID);
for (final var buid : requests.buids()) {
friendsService.sendRequest(steamID, buid);
}
return new ActionResponse(List.of());
} }
@POST @POST
@@ -53,7 +138,12 @@ public class FriendsEndpoints {
@Produces("application/json") @Produces("application/json")
public ActionResponse cancelRequest(@HeaderParam("Authorization") final String authentication, public ActionResponse cancelRequest(@HeaderParam("Authorization") final String authentication,
final ActionBody request) { final ActionBody request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("cancelRequest called by " + steamID + " : " + request);
for (final var buid : request.buids()) {
friendsService.cancelRequest(steamID, buid);
}
return new ActionResponse(List.of());
} }
@POST @POST
@@ -62,7 +152,12 @@ public class FriendsEndpoints {
@Produces("application/json") @Produces("application/json")
public ActionResponse acceptRequest(@HeaderParam("Authorization") final String authentication, public ActionResponse acceptRequest(@HeaderParam("Authorization") final String authentication,
final ActionBody request) { final ActionBody request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("acceptRequest called by " + steamID + " : " + request);
for (final var buid : request.buids()) {
friendsService.acceptRequest(steamID, buid);
}
return new ActionResponse(List.of());
} }
@POST @POST
@@ -71,28 +166,39 @@ public class FriendsEndpoints {
@Produces("application/json") @Produces("application/json")
public ActionResponse rejectRequest(@HeaderParam("Authorization") final String authentication, public ActionResponse rejectRequest(@HeaderParam("Authorization") final String authentication,
final ActionBody request) { final ActionBody request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("rejectRequest called by " + steamID + " : " + request);
for (final var buid : request.buids()) {
friendsService.rejectRequest(steamID, buid);
}
return new ActionResponse(List.of());
} }
@POST @GET
@Path("/requests/sent") @Path("/requests/sent")
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public ActionResponse getSentRequests(@HeaderParam("Authorization") final String authentication, public SentRequestsResponse getSentRequests(@HeaderParam("Authorization") final String authentication,
@QueryParam("size") final int size, @QueryParam("start_keys") final int startKeys,
final ActionBody request) { @QueryParam("size") final int size,
return null; final ActionBody request) {
final var steamID = authenticateOrThrow(authentication);
logger.info("getSentRequests called by " + steamID + " : " + startKeys + " ; " + size + " ; " + request);
return new SentRequestsResponse(List.of(), 0);
} }
@POST @POST
@Path("/search") @Path("/search")
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public ActionResponse search(@HeaderParam("Authorization") final String authentication, public SearchResponse search(@HeaderParam("Authorization") final String authentication,
@QueryParam("search_term") final String searchTerm, @QueryParam("search_term") final String searchTerm,
@QueryParam("start_keys") final int startKeys,
@QueryParam("size") final int size, @QueryParam("size") final int size,
final ActionBody request) { final ActionBody request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("search called by " + steamID + " : " + searchTerm + " ; " + startKeys + " ; " + size + " ; " + request);
return new SearchResponse(List.of(), 0);
} }
} }

View File

@@ -0,0 +1,5 @@
package ch.gtache.elderscrollslegends.service.friends;
public record FriendsItem(String buid, String username, boolean blocked, String firends_since,
String service_account_id, String friendship_type, Presence presence) {
}

View File

@@ -0,0 +1,6 @@
package ch.gtache.elderscrollslegends.service.friends;
import java.util.List;
public record FriendsResponse(List<FriendsItem> friend_list, int total_count, int start_keys) {
}

View File

@@ -0,0 +1,52 @@
package ch.gtache.elderscrollslegends.service.friends;
import ch.gtache.elderscrollslegends.service.BaseService;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javax.sql.DataSource;
@ApplicationScoped
class FriendsService extends BaseService {
@Inject
FriendsService(final DataSource dataSource) {
super(dataSource);
}
void unfriend(final String steamID, final String buid) {
}
void block(final String steamID, final String buid) {
}
void unblock(final String steamID, final String buid) {
}
void cancelRequest(final String steamID, final String buid) {
}
void acceptRequest(final String steamID, final String buid) {
}
void rejectRequest(final String steamID, final String buid) {
}
Object getRequests(final String steamID, final int size) {
return null;
}
void sendRequest(final String steamID, final String buid) {
}
Object getSentRequests(final String steamID) {
return null;
}
}

View File

@@ -0,0 +1,6 @@
package ch.gtache.elderscrollslegends.service.friends;
import java.util.List;
public record Presence(String status, String first_party_status, List<PresenceStatusInfo> status_info) {
}

View File

@@ -0,0 +1,6 @@
package ch.gtache.elderscrollslegends.service.friends;
public record PresenceStatusInfo(String last_activity_timestamp, String product_id, String platform,
String main_game_status, String player_status, String custom_data,
Status idle_status, Status offline_status) {
}

View File

@@ -0,0 +1,4 @@
package ch.gtache.elderscrollslegends.service.friends;
public record Requester(String buid, String username, String avatar) {
}

View File

@@ -0,0 +1,4 @@
package ch.gtache.elderscrollslegends.service.friends;
public record RequestsItem(String request_date, Requester requester) {
}

View File

@@ -0,0 +1,6 @@
package ch.gtache.elderscrollslegends.service.friends;
import java.util.List;
public record RequestsResponse(List<RequestsItem> requests_list, int start_keys) {
}

View File

@@ -0,0 +1,6 @@
package ch.gtache.elderscrollslegends.service.friends;
import java.util.List;
public record SearchResponse(List<Requester> result, int start_keys) {
}

View File

@@ -0,0 +1,6 @@
package ch.gtache.elderscrollslegends.service.friends;
import java.util.List;
public record SentRequestsResponse(List<RequestsItem> requests_list, int start_keys) {
}

View File

@@ -0,0 +1,4 @@
package ch.gtache.elderscrollslegends.service.friends;
public record Status(int seconds, String timestamp, String text) {
}

View File

@@ -1,23 +1,42 @@
package ch.gtache.elderscrollslegends.service.inventory; package ch.gtache.elderscrollslegends.service.inventory;
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
import ch.gtache.elderscrollslegends.service.account.AccountService;
import jakarta.ws.rs.GET; import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam; import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST; import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import org.jboss.logging.Logger;
import java.util.Objects;
@Path("/genericinventory") @Path("/genericinventory")
public class GenericInventoryEndpoints { public class GenericInventoryEndpoints extends BaseEndpoints {
private static final Logger logger = Logger.getLogger(GenericInventoryEndpoints.class.getName());
private final GenericsInventoryService genericsInventoryService;
GenericInventoryEndpoints(final AccountService accountService,
final GenericsInventoryService genericsInventoryService) {
super(accountService);
this.genericsInventoryService = Objects.requireNonNull(genericsInventoryService);
}
@GET @GET
@Path("fetch") @Path("fetch")
public FetchResponse fetch(@HeaderParam("Authorization") final String authentication) { public InventoryFetchResponse fetch(@HeaderParam("Authorization") final String authentication) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("fetch called by " + steamID);
return new InventoryFetchResponse(genericsInventoryService.getInventory(steamID));
} }
@POST @POST
@Path("setSelected") @Path("setSelected")
public void setSelected(@HeaderParam("Authorization") final String authentication, public void setSelected(@HeaderParam("Authorization") final String authentication,
final SetSelectedRequest request) { final InventorySetSelectedRequest request) {
final var steamID = authenticateOrThrow(authentication);
logger.info("setSelected called by " + steamID);
genericsInventoryService.setSelected(steamID, request.category(), request.itemKey());
} }
} }

View File

@@ -0,0 +1,25 @@
package ch.gtache.elderscrollslegends.service.inventory;
import ch.gtache.elderscrollslegends.service.BaseService;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javax.sql.DataSource;
import java.util.List;
@ApplicationScoped
class GenericsInventoryService extends BaseService {
@Inject
GenericsInventoryService(final DataSource dataSource) {
super(dataSource);
}
List<CategoryData> getInventory(final String steamID) {
return List.of();
}
void setSelected(final String steamID, final String category, final String itemKey) {
}
}

View File

@@ -38,8 +38,8 @@ public class InventoryEndpoints {
@Path("saveDeck_v2") @Path("saveDeck_v2")
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public SaveResult saveDeck(@HeaderParam("Authorization") final String authentication, public InventorySaveResult saveDeck(@HeaderParam("Authorization") final String authentication,
final Deck request) { final Deck request) {
return null; return null;
} }
@@ -47,8 +47,8 @@ public class InventoryEndpoints {
@Path("setSeens") @Path("setSeens")
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public SaveResult setSeens(@HeaderParam("Authorization") final String authentication, public InventorySaveResult setSeens(@HeaderParam("Authorization") final String authentication,
final SetSeens request) { final InventorySetSeens request) {
return null; return null;
} }

View File

@@ -2,5 +2,5 @@ package ch.gtache.elderscrollslegends.service.inventory;
import java.util.List; import java.util.List;
public record FetchResponse(List<CategoryData> categories) { public record InventoryFetchResponse(List<CategoryData> categories) {
} }

View File

@@ -1,4 +1,4 @@
package ch.gtache.elderscrollslegends.service.inventory; package ch.gtache.elderscrollslegends.service.inventory;
public record SaveResult(boolean success) { public record InventorySaveResult(boolean success) {
} }

View File

@@ -0,0 +1,4 @@
package ch.gtache.elderscrollslegends.service.inventory;
public record InventorySeenEntry(int cardTypeHash, boolean isPremium, boolean isRegular) {
}

View File

@@ -0,0 +1,4 @@
package ch.gtache.elderscrollslegends.service.inventory;
public record InventorySelectedItem(String category, String selected) {
}

View File

@@ -2,5 +2,5 @@ package ch.gtache.elderscrollslegends.service.inventory;
import java.util.List; import java.util.List;
public record SetSeens(List<SeenEntry> entries) { public record InventorySetSeens(List<InventorySeenEntry> entries) {
} }

View File

@@ -0,0 +1,4 @@
package ch.gtache.elderscrollslegends.service.inventory;
public record InventorySetSelectedRequest(String category, String itemKey) {
}

View File

@@ -1,4 +0,0 @@
package ch.gtache.elderscrollslegends.service.inventory;
public record SeenEntry(int cardTypeHash, boolean isPremium, boolean isRegular) {
}

View File

@@ -1,4 +0,0 @@
package ch.gtache.elderscrollslegends.service.inventory;
public record SelectedItem(String category, String selected) {
}

View File

@@ -1,4 +0,0 @@
package ch.gtache.elderscrollslegends.service.inventory;
public record SetSelectedRequest(String category, String itemKey) {
}

View File

@@ -1,20 +1,38 @@
package ch.gtache.elderscrollslegends.service.matching; package ch.gtache.elderscrollslegends.service.matching;
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
import ch.gtache.elderscrollslegends.service.account.AccountService;
import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes; import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET; import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam; import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST; import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
import org.jboss.logging.Logger;
import java.util.Objects;
@Path("matching") @Path("matching")
public class MatchingEndpoints { public class MatchingEndpoints extends BaseEndpoints {
private static final Logger logger = Logger.getLogger(MatchingEndpoints.class.getName());
private final MatchingService matchingService;
@Inject
MatchingEndpoints(final AccountService accountService, final MatchingService matchingService) {
super(accountService);
this.matchingService = Objects.requireNonNull(matchingService);
}
@GET @GET
@Path("reserve") @Path("reserve")
@Produces("application/json") @Produces("application/json")
public ClientMatchReserveRequestResult reserve(@HeaderParam("Authorization") final String authentication) { public ClientMatchReserveRequestResult reserve(@HeaderParam("Authorization") final String authentication) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("reserve called by " + steamID);
return new ClientMatchReserveRequestResult("", MatchErrorType.InternalError);
} }
@POST @POST
@@ -23,7 +41,9 @@ public class MatchingEndpoints {
@Produces("application/json") @Produces("application/json")
public ClientMatchRequestResult add(@HeaderParam("Authorization") final String authentication, public ClientMatchRequestResult add(@HeaderParam("Authorization") final String authentication,
final ClientMatchRequest request) { final ClientMatchRequest request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("add called by " + steamID + " : " + request);
return new ClientMatchRequestResult("", "", Integer.MAX_VALUE, Integer.MAX_VALUE);
} }
@POST @POST
@@ -31,6 +51,9 @@ public class MatchingEndpoints {
@Consumes("application/json") @Consumes("application/json")
public void cancel(@HeaderParam("Authorization") final String authentication, public void cancel(@HeaderParam("Authorization") final String authentication,
final ClientMatchCancelRequest request) { final ClientMatchCancelRequest request) {
final var steamID = authenticateOrThrow(authentication);
logger.info("cancel called by " + steamID + " : " + request);
matchingService.cancel(steamID, request.requestId(), request.friendBuid());
} }
@POST @POST
@@ -38,6 +61,9 @@ public class MatchingEndpoints {
@Consumes("application/json") @Consumes("application/json")
public void respondChallenge(@HeaderParam("Authorization") final String authentication, public void respondChallenge(@HeaderParam("Authorization") final String authentication,
final ClientChallengeRequest request) { final ClientChallengeRequest request) {
final var steamID = authenticateOrThrow(authentication);
logger.info("respondChallenge called by " + steamID + " : " + request);
matchingService.respondChallenge(steamID, request.friendBuid(), request.type());
} }
@POST @POST
@@ -46,20 +72,25 @@ public class MatchingEndpoints {
@Produces("application/json") @Produces("application/json")
public RefreshResult refresh(@HeaderParam("Authorization") final String authentication, public RefreshResult refresh(@HeaderParam("Authorization") final String authentication,
final RefreshRequest request) { final RefreshRequest request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("refresh called by " + steamID + " : " + request);
return new RefreshResult(Integer.MAX_VALUE, null);
} }
@GET @GET
@Path("rejoin") @Path("rejoin")
@Produces("application/json") @Produces("application/json")
public ClientMatchRejoinResult rejoin(@HeaderParam("Authorization") final String authentication) { public ClientMatchRejoinResult rejoin(@HeaderParam("Authorization") final String authentication) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("rejoin called by " + steamID);
return new ClientMatchRejoinResult(null);
} }
@GET @GET
@Path("rejoindeny") @Path("rejoindeny")
public void rejoinDeny(@HeaderParam("Authorization") final String authentication) { public void rejoinDeny(@HeaderParam("Authorization") final String authentication) {
final var steamID = authenticateOrThrow(authentication);
logger.info("rejoinDeny called by " + steamID);
} }
@POST @POST
@@ -68,7 +99,10 @@ public class MatchingEndpoints {
@Produces("application/json") @Produces("application/json")
public ClientOpponentBuidResult requestOpponent(@HeaderParam("Authorization") final String authentication, public ClientOpponentBuidResult requestOpponent(@HeaderParam("Authorization") final String authentication,
final ClientOpponentBuidRequest request) { final ClientOpponentBuidRequest request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("requestOpponent called by " + steamID + " : " + request);
final var opponentID = matchingService.requestOpponent(steamID, request.friendBuid());
return new ClientOpponentBuidResult(opponentID);
} }
@POST @POST
@@ -77,7 +111,9 @@ public class MatchingEndpoints {
@Produces("application/json") @Produces("application/json")
public ClientSpectateRequestResult spectate(@HeaderParam("Authorization") final String authentication, public ClientSpectateRequestResult spectate(@HeaderParam("Authorization") final String authentication,
final ClientSpectateRequest request) { final ClientSpectateRequest request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("spectate called by " + steamID + " : " + request);
return new ClientSpectateRequestResult("", null);
} }
@POST @POST
@@ -86,8 +122,8 @@ public class MatchingEndpoints {
@Produces("application/json") @Produces("application/json")
public ClientSpectateRequestResult dualSpectate(@HeaderParam("Authorization") final String authentication, public ClientSpectateRequestResult dualSpectate(@HeaderParam("Authorization") final String authentication,
final ClientSpectateRequest request) { final ClientSpectateRequest request) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("dualspectate called by " + steamID + " : " + request);
return new ClientSpectateRequestResult("", null);
} }
} }

View File

@@ -0,0 +1,32 @@
package ch.gtache.elderscrollslegends.service.matching;
import ch.gtache.elderscrollslegends.service.BaseService;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javax.sql.DataSource;
@ApplicationScoped
class MatchingService extends BaseService {
@Inject
MatchingService(final DataSource dataSource) {
super(dataSource);
}
Object reserve(final String steamID) {
return null;
}
void cancel(final String steamID, final String requestID, final String friendID) {
}
void respondChallenge(final String steamID, final String friendID, final String type) {
}
String requestOpponent(final String steamID, final String friendID) {
return null;
}
}

View File

@@ -1,20 +1,35 @@
package ch.gtache.elderscrollslegends.service.packages; package ch.gtache.elderscrollslegends.service.packages;
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
import ch.gtache.elderscrollslegends.service.account.AccountService;
import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes; import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET; import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam; import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST; import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
import org.jboss.logging.Logger;
import java.util.List;
@Path("packages") @Path("packages")
public class PackagesEndpoints { public class PackagesEndpoints extends BaseEndpoints {
private static final Logger logger = Logger.getLogger(PackagesEndpoints.class);
@Inject
PackagesEndpoints(final AccountService accountService, final PackagesService packagesService) {
super(accountService);
}
@GET @GET
@Path("list") @Path("list")
@Produces("application/json") @Produces("application/json")
public ListPackagesResponse list(@HeaderParam("Authorization") final String authentication) { public ListPackagesResponse list(@HeaderParam("Authorization") final String authentication) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("list called by " + steamID);
return new ListPackagesResponse(0, List.of());
} }
@POST @POST
@@ -23,7 +38,9 @@ public class PackagesEndpoints {
@Produces("application/json") @Produces("application/json")
public DeliverResponse deliver(@HeaderParam("Authorization") final String authentication, public DeliverResponse deliver(@HeaderParam("Authorization") final String authentication,
final DeliverRequest deliverRequest) { final DeliverRequest deliverRequest) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("deliver called by " + steamID + " : " + deliverRequest);
return new DeliverResponse(new Delivered(0, 0, List.of()));
} }
@POST @POST
@@ -32,6 +49,8 @@ public class PackagesEndpoints {
@Produces("application/json") @Produces("application/json")
public MassPackOpeningResponse massPackOpening(@HeaderParam("Authorization") final String authentication, public MassPackOpeningResponse massPackOpening(@HeaderParam("Authorization") final String authentication,
final MassPackOpeningRequest massPackOpeningRequest) { final MassPackOpeningRequest massPackOpeningRequest) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("massPackOpening called by " + steamID + " : " + massPackOpeningRequest);
return new MassPackOpeningResponse(0, List.of());
} }
} }

View File

@@ -0,0 +1,16 @@
package ch.gtache.elderscrollslegends.service.packages;
import ch.gtache.elderscrollslegends.service.BaseService;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javax.sql.DataSource;
@ApplicationScoped
class PackagesService extends BaseService {
@Inject
PackagesService(final DataSource dataSource) {
super(dataSource);
}
}

View File

@@ -1,13 +1,24 @@
package ch.gtache.elderscrollslegends.service.presence; package ch.gtache.elderscrollslegends.service.presence;
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
import ch.gtache.elderscrollslegends.service.account.AccountService;
import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes; import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.HeaderParam; import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST; import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
import org.jboss.logging.Logger;
@Path("/beam/presence/v1") @Path("/beam/presence/v1")
public class PresenceEndpoints { public class PresenceEndpoints extends BaseEndpoints {
private static final Logger logger = Logger.getLogger(PresenceEndpoints.class);
@Inject
PresenceEndpoints(final AccountService accountService, final PresenceService presenceService) {
super(accountService);
}
@POST @POST
@Path("presence") @Path("presence")
@@ -15,6 +26,8 @@ public class PresenceEndpoints {
@Produces("application/json") @Produces("application/json")
public PostPresenceResponse presence(@HeaderParam("Authorization") final String authentication, public PostPresenceResponse presence(@HeaderParam("Authorization") final String authentication,
final PostPresenceBody postPresenceBody) { final PostPresenceBody postPresenceBody) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("presence called by " + steamID + " : " + postPresenceBody);
return new PostPresenceResponse("", 0, new PresenceResponse(0));
} }
} }

View File

@@ -0,0 +1,16 @@
package ch.gtache.elderscrollslegends.service.presence;
import ch.gtache.elderscrollslegends.service.BaseService;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javax.sql.DataSource;
@ApplicationScoped
class PresenceService extends BaseService {
@Inject
PresenceService(final DataSource dataSource) {
super(dataSource);
}
}

View File

@@ -1,5 +1,7 @@
package ch.gtache.elderscrollslegends.service.profile; package ch.gtache.elderscrollslegends.service.profile;
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
import ch.gtache.elderscrollslegends.service.account.AccountService;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.ws.rs.GET; import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam; import jakarta.ws.rs.HeaderParam;
@@ -11,59 +13,60 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
@Path("/profile") @Path("/profile")
public class ProfileEndpoints { public class ProfileEndpoints extends BaseEndpoints {
private static final Logger logger = Logger.getLogger(ProfileEndpoints.class); private static final Logger logger = Logger.getLogger(ProfileEndpoints.class);
private final ProfileService profileService; private final ProfileService profileService;
@Inject @Inject
ProfileEndpoints(final ProfileService profileService) { ProfileEndpoints(final AccountService accountService, final ProfileService profileService) {
super(accountService);
this.profileService = Objects.requireNonNull(profileService); this.profileService = Objects.requireNonNull(profileService);
} }
@POST @POST
@Path("/doE3Reset") @Path("/doE3Reset")
public void doE3Reset(@HeaderParam("Authorization") final String authentication) { public void doE3Reset(@HeaderParam("Authorization") final String authentication) {
logger.info("doE3Reset called by " + authentication); final var steamID = authenticateOrThrow(authentication);
//Do nothing logger.info("doE3Reset called by " + steamID);
} }
@POST @POST
@Path("/requestOptOut") @Path("/requestOptOut")
public void requestOptOut(@HeaderParam("Authorization") final String authentication) { public void requestOptOut(@HeaderParam("Authorization") final String authentication) {
logger.info("requestOptOut called by " + authentication); final var steamID = authenticateOrThrow(authentication);
//Do nothing logger.info("requestOptOut called by " + steamID);
} }
@POST @POST
@Path("/requestOptIn") @Path("/requestOptIn")
public void requestOptIn(@HeaderParam("Authorization") final String authentication) { public void requestOptIn(@HeaderParam("Authorization") final String authentication) {
logger.info("requestOptIn called by " + authentication); final var steamID = authenticateOrThrow(authentication);
//Do nothing logger.info("requestOptIn called by " + steamID);
} }
@POST @POST
@Path("/setOnboardingProgress") @Path("/setOnboardingProgress")
public void setOnboardingProgress(@HeaderParam("Authorization") final String authentication, public void setOnboardingProgress(@HeaderParam("Authorization") final String authentication,
final SetOnboardingProgressRequest request) { final SetOnboardingProgressRequest request) {
logger.info("setOnboardingProgress called by " + authentication + " : " + request); final var steamID = authenticateOrThrow(authentication);
//Do nothing logger.info("setOnboardingProgress called by " + steamID + " : " + request);
} }
@GET @GET
@Path("/setSeen") @Path("/setSeen")
public String setSeen(@HeaderParam("Authorization") final String authentication) { public String setSeen(@HeaderParam("Authorization") final String authentication) {
logger.info("setSeen called by " + authentication); final var steamID = authenticateOrThrow(authentication);
//Do nothing logger.info("setSeen called by " + steamID);
return null; return null;
} }
@GET @GET
@Path("/doSeasonRollover") @Path("/doSeasonRollover")
public String doSeasonRollover(@HeaderParam("Authorization") final String authentication) { public String doSeasonRollover(@HeaderParam("Authorization") final String authentication) {
logger.info("doSeasonRollover called by " + authentication); final var steamID = authenticateOrThrow(authentication);
//Do nothing logger.info("doSeasonRollover called by " + steamID);
return null; return null;
} }
@@ -71,8 +74,9 @@ public class ProfileEndpoints {
@Path("getProfileForBuid") @Path("getProfileForBuid")
public ProfileForBuidResponse getProfileForBuid(@HeaderParam("Authorization") final String authentication, public ProfileForBuidResponse getProfileForBuid(@HeaderParam("Authorization") final String authentication,
final GetProfileForBuidRequest request) { final GetProfileForBuidRequest request) {
logger.info("getProfileForBuid called by " + authentication + " : " + request); final var steamID = authenticateOrThrow(authentication);
final var profile = profileService.getProfile(request.buid()); logger.info("getProfileForBuid called by " + steamID + " : " + request);
final var profile = profileService.getProfile(steamID, request.buid());
return new ProfileForBuidResponse(profile, List.of()); return new ProfileForBuidResponse(profile, List.of());
} }
@@ -80,14 +84,15 @@ public class ProfileEndpoints {
@Path("logMatchStart") @Path("logMatchStart")
public void logMatchStart(@HeaderParam("Authorization") final String authentication, public void logMatchStart(@HeaderParam("Authorization") final String authentication,
final MatchStartLogData request) { final MatchStartLogData request) {
logger.info("logMatchStart called by " + authentication + " : " + request); final var steamID = authenticateOrThrow(authentication);
//Do nothing logger.info("logMatchStart called by " + steamID + " : " + request);
} }
@GET @GET
@Path("/fetch") @Path("/fetch")
public FetchProfileResponse getFetch(@HeaderParam("Authorization") final String authentication) { public FetchProfileResponse getFetch(@HeaderParam("Authorization") final String authentication) {
logger.info("fetch called by " + authentication); final var steamID = authenticateOrThrow(authentication);
return null; logger.info("fetch called by " + steamID);
return new FetchProfileResponse(profileService.getProfile(steamID, steamID));
} }
} }

View File

@@ -1,8 +1,8 @@
package ch.gtache.elderscrollslegends.service.profile; package ch.gtache.elderscrollslegends.service.profile;
import ch.gtache.elderscrollslegends.service.inventory.SelectedItem; import ch.gtache.elderscrollslegends.service.inventory.InventorySelectedItem;
import java.util.List; import java.util.List;
public record ProfileForBuidResponse(ProfileStruct profile, List<SelectedItem> categories) { public record ProfileForBuidResponse(ProfileStruct profile, List<InventorySelectedItem> categories) {
} }

View File

@@ -1,22 +1,21 @@
package ch.gtache.elderscrollslegends.service.profile; package ch.gtache.elderscrollslegends.service.profile;
import ch.gtache.elderscrollslegends.service.BaseService;
import jakarta.enterprise.context.ApplicationScoped; import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.util.Objects;
@ApplicationScoped @ApplicationScoped
public class ProfileService { public class ProfileService extends BaseService {
private final DataSource dataSource;
@Inject @Inject
ProfileService(final DataSource dataSource) { ProfileService(final DataSource dataSource) {
this.dataSource = Objects.requireNonNull(dataSource); super(dataSource);
} }
ProfileStruct getProfile(final String steamID) { ProfileStruct getProfile(final String steamID, final String profileID) {
return null;//new ProfileStruct(name, level, gold, gems, xp, tickets, onboardingProgressFlags, dailyGold, dailyGems, ratins, maxRatings, collectionStats, seasonRollovers); return null;//new ProfileStruct(name, level, gold, gems, xp, tickets, onboardingProgressFlags, dailyGold, dailyGems, ratins, maxRatings, collectionStats, seasonRollovers);
} }
} }

View File

@@ -1,16 +1,35 @@
package ch.gtache.elderscrollslegends.service.pubsub; package ch.gtache.elderscrollslegends.service.pubsub;
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
import ch.gtache.elderscrollslegends.service.account.AccountService;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET; import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam; import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
import org.jboss.logging.Logger;
import java.util.Objects;
@Path("pubsubauth") @Path("pubsubauth")
public class PubSubAuthEndpoints { public class PubSubAuthEndpoints extends BaseEndpoints {
private static final Logger logger = Logger.getLogger(PubSubAuthEndpoints.class);
private final PubSubService pubSubService;
@Inject
PubSubAuthEndpoints(final AccountService accountService, final PubSubService pubSubService) {
super(accountService);
this.pubSubService = Objects.requireNonNull(pubSubService);
}
@GET @GET
@Produces("application/json") @Produces("application/json")
public PubSubResponse get(@HeaderParam("Authorization") final String authentication) { public PubSubResponse get(@HeaderParam("Authorization") final String authentication) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("get called by " + steamID);
final var chatRooms = pubSubService.getChatRooms(steamID);
return new PubSubResponse(authentication.replace("Bearer ", ""), chatRooms);
} }
} }

View File

@@ -0,0 +1,21 @@
package ch.gtache.elderscrollslegends.service.pubsub;
import ch.gtache.elderscrollslegends.service.BaseService;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javax.sql.DataSource;
import java.util.List;
@ApplicationScoped
class PubSubService extends BaseService {
@Inject
PubSubService(final DataSource dataSource) {
super(dataSource);
}
ChatRooms getChatRooms(final String steamID) {
return new ChatRooms(List.of());
}
}

View File

@@ -1,43 +1,64 @@
package ch.gtache.elderscrollslegends.service.quests; package ch.gtache.elderscrollslegends.service.quests;
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
import ch.gtache.elderscrollslegends.service.account.AccountService;
import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes; import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET; import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam; import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST; import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
import org.jboss.logging.Logger;
import java.util.Objects;
@Path("quests") @Path("quests")
public class QuestsEndpoints { public class QuestsEndpoints extends BaseEndpoints {
private static final Logger logger = Logger.getLogger(QuestsEndpoints.class);
private final QuestsService questsService;
@Inject
QuestsEndpoints(final AccountService accountService, final QuestsService questsService) {
super(accountService);
this.questsService = Objects.requireNonNull(questsService);
}
@GET @GET
@Path("fetch") @Path("fetch")
@Produces("application/json") @Produces("application/json")
public QuestsFetchResponse fetch(@HeaderParam("Authorization") final String authentication) { public QuestsFetchResponse fetch(@HeaderParam("Authorization") final String authentication) {
return null; final var steamID = authenticateOrThrow(authentication);
logger.info("fetch called by " + steamID);
return new QuestsFetchResponse();
} }
@POST @POST
@Path("setSeen") @Path("setSeen")
@Consumes("application/json") @Consumes("application/json")
public void setSeen(@HeaderParam("Authorization") final String authentication, public void setSeen(@HeaderParam("Authorization") final String authentication,
final SetSeenRequest request) { final QuestsSetSeenRequest request) {
final var steamID = authenticateOrThrow(authentication);
logger.info("setSeen called by " + steamID + " : " + request);
} }
@POST @POST
@Path("skip") @Path("skip")
@Consumes("application/json") @Consumes("application/json")
public void skip(@HeaderParam("Authorization") final String authentication, public void skip(@HeaderParam("Authorization") final String authentication,
final SkipRequest request) { final QuestsSkipRequest request) {
final var steamID = authenticateOrThrow(authentication);
logger.info("skip called by " + steamID + " : " + request);
} }
@POST @POST
@Path("select") @Path("select")
@Consumes("application/json") @Consumes("application/json")
public void select(@HeaderParam("Authorization") final String authentication, public void select(@HeaderParam("Authorization") final String authentication,
final SelectRequest request) { final QuestsSelectRequest request) {
final var steamID = authenticateOrThrow(authentication);
logger.info("select called by " + steamID + " : " + request);
} }
} }

View File

@@ -1,4 +1,4 @@
package ch.gtache.elderscrollslegends.service.quests; package ch.gtache.elderscrollslegends.service.quests;
public record SelectRequest(int questTypeHash) { public record QuestsSelectRequest(int questTypeHash) {
} }

View File

@@ -0,0 +1,16 @@
package ch.gtache.elderscrollslegends.service.quests;
import ch.gtache.elderscrollslegends.service.BaseService;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import javax.sql.DataSource;
@ApplicationScoped
class QuestsService extends BaseService {
@Inject
QuestsService(final DataSource dataSource) {
super(dataSource);
}
}

View File

@@ -1,4 +1,4 @@
package ch.gtache.elderscrollslegends.service.quests; package ch.gtache.elderscrollslegends.service.quests;
public record SetSeenRequest() { public record QuestsSetSeenRequest() {
} }

View File

@@ -1,4 +1,4 @@
package ch.gtache.elderscrollslegends.service.quests; package ch.gtache.elderscrollslegends.service.quests;
public record SkipRequest() { public record QuestsSkipRequest() {
} }

Some files were not shown because too many files have changed in this diff Show More