Starts creating SQL, starts parsing client JSONs
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
package ch.gtache.elderscrollslegends.service;
|
||||
|
||||
public enum AIDifficulty {
|
||||
None,
|
||||
Novice,
|
||||
Adept,
|
||||
Expert,
|
||||
}
|
||||
@@ -22,6 +22,10 @@ public class BaseEndpoints {
|
||||
throw new NotAuthorizedException("Invalid token", "Bearer");
|
||||
}
|
||||
final var token = bearerToken.replace("Bearer ", "");
|
||||
return authenticateTokenOrThrow(token);
|
||||
}
|
||||
|
||||
protected String authenticateTokenOrThrow(final String token) {
|
||||
final var steamID = accountService.getSteamIDFromToken(token);
|
||||
if (steamID == null) {
|
||||
throw new NotAuthorizedException("Invalid token", "Bearer");
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package ch.gtache.elderscrollslegends.service;
|
||||
|
||||
public record BaseResult(ResultCode resultCode, String endpoint) {
|
||||
|
||||
public BaseResult(final ResultCode resultCode) {
|
||||
this(resultCode, "");
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,13 @@ public class BaseService {
|
||||
this.dataSource = Objects.requireNonNull(dataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for CDI
|
||||
*/
|
||||
protected BaseService() {
|
||||
this.dataSource = null;
|
||||
}
|
||||
|
||||
protected DataSource dataSource() {
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service;
|
||||
|
||||
public record Card(int hash) {
|
||||
import ch.gtache.elderscrollslegends.service.profile.CollectionName;
|
||||
import ch.gtache.elderscrollslegends.service.profile.Rarity;
|
||||
|
||||
public record Card(int id, String name, CollectionName collectionName, Rarity rarity) {
|
||||
}
|
||||
|
||||
@@ -1,20 +1,50 @@
|
||||
package ch.gtache.elderscrollslegends.service;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.profile.CollectionName;
|
||||
import ch.gtache.elderscrollslegends.service.profile.Rarity;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ApplicationScoped
|
||||
public class CardService extends BaseService {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(CardService.class);
|
||||
|
||||
private static final String GET_CARD_QUERY = "SELECT c.name, coll.name, r.name FROM card c JOIN collection coll ON c.collection_id = coll.id JOIN rarity r ON c.rarity_id = r.id WHERE c.id = ?";
|
||||
|
||||
private final Map<Integer, Card> cache;
|
||||
|
||||
@Inject
|
||||
CardService(final DataSource dataSource) {
|
||||
super(dataSource);
|
||||
this.cache = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
public Card getCard(final int hash) {
|
||||
// TODO
|
||||
return new Card(hash);
|
||||
return cache.computeIfAbsent(hash, this::retrieveCard);
|
||||
}
|
||||
|
||||
private Card retrieveCard(final int hash) {
|
||||
try (final var connection = dataSource().getConnection();
|
||||
final var statement = connection.prepareStatement(GET_CARD_QUERY)) {
|
||||
statement.setInt(1, hash);
|
||||
try (final var rs = statement.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
final var name = rs.getString(1);
|
||||
final var collection = rs.getString(2);
|
||||
final var rarity = rs.getString(3);
|
||||
return new Card(hash, name, CollectionName.getCollection(collection), Rarity.valueOf(rarity));
|
||||
}
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
logger.error("Error checking for card " + hash, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package ch.gtache.elderscrollslegends.service;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.profile.CollectionName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record Collection(CollectionName name, List<Card> cards) {
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package ch.gtache.elderscrollslegends.service;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.profile.CollectionName;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ApplicationScoped
|
||||
public class CollectionService extends BaseService {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(CollectionService.class);
|
||||
|
||||
private static final String GET_CARDS_QUERY = "SELECT id FROM card WHERE collection_id=(SELECT id FROM collection WHERE name=?)";
|
||||
|
||||
private final Map<CollectionName, Collection> cache;
|
||||
private final CardService cardService;
|
||||
|
||||
@Inject
|
||||
CollectionService(final DataSource dataSource, final CardService cardService) {
|
||||
super(dataSource);
|
||||
this.cardService = Objects.requireNonNull(cardService);
|
||||
this.cache = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
public Collection getCollection(final String name) {
|
||||
return getCollection(CollectionName.getCollection(name));
|
||||
}
|
||||
|
||||
public Collection getCollection(final CollectionName name) {
|
||||
return cache.computeIfAbsent(name, this::retrieveCollection);
|
||||
}
|
||||
|
||||
private Collection retrieveCollection(final CollectionName name) {
|
||||
try (final var connection = dataSource().getConnection();
|
||||
final var statement = connection.prepareStatement(GET_CARDS_QUERY)) {
|
||||
statement.setString(1, name.databaseName());
|
||||
try (final var rs = statement.executeQuery()) {
|
||||
final var cards = new ArrayList<Card>();
|
||||
while (rs.next()) {
|
||||
cards.add(cardService.getCard(rs.getInt(1)));
|
||||
}
|
||||
return new Collection(name, cards);
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
logger.error("Error checking for collection " + name, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,20 +1,158 @@
|
||||
package ch.gtache.elderscrollslegends.service;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.inventory.Deck;
|
||||
import ch.gtache.elderscrollslegends.service.inventory.DeckCard;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ApplicationScoped
|
||||
public class DeckService extends BaseService {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(DeckService.class);
|
||||
|
||||
private static final String GET_QUERY = "SELECT name, has_been_seen, is_valid, is_locked, rename_from_user, art_type_id, deck_type_id, event_id " +
|
||||
"FROM deck WHERE id=? AND player_id=(SELECT id FROM player WHERE steam_id=?)";
|
||||
|
||||
@Inject
|
||||
DeckService(final DataSource dataSource) {
|
||||
super(dataSource);
|
||||
}
|
||||
|
||||
public Deck getDeck(final String steamID, final long deckID) {
|
||||
final var steamIDHandle = Long.parseLong(steamID);
|
||||
try (final var connection = dataSource().getConnection();
|
||||
final var statement = connection.prepareStatement(GET_QUERY)) {
|
||||
statement.setLong(1, deckID);
|
||||
statement.setLong(2, steamIDHandle);
|
||||
try (final var rs = statement.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
var i = 0;
|
||||
final var displayName = rs.getString(++i);
|
||||
final var hasBeenSeen = rs.getBoolean(++i);
|
||||
final var isValid = rs.getBoolean(++i);
|
||||
final var isLocked = rs.getBoolean(++i);
|
||||
final var renameFromUser = rs.getBoolean(++i);
|
||||
final var artTypeHash = rs.getInt(++i);
|
||||
final var deckTypeHash = rs.getInt(++i);
|
||||
final var eventId = rs.getLong(++i);
|
||||
final var deckCards = getDeckCards(deckID);
|
||||
return new Deck(deckID, displayName, hasBeenSeen, isValid, isLocked, renameFromUser, artTypeHash, deckTypeHash, deckCards, eventId);
|
||||
}
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
logger.error("Error getting deck " + deckID + " for player " + steamID, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<DeckCard> getDeckCards(final long deckID) {
|
||||
final var list = new ArrayList<DeckCard>();
|
||||
try (final var connection = dataSource().getConnection();
|
||||
final var statement = connection.prepareStatement("SELECT type_id, num_regular, num_premium FROM deck_card WHERE deck_id=?")) {
|
||||
statement.setLong(1, deckID);
|
||||
try (final var rs = statement.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
var i = 0;
|
||||
final var cardHash = rs.getInt(++i);
|
||||
final var numRegular = rs.getInt(++i);
|
||||
final var numPremium = rs.getInt(++i);
|
||||
list.add(new DeckCard(cardHash, numRegular, numPremium));
|
||||
}
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
logger.error("Error getting deck cards for deck " + deckID, e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public long createDeck(final String steamID, final String name) {
|
||||
final var steamIDHandle = Long.parseLong(steamID);
|
||||
try (final var connection = dataSource().getConnection();
|
||||
final var statement = connection.prepareStatement("INSERT INTO deck (player_id, name) VALUES ((SELECT id FROM player WHERE steam_id=?), ?) RETURNING id")) {
|
||||
statement.setLong(1, steamIDHandle);
|
||||
statement.setString(2, name);
|
||||
try (final var rs = statement.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
return rs.getLong(1);
|
||||
}
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
logger.error("Error inserting deck " + name + " for player " + steamID, e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void deleteDeck(final String steamID, final long deckID) {
|
||||
final var steamIDHandle = Long.parseLong(steamID);
|
||||
try (final var connection = dataSource().getConnection();
|
||||
final var statement = connection.prepareStatement("DELETE FROM deck WHERE id=? AND player_id=(SELECT id FROM player WHERE steam_id=?)")) {
|
||||
statement.setLong(1, deckID);
|
||||
statement.setLong(2, steamIDHandle);
|
||||
statement.executeUpdate();
|
||||
} catch (final SQLException e) {
|
||||
logger.error("Error deleting deck " + deckID + " for player " + steamID, e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean saveDeck(final String steamID, final Deck deck) {
|
||||
final var steamIDHandle = Long.parseLong(steamID);
|
||||
try (final var connection = dataSource().getConnection()) {
|
||||
return updateDeck(connection, steamIDHandle, deck);
|
||||
} catch (final SQLException e) {
|
||||
logger.error("Error saving deck " + deck.id() + " for player " + steamID, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean updateDeck(final Connection connection, final long steamIDHandle, final Deck deck) throws SQLException {
|
||||
try (final var statement = connection.prepareStatement("UPDATE deck SET name=?, has_been_seen=?, is_valid=?, is_locked=?, rename_from_user=?," +
|
||||
"art_type_id=?, deck_type_id=?, event_id=? WHERE id=? AND player_id=(SELECT id FROM player WHERE steam_id=?)")) {
|
||||
connection.setAutoCommit(false);
|
||||
updateDeckCards(connection, deck.id(), deck.cards());
|
||||
|
||||
var i = 0;
|
||||
statement.setString(++i, deck.displayName());
|
||||
statement.setBoolean(++i, deck.hasBeenSeen());
|
||||
statement.setBoolean(++i, deck.isValid());
|
||||
statement.setBoolean(++i, deck.isLocked());
|
||||
statement.setBoolean(++i, deck.renameFromUser());
|
||||
statement.setInt(++i, deck.artTypeHash());
|
||||
statement.setInt(++i, deck.deckTypeHash());
|
||||
statement.setLong(++i, deck.eventId());
|
||||
statement.setLong(++i, deck.id());
|
||||
statement.setLong(++i, steamIDHandle);
|
||||
final var ret = statement.executeUpdate() > 0;
|
||||
connection.commit();
|
||||
return ret;
|
||||
} catch (final SQLException e) {
|
||||
logger.error("Error saving deck " + deck.id() + " for player " + steamIDHandle, e);
|
||||
connection.rollback();
|
||||
return false;
|
||||
} finally {
|
||||
connection.setAutoCommit(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDeckCards(final Connection connection, final long deckID, final List<DeckCard> cards) throws SQLException {
|
||||
try (final var deleteCardStatement = connection.prepareStatement("DELETE FROM deck_card WHERE deck_id=?");
|
||||
final var insertCardStatement = connection.prepareStatement("INSERT INTO deck_card (deck_id, type_id, num_regular, num_premium) VALUES (?,?,?,?)")) {
|
||||
deleteCardStatement.setLong(1, deckID);
|
||||
deleteCardStatement.executeUpdate();
|
||||
for (final var card : cards) {
|
||||
insertCardStatement.setLong(1, deckID);
|
||||
insertCardStatement.setInt(2, card.typeHash());
|
||||
insertCardStatement.setInt(3, card.numRegular());
|
||||
insertCardStatement.setInt(4, card.numPremium());
|
||||
insertCardStatement.addBatch();
|
||||
}
|
||||
insertCardStatement.executeBatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package ch.gtache.elderscrollslegends.service;
|
||||
|
||||
public enum LaneType {
|
||||
None,
|
||||
Default,
|
||||
Stealth,
|
||||
Liquid_Courage,
|
||||
Armor,
|
||||
Masquerade_Ball,
|
||||
Docks,
|
||||
Water,
|
||||
Sewer,
|
||||
Jail,
|
||||
Mine_Depths,
|
||||
Venom,
|
||||
Reanimation,
|
||||
Altar_Of_Silence,
|
||||
Torment,
|
||||
Eclipse,
|
||||
Heist,
|
||||
Conveyor,
|
||||
Incinerator,
|
||||
Smelting,
|
||||
Mage_Tower,
|
||||
Surplus,
|
||||
Plunder,
|
||||
Renewal,
|
||||
Armory,
|
||||
Siege,
|
||||
Killing_Field,
|
||||
Fountain,
|
||||
Library,
|
||||
Windy,
|
||||
Campfire,
|
||||
Barracks,
|
||||
King_Of_The_Hill,
|
||||
Blitz,
|
||||
Ballista_Tower,
|
||||
Hall_Of_Mirrors,
|
||||
Champions_Arena,
|
||||
Temple,
|
||||
Lucky,
|
||||
Fortifications,
|
||||
Warzone,
|
||||
Graveyard,
|
||||
Inner_Fire,
|
||||
Zoo,
|
||||
Wispmothers_Blessing,
|
||||
Flanking,
|
||||
City_Gates,
|
||||
City_Gates_Stealth,
|
||||
Default_LowPri,
|
||||
Monastery,
|
||||
Madness,
|
||||
Order,
|
||||
Mania,
|
||||
Dementia,
|
||||
Jode,
|
||||
Count,
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package ch.gtache.elderscrollslegends.service;
|
||||
|
||||
public enum MatchMode {
|
||||
None,
|
||||
Campaign,
|
||||
SoloArena,
|
||||
VersusArena,
|
||||
PracticeBattle,
|
||||
VersusBattle,
|
||||
EventBattle,
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service;
|
||||
|
||||
public enum MatchType {
|
||||
Solo,
|
||||
Challenge,
|
||||
Multi,
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,413 @@
|
||||
package ch.gtache.elderscrollslegends.service;
|
||||
|
||||
public enum ResultCode {
|
||||
Ok(0),
|
||||
HTTPInternalError(1),
|
||||
HTTPError(2),
|
||||
InternalError(3),
|
||||
Unauthorized(4),
|
||||
NotYetSupported(5),
|
||||
BadParameters(6),
|
||||
FailedConfigFetch(7),
|
||||
MissingConfigData(8),
|
||||
QueryFailure(9),
|
||||
DeviceIdNotFound(10),
|
||||
SteamNotAvailable(11),
|
||||
DevAuthFailed(12),
|
||||
SteamAuthFailed(13),
|
||||
BNETAuthFailed(14),
|
||||
BNETAuthInvalidLoginCredentials(15),
|
||||
BNETAuthErrorVerifyingAuthentication(16),
|
||||
BNETAuthUnknownAccount(17),
|
||||
SparkleLoginFailed(18),
|
||||
InvalidBuildComponent(19),
|
||||
NoValidBuildForChannel(20),
|
||||
BannedAccount(21),
|
||||
UpgradeAccountUnknownFailure(22),
|
||||
UpgradeAccountUsernameTaken(23),
|
||||
UpgradeAccountEmailTaken(24),
|
||||
UpgradeAccountInvalidUsername(25),
|
||||
UpgradeAccountInvalidPassword(26),
|
||||
UpgradeAccountInvalidEmail(27),
|
||||
UpgradeAccountInvalidSecretAnswer(28),
|
||||
UpgradeAccountInvalidAccountType(29),
|
||||
LinkAccountUnknownFailure(30),
|
||||
LinkAccountObjectAlreadyExists(31),
|
||||
InventoryErrorDeliveringPackage(32),
|
||||
InventoryErrorFetching(33),
|
||||
InventorySaveDeckFailed(34),
|
||||
InventoryDeleteDeckFailed(35),
|
||||
InventoryCopyDeckFailed(36),
|
||||
PackagesFailedList(37),
|
||||
PackagesFailedDelivery(38),
|
||||
MatchReserveFailed(39),
|
||||
MatchFailedReservationFetch(40),
|
||||
MatchDeckNotFound(41),
|
||||
MatchDeckInvalid(42),
|
||||
MatchFailedCancel(43),
|
||||
MatchRefreshFailed(44),
|
||||
ShopMissingRequiredSteamId(45),
|
||||
ShopFailedSteamPurchaseContact(46),
|
||||
ShopFailedToFinalizeIAPPurchase(47),
|
||||
ShopFailedPurchase(48),
|
||||
QuestFailedCheckForNew(49),
|
||||
QuestFailedSelection(50),
|
||||
QuestFailedSkip(51),
|
||||
AnonymousBNETAuthFailed(52),
|
||||
BNETGetLegalDocumentsFailure(53),
|
||||
BNETAcceptLegalDocumentsUnknownFailure(54),
|
||||
BNETAcceptLegalDocumentsUnauthorizedAccess(55),
|
||||
BNETAnonymousAccountCreationFailed(56),
|
||||
SparkleLoginUnexpectedUserId(57),
|
||||
LoginTokenNotFound(58),
|
||||
UpgradeAccountBuidMissingFromResponse(59),
|
||||
UpgradeAccountInvalidDeviceId(60),
|
||||
ChallengeFriendInMatch(61),
|
||||
LoggedInElsewhere(62),
|
||||
SeasonRolloverRequired(63),
|
||||
DownForMaintenance(64),
|
||||
LinkAccountConflict(65),
|
||||
ResolveAccountUnknownFailure(66),
|
||||
Placeholder_15(67),
|
||||
Placeholder_16(68),
|
||||
Placeholder_17(69),
|
||||
Placeholder_18(70),
|
||||
Placeholder_19(71),
|
||||
Placeholder_20(72),
|
||||
Placeholder_21(73),
|
||||
Placeholder_22(74),
|
||||
Placeholder_23(75),
|
||||
Placeholder_24(76),
|
||||
Placeholder_25(77),
|
||||
Placeholder_26(78),
|
||||
Placeholder_27(79),
|
||||
Placeholder_28(80),
|
||||
Placeholder_29(81),
|
||||
Placeholder_30(82),
|
||||
Placeholder_31(83),
|
||||
Placeholder_32(84),
|
||||
Placeholder_33(85),
|
||||
Placeholder_34(86),
|
||||
Placeholder_35(87),
|
||||
Placeholder_36(88),
|
||||
Placeholder_37(89),
|
||||
Placeholder_38(90),
|
||||
Placeholder_39(91),
|
||||
Placeholder_40(92),
|
||||
Placeholder_41(93),
|
||||
Placeholder_42(94),
|
||||
Placeholder_43(95),
|
||||
Placeholder_44(96),
|
||||
Placeholder_45(97),
|
||||
Placeholder_46(98),
|
||||
Placeholder_47(99),
|
||||
Placeholder_48(100),
|
||||
Placeholder_49(101),
|
||||
Placeholder_50(102),
|
||||
Placeholder_51(103),
|
||||
Placeholder_52(104),
|
||||
Placeholder_53(105),
|
||||
Placeholder_54(106),
|
||||
Placeholder_55(107),
|
||||
Placeholder_56(108),
|
||||
Placeholder_57(109),
|
||||
Placeholder_58(110),
|
||||
Placeholder_59(111),
|
||||
Placeholder_60(112),
|
||||
Placeholder_61(113),
|
||||
Placeholder_62(114),
|
||||
Placeholder_63(115),
|
||||
Placeholder_64(116),
|
||||
Placeholder_65(117),
|
||||
Placeholder_66(118),
|
||||
Placeholder_67(119),
|
||||
Placeholder_68(120),
|
||||
Placeholder_69(121),
|
||||
Placeholder_70(122),
|
||||
Placeholder_71(123),
|
||||
Placeholder_72(124),
|
||||
Placeholder_73(125),
|
||||
Placeholder_74(126),
|
||||
Placeholder_75(127),
|
||||
Placeholder_76(128),
|
||||
Placeholder_77(129),
|
||||
Placeholder_78(130),
|
||||
Placeholder_79(131),
|
||||
Placeholder_80(132),
|
||||
Placeholder_81(133),
|
||||
Placeholder_82(134),
|
||||
Placeholder_83(135),
|
||||
Placeholder_84(136),
|
||||
Placeholder_85(137),
|
||||
Placeholder_86(138),
|
||||
Placeholder_87(139),
|
||||
Placeholder_88(140),
|
||||
Placeholder_89(141),
|
||||
Placeholder_90(142),
|
||||
Placeholder_91(143),
|
||||
Placeholder_92(144),
|
||||
Placeholder_93(145),
|
||||
Placeholder_94(146),
|
||||
Placeholder_95(147),
|
||||
Placeholder_96(148),
|
||||
Placeholder_97(149),
|
||||
Placeholder_98(150),
|
||||
Placeholder_99(151),
|
||||
Placeholder_100(152),
|
||||
Placeholder_101(153),
|
||||
Placeholder_102(154),
|
||||
Placeholder_103(155),
|
||||
Placeholder_104(156),
|
||||
Placeholder_105(157),
|
||||
Placeholder_106(158),
|
||||
Placeholder_107(159),
|
||||
Placeholder_108(160),
|
||||
Placeholder_109(161),
|
||||
Placeholder_110(162),
|
||||
Placeholder_111(163),
|
||||
Placeholder_112(164),
|
||||
Placeholder_113(165),
|
||||
Placeholder_114(166),
|
||||
Placeholder_115(167),
|
||||
Placeholder_116(168),
|
||||
Placeholder_117(169),
|
||||
Placeholder_118(170),
|
||||
Placeholder_119(171),
|
||||
Placeholder_120(172),
|
||||
Placeholder_121(173),
|
||||
Placeholder_122(174),
|
||||
Placeholder_123(175),
|
||||
Placeholder_124(176),
|
||||
Placeholder_125(177),
|
||||
Placeholder_126(178),
|
||||
Placeholder_127(179),
|
||||
Placeholder_128(180),
|
||||
Placeholder_129(181),
|
||||
Placeholder_130(182),
|
||||
Placeholder_131(183),
|
||||
Placeholder_132(184),
|
||||
Placeholder_133(185),
|
||||
Placeholder_134(186),
|
||||
Placeholder_135(187),
|
||||
Placeholder_136(188),
|
||||
Placeholder_137(189),
|
||||
Placeholder_138(190),
|
||||
Placeholder_139(191),
|
||||
Placeholder_140(192),
|
||||
Placeholder_141(193),
|
||||
Placeholder_142(194),
|
||||
Placeholder_143(195),
|
||||
Placeholder_144(196),
|
||||
Placeholder_145(197),
|
||||
Placeholder_146(198),
|
||||
Placeholder_147(199),
|
||||
Placeholder_148(200),
|
||||
Placeholder_149(201),
|
||||
Placeholder_150(202),
|
||||
Placeholder_151(203),
|
||||
Placeholder_152(204),
|
||||
Placeholder_153(205),
|
||||
Placeholder_154(206),
|
||||
Placeholder_155(207),
|
||||
Placeholder_156(208),
|
||||
Placeholder_157(209),
|
||||
Placeholder_158(210),
|
||||
Placeholder_159(211),
|
||||
Placeholder_160(212),
|
||||
Placeholder_161(213),
|
||||
Placeholder_162(214),
|
||||
Placeholder_163(215),
|
||||
Placeholder_164(216),
|
||||
Placeholder_165(217),
|
||||
Placeholder_166(218),
|
||||
Placeholder_167(219),
|
||||
Placeholder_168(220),
|
||||
Placeholder_169(221),
|
||||
Placeholder_170(222),
|
||||
Placeholder_171(223),
|
||||
Placeholder_172(224),
|
||||
Placeholder_173(225),
|
||||
Placeholder_174(226),
|
||||
Placeholder_175(227),
|
||||
Placeholder_176(228),
|
||||
Placeholder_177(229),
|
||||
Placeholder_178(230),
|
||||
Placeholder_179(231),
|
||||
Placeholder_180(232),
|
||||
Placeholder_181(233),
|
||||
Placeholder_182(234),
|
||||
Placeholder_183(235),
|
||||
Placeholder_184(236),
|
||||
Placeholder_185(237),
|
||||
Placeholder_186(238),
|
||||
Placeholder_187(239),
|
||||
Placeholder_188(240),
|
||||
Placeholder_189(241),
|
||||
Placeholder_190(242),
|
||||
Placeholder_191(243),
|
||||
Placeholder_192(244),
|
||||
Placeholder_193(245),
|
||||
Placeholder_194(246),
|
||||
Placeholder_195(247),
|
||||
Placeholder_196(248),
|
||||
Placeholder_197(249),
|
||||
Placeholder_198(250),
|
||||
Placeholder_199(251),
|
||||
Placeholder_200(252),
|
||||
Placeholder_201(253),
|
||||
Placeholder_202(254),
|
||||
Placeholder_203(255),
|
||||
Placeholder_204(256),
|
||||
Placeholder_205(257),
|
||||
Placeholder_206(258),
|
||||
Placeholder_207(259),
|
||||
Placeholder_208(260),
|
||||
Placeholder_209(261),
|
||||
Placeholder_210(262),
|
||||
Placeholder_211(263),
|
||||
Placeholder_212(264),
|
||||
Placeholder_213(265),
|
||||
Placeholder_214(266),
|
||||
Placeholder_215(267),
|
||||
Placeholder_216(268),
|
||||
Placeholder_217(269),
|
||||
Placeholder_218(270),
|
||||
Placeholder_219(271),
|
||||
Placeholder_220(272),
|
||||
Placeholder_221(273),
|
||||
Placeholder_222(274),
|
||||
Placeholder_223(275),
|
||||
Placeholder_224(276),
|
||||
Placeholder_225(277),
|
||||
Placeholder_226(278),
|
||||
Placeholder_227(279),
|
||||
Placeholder_228(280),
|
||||
Placeholder_229(281),
|
||||
Placeholder_230(282),
|
||||
Placeholder_231(283),
|
||||
Placeholder_232(284),
|
||||
Placeholder_233(285),
|
||||
Placeholder_234(286),
|
||||
Placeholder_235(287),
|
||||
Placeholder_236(288),
|
||||
Placeholder_237(289),
|
||||
Placeholder_238(290),
|
||||
Placeholder_239(291),
|
||||
Placeholder_240(292),
|
||||
Placeholder_241(293),
|
||||
Placeholder_242(294),
|
||||
Placeholder_243(295),
|
||||
Placeholder_244(296),
|
||||
Placeholder_245(297),
|
||||
Placeholder_246(298),
|
||||
Placeholder_247(299),
|
||||
Placeholder_248(300),
|
||||
Placeholder_249(301),
|
||||
Placeholder_250(302),
|
||||
Placeholder_251(303),
|
||||
Placeholder_252(304),
|
||||
Placeholder_253(305),
|
||||
Placeholder_254(306),
|
||||
Placeholder_255(307),
|
||||
Placeholder_256(308),
|
||||
Placeholder_257(309),
|
||||
Placeholder_258(310),
|
||||
Placeholder_259(311),
|
||||
Placeholder_260(312),
|
||||
Placeholder_261(313),
|
||||
Placeholder_262(314),
|
||||
Placeholder_263(315),
|
||||
Placeholder_264(316),
|
||||
Placeholder_265(317),
|
||||
Placeholder_266(318),
|
||||
Placeholder_267(319),
|
||||
Placeholder_268(320),
|
||||
Placeholder_269(321),
|
||||
Placeholder_270(322),
|
||||
Placeholder_271(323),
|
||||
Placeholder_272(324),
|
||||
Placeholder_273(325),
|
||||
Placeholder_274(326),
|
||||
Placeholder_275(327),
|
||||
Placeholder_276(328),
|
||||
Placeholder_277(329),
|
||||
Placeholder_278(330),
|
||||
Placeholder_279(331),
|
||||
Placeholder_280(332),
|
||||
Placeholder_281(333),
|
||||
Placeholder_282(334),
|
||||
Placeholder_283(335),
|
||||
Placeholder_284(336),
|
||||
Placeholder_285(337),
|
||||
Placeholder_286(338),
|
||||
Placeholder_287(339),
|
||||
Placeholder_288(340),
|
||||
Placeholder_289(341),
|
||||
Placeholder_290(342),
|
||||
Placeholder_291(343),
|
||||
Placeholder_292(344),
|
||||
Placeholder_293(345),
|
||||
Placeholder_294(346),
|
||||
Placeholder_295(347),
|
||||
Placeholder_296(348),
|
||||
Placeholder_297(349),
|
||||
Placeholder_298(350),
|
||||
Placeholder_299(351),
|
||||
ClientError(5000),
|
||||
ClientGooglePlayRequestServerAuthCodeFailure(5001),
|
||||
ClientiOSGameCenterLoginCancelled(5002),
|
||||
ClientiOSGameCenterUnknownError(5003),
|
||||
ClientiOSGameCenterAuthFailure(5004),
|
||||
ClientiOSGameCenterIdentityFailure(5005),
|
||||
ClientiOSGameCenterPluginInternalError(5006),
|
||||
ClientiOSGameCenterInvalidIdentityData(5007),
|
||||
ClientHttpErrorUnknown(5008),
|
||||
ClientHttpErrorBadRequest(5009),
|
||||
ClientHttpErrorUnauthorized(5010),
|
||||
ClientHttpErrorPaymentRequired(5011),
|
||||
ClientHttpErrorForbidden(5012),
|
||||
ClientHttpErrorNotFound(5013),
|
||||
ClientHttpErrorMethodNotAllowed(5014),
|
||||
ClientHttpErrorNotAcceptable(5015),
|
||||
ClientHttpErrorProxyAuthenticationRequired(5016),
|
||||
ClientHttpErrorRequestTimeout(5017),
|
||||
ClientHttpErrorConflict(5018),
|
||||
ClientHttpErrorGone(5019),
|
||||
ClientHttpErrorLengthRequired(5020),
|
||||
ClientHttpErrorPreconditionFailed(5021),
|
||||
ClientHttpErrorPayloadTooLarge(5022),
|
||||
ClientHttpErrorUriTooLong(5023),
|
||||
ClientHttpErrorUnsupportedMediaType(5024),
|
||||
ClientHttpErrorRangeNotSatisfiable(5025),
|
||||
ClientHttpErrorExpectationFailed(5026),
|
||||
ClientHttpErrorIMATeapot(5027),
|
||||
ClientHttpErrorMisdirectedRequest(5028),
|
||||
ClientHttpErrorUnprocessableEntity(5029),
|
||||
ClientHttpErrorLocked(5030),
|
||||
ClientHttpErrorFailedDependency(5031),
|
||||
ClientHttpErrorUpgradeRequired(5032),
|
||||
ClientHttpErrorPreconditionRequired(5033),
|
||||
ClientHttpErrorTooManyRequests(5034),
|
||||
ClientHttpErrorRequestHeaderFieldsTooLarge(5035),
|
||||
ClientHttpErrorUnavailableForLegalReasons(5036),
|
||||
ClientHttpErrorExceptionDecodingResponse(5037),
|
||||
ClientSteamLinkedToAnotherAccount(5038),
|
||||
ClientiOSLinkedToAnotherAccount(5039),
|
||||
ClientAndroidLinkedToAnotherAccount(5040),
|
||||
ClientLoginCancelled(5041),
|
||||
ClientBadAuthToken(5042),
|
||||
ClientNotSupportedInBNETLauncher(5043),
|
||||
ClientGetEulaUnknownError(5044),
|
||||
ClientUserRejectedDocError(5045),
|
||||
ClientDigitalRiverRedirectException(5046);
|
||||
|
||||
private final int code;
|
||||
|
||||
ResultCode(final int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int code() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package ch.gtache.elderscrollslegends.service.account;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
|
||||
import ch.gtache.elderscrollslegends.service.BaseResult;
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
import ch.gtache.elderscrollslegends.service.SteamService;
|
||||
import ch.gtache.elderscrollslegends.service.account.auth.AuthBNETGamecodeRequest;
|
||||
import ch.gtache.elderscrollslegends.service.account.auth.AuthBNETSteamRequest;
|
||||
@@ -49,24 +51,26 @@ public class AccountEndpoints extends BaseEndpoints {
|
||||
if (steamService.authenticate(request.sessionTicket(), request.steamId())) {
|
||||
logger.info("SteamLogin succeeded for " + request);
|
||||
final var data = accountService().authenticate(request.steamId());
|
||||
return new AuthResult(data, 0, null, List.of());
|
||||
return new AuthResult(ResultCode.Ok, "", data, 0, null, List.of());
|
||||
} else {
|
||||
return new AuthResult(null, 2, "SteamLogin failed", List.of());
|
||||
return new AuthResult(ResultCode.SteamAuthFailed, "", null, 2, "SteamLogin failed", List.of());
|
||||
}
|
||||
} catch (final SteamException e) {
|
||||
logger.error("SteamLogin failed for " + request, e);
|
||||
return new AuthResult(null, 1, "SteamLogin failed", List.of());
|
||||
return new AuthResult(ResultCode.SteamAuthFailed, "", null, 1, "SteamLogin failed", List.of());
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("bnetSteamLogout")
|
||||
@Consumes("application/json")
|
||||
public void steamLogout(@HeaderParam("Authorization") final String authentication) {
|
||||
@Produces("application/json")
|
||||
public BaseResult steamLogout(@HeaderParam("Authorization") final String authentication) {
|
||||
logger.info("SteamLogout called");
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("SteamLogout called by " + steamID);
|
||||
steamService.endAuthSession(steamID);
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -75,7 +79,7 @@ public class AccountEndpoints extends BaseEndpoints {
|
||||
@Produces("application/json")
|
||||
public AuthResult gamecodeLogin(final AuthBNETGamecodeRequest request) {
|
||||
logger.info("GamecodeLogin called : " + request);
|
||||
return new AuthResult(null, 1, "GamecodeLogin not implemented", List.of());
|
||||
return new AuthResult(ResultCode.BNETAuthFailed, "", null, 1, "GamecodeLogin not implemented", List.of());
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -85,9 +89,9 @@ public class AccountEndpoints extends BaseEndpoints {
|
||||
public CheckUsernameResponse checkUsername(final CheckUsernameRequest request) {
|
||||
logger.info("CheckUsername called : " + request);
|
||||
if (accountService().exists(request.username())) {
|
||||
return new CheckUsernameResponse(new CheckUsernameResponseBody(true, true, 0));
|
||||
return new CheckUsernameResponse(ResultCode.Ok, "", new CheckUsernameResponseBody(true, true, 0));
|
||||
} else {
|
||||
return new CheckUsernameResponse(new CheckUsernameResponseBody(false, false, 1));
|
||||
return new CheckUsernameResponse(ResultCode.BNETAuthFailed, "", new CheckUsernameResponseBody(false, false, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,9 +102,9 @@ public class AccountEndpoints extends BaseEndpoints {
|
||||
public CheckEmailResponse checkEmail(final CheckEmailRequest request) {
|
||||
logger.info("CheckEmail called : " + request);
|
||||
if (accountService().exists(request.email())) {
|
||||
return new CheckEmailResponse(new CheckEmailResponseBody(true, 0));
|
||||
return new CheckEmailResponse(ResultCode.Ok, "", new CheckEmailResponseBody(true, 0));
|
||||
} else {
|
||||
return new CheckEmailResponse(new CheckEmailResponseBody(false, 1));
|
||||
return new CheckEmailResponse(ResultCode.BNETAuthFailed, "", new CheckEmailResponseBody(false, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,12 +114,12 @@ public class AccountEndpoints extends BaseEndpoints {
|
||||
@Produces("application/json")
|
||||
public RefreshSessionResponse refreshSession(@HeaderParam("Authorization") final String authentication,
|
||||
final RefreshSessionRequest request) {
|
||||
logger.info("RefreshSession called : " + request);
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("RefreshSession called by " + steamID + " : " + request);
|
||||
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(ResultCode.Ok, "", (int) timeToRefresh, token.token());
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -124,18 +128,20 @@ public class AccountEndpoints extends BaseEndpoints {
|
||||
@Produces("application/json")
|
||||
public LegalDocumentsResponse getLegalDocumentsForUser(@HeaderParam("Authorization") final String authentication,
|
||||
final GetLegalDocumentsForUserRequest request) {
|
||||
logger.info("GetLegalDocumentsForUser called : " + request);
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
return new LegalDocumentsResponse(List.of());
|
||||
logger.info("GetLegalDocumentsForUser called by " + steamID + " : " + request);
|
||||
return new LegalDocumentsResponse(ResultCode.Ok, "", List.of());
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("bnetAcceptLegalDocument")
|
||||
@Consumes("application/json")
|
||||
public void acceptLegalDocument(@HeaderParam("Authorization") final String authentication,
|
||||
final AcceptLegalDocumentRequest request) {
|
||||
logger.info("acceptLegalDocument called : " + request);
|
||||
authenticateOrThrow(authentication);
|
||||
@Produces("application/json")
|
||||
public BaseResult acceptLegalDocument(@HeaderParam("Authorization") final String authentication,
|
||||
final AcceptLegalDocumentRequest request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("acceptLegalDocument called by " + steamID + " : " + request);
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -144,6 +150,6 @@ public class AccountEndpoints extends BaseEndpoints {
|
||||
@Produces("application/json")
|
||||
public LegalDocumentsResponse getAllLegalDocuments(final GetAllLegalDocumentsRequest request) {
|
||||
logger.info("GetAllLegalDocuments called : " + request);
|
||||
return new LegalDocumentsResponse(List.of());
|
||||
return new LegalDocumentsResponse(ResultCode.Ok, "", List.of());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,23 @@ public class AccountService extends BaseService {
|
||||
final var longId = Long.parseLong(steamID);
|
||||
final var name = steamService.getName(steamID);
|
||||
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 (?, ?) RETURNING id")) {
|
||||
statement.setLong(1, longId);
|
||||
statement.setString(2, name);
|
||||
statement.executeUpdate();
|
||||
try (final var rs = statement.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
final var playerId = rs.getLong(1);
|
||||
try (final var profileStatement = connection.prepareStatement("INSERT INTO profile (player_id, name) VALUES (?, ?)")) {
|
||||
profileStatement.setLong(1, playerId);
|
||||
profileStatement.setString(2, name);
|
||||
profileStatement.executeUpdate();
|
||||
}
|
||||
try (final var onboardingStatement = connection.prepareStatement("INSERT INTO onboarding (player_id) VALUES (?)")) {
|
||||
onboardingStatement.setLong(1, playerId);
|
||||
onboardingStatement.executeUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
logger.error("Error inserting player " + steamID, e);
|
||||
return null;
|
||||
@@ -53,7 +66,7 @@ public class AccountService extends BaseService {
|
||||
final var longId = Long.parseLong(steamID);
|
||||
final var name = steamService.getName(steamID);
|
||||
try (final var connection = dataSource().getConnection();
|
||||
final var statement = connection.prepareStatement("UPDATE player SET name=? WHERE steam_id=?")) {
|
||||
final var statement = connection.prepareStatement("UPDATE profile SET name=? WHERE player_id=(SELECT id FROM player WHERE steam_id=?)")) {
|
||||
statement.setString(1, name);
|
||||
statement.setLong(2, longId);
|
||||
statement.executeUpdate();
|
||||
@@ -66,7 +79,7 @@ public class AccountService extends BaseService {
|
||||
if (token != null) {
|
||||
final var longId = Long.parseLong(steamID);
|
||||
try (final var connection = dataSource().getConnection();
|
||||
final var statement = connection.prepareStatement("SELECT name FROM player WHERE steam_id=?")) {
|
||||
final var statement = connection.prepareStatement("SELECT name FROM profile WHERE player_id=(SELECT id FROM player WHERE steam_id=?)")) {
|
||||
statement.setLong(1, longId);
|
||||
try (final var rs = statement.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
|
||||
@@ -12,22 +12,22 @@ 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 Duration timeToLive;
|
||||
private final JWTVerifier verifier;
|
||||
|
||||
@Inject
|
||||
JWTService(@ConfigProperty(name = "jwt.hs256.key.secret") final String key, final Duration timeToLive) {
|
||||
this.timeToLive = Objects.requireNonNull(timeToLive);
|
||||
JWTService(@ConfigProperty(name = "jwt.hs256.key.secret") final String key,
|
||||
@ConfigProperty(name = "jwt.token.ttl.seconds") final int ttlSeconds) {
|
||||
this.algorithm = Algorithm.HMAC256(key);
|
||||
this.timeToLive = Duration.ofSeconds(ttlSeconds);
|
||||
this.verifier = JWT.require(algorithm).withIssuer(ISSUER).build();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.account;
|
||||
|
||||
public record RefreshSessionResponse(int timeToRefresh, String sessionToken) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record RefreshSessionResponse(ResultCode resultCode, String endpoint,
|
||||
int timeToRefresh, String sessionToken) {
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package ch.gtache.elderscrollslegends.service.account.auth;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record AuthResult(AuthData data, int errorCode, String errorMessage, List<String> validChangelists) {
|
||||
public record AuthResult(ResultCode resultCode, String endpoint,
|
||||
AuthData data, int errorCode, String errorMessage, List<String> validChangelists) {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.account.check;
|
||||
|
||||
public record CheckEmailResponse(CheckEmailResponseBody body) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record CheckEmailResponse(ResultCode resultCode, String endpoint,
|
||||
CheckEmailResponseBody body) {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.account.check;
|
||||
|
||||
public record CheckUsernameResponse(CheckUsernameResponseBody body) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record CheckUsernameResponse(ResultCode resultCode, String endpoint,
|
||||
CheckUsernameResponseBody body) {
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package ch.gtache.elderscrollslegends.service.account.transfer;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record LegalDocumentsResponse(List<LegalDocEntry> items) {
|
||||
public record LegalDocumentsResponse(ResultCode resultCode, String endpoint,
|
||||
List<LegalDocEntry> items) {
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package ch.gtache.elderscrollslegends.service.account.transfer;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
import ch.gtache.elderscrollslegends.service.inventory.InventorySelectedItem;
|
||||
import ch.gtache.elderscrollslegends.service.profile.ProfileStruct;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
record TransferResponse_Phase0(List<LegalDocEntry> items, String buid, String sessionToken, boolean hasTeslUserData,
|
||||
record TransferResponse_Phase0(ResultCode resultCode, String endpoint,
|
||||
List<LegalDocEntry> items, String buid, String sessionToken, boolean hasTeslUserData,
|
||||
ProfileStruct profile, List<InventorySelectedItem> categories) {
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package ch.gtache.elderscrollslegends.service.account.transfer;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
import ch.gtache.elderscrollslegends.service.account.auth.AuthData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
record TransferResponse_Phase1(AuthData data, int errorCode, String errorMessage, List<String> validChangelists) {
|
||||
record TransferResponse_Phase1(ResultCode resultCode, String endpoint,
|
||||
AuthData data, int errorCode, String errorMessage, List<String> validChangelists) {
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package ch.gtache.elderscrollslegends.service.analytics;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
import ch.gtache.elderscrollslegends.service.account.AccountService;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.HeaderParam;
|
||||
import jakarta.ws.rs.POST;
|
||||
@@ -26,18 +28,24 @@ public class AnalyticsEndpoints extends BaseEndpoints {
|
||||
|
||||
@POST
|
||||
@Path("/clientEvent")
|
||||
public void newAnalytics(@HeaderParam("Authorization") final String authentication,
|
||||
final AnalyticsEvent analyticsEvent) {
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public AnalyticsEventResult newAnalytics(@HeaderParam("Authorization") final String authentication,
|
||||
final AnalyticsEvent analyticsEvent) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("Report analytics called by " + steamID + " : " + analyticsEvent);
|
||||
analyticsService.newAnalytics(steamID, analyticsEvent);
|
||||
return new AnalyticsEventResult(ResultCode.Ok, "", false);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/clientEventPA")
|
||||
public void newAnalyticsPA(final AnalyticsEvent analyticsEvent) {
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public AnalyticsEventResult newAnalyticsPA(final AnalyticsEvent analyticsEvent) {
|
||||
logger.info("Report analyticsPA called : " + analyticsEvent);
|
||||
analyticsService.newAnalytics(analyticsEvent);
|
||||
return new AnalyticsEventResult(ResultCode.Ok, "", false);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -46,6 +54,6 @@ public class AnalyticsEndpoints extends BaseEndpoints {
|
||||
public AnalyticsFetchResponse getReportingConfig(@HeaderParam("Authorization") final String authentication) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("ReportingConfig called by " + steamID);
|
||||
return new AnalyticsFetchResponse(true);
|
||||
return new AnalyticsFetchResponse(ResultCode.Ok, "", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.analytics;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record AnalyticsEventResult(ResultCode resultCode, String endpoint,
|
||||
boolean disable) {
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.analytics;
|
||||
|
||||
public record AnalyticsFetchResponse(boolean enableReporting) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record AnalyticsFetchResponse(ResultCode resultCode, String endpoint,
|
||||
boolean enableReporting) {
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package ch.gtache.elderscrollslegends.service.arena;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
|
||||
import ch.gtache.elderscrollslegends.service.BaseResult;
|
||||
import ch.gtache.elderscrollslegends.service.CardService;
|
||||
import ch.gtache.elderscrollslegends.service.ClassService;
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
import ch.gtache.elderscrollslegends.service.account.AccountService;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
@@ -42,19 +44,19 @@ public class ArenaEndpoints extends BaseEndpoints {
|
||||
logger.info("purchaseArena called by " + steamID + " : " + request);
|
||||
arenaService.purchaseArena(steamID, request.arenaType(), request.currencyType());
|
||||
final var data = arenaService.getArenaClientData(steamID);
|
||||
return new FetchArenaInstancesResult(data);
|
||||
return new FetchArenaInstancesResult(ResultCode.Ok, "", data);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("resignArena")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public ResignArenaResult resignArena(@HeaderParam("Authorization") final String authentication,
|
||||
final ResignArenaRequest request) {
|
||||
public BaseResult resignArena(@HeaderParam("Authorization") final String authentication,
|
||||
final ResignArenaRequest request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("resignArena called by " + steamID + " : " + request);
|
||||
arenaService.resignArena(steamID, request.arenaType());
|
||||
return new ResignArenaResult();
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -67,7 +69,7 @@ public class ArenaEndpoints extends BaseEndpoints {
|
||||
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));
|
||||
return new SelectCardResult(ResultCode.Ok, "", arenaService.getArenaClientData(steamID));
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -80,7 +82,7 @@ public class ArenaEndpoints extends BaseEndpoints {
|
||||
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));
|
||||
return new SelectClassResult(ResultCode.Ok, "", arenaService.getArenaClientData(steamID));
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -90,6 +92,6 @@ public class ArenaEndpoints extends BaseEndpoints {
|
||||
public FetchArenaInstancesResult fetchActiveArenaInstances(@HeaderParam("Authorization") final String authentication) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("fetchActiveArenaInstances called by " + steamID);
|
||||
return new FetchArenaInstancesResult(arenaService.getArenaClientData(steamID));
|
||||
return new FetchArenaInstancesResult(ResultCode.Ok, "", arenaService.getArenaClientData(steamID));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,14 +17,14 @@ class ArenaService extends BaseService {
|
||||
super(dataSource);
|
||||
}
|
||||
|
||||
public void purchaseArena(final String steamID, final ArenaType arenaType,
|
||||
final ArenaPurchaseCurrencyType currencyType) {
|
||||
void purchaseArena(final String steamID, final ArenaType arenaType,
|
||||
final ArenaPurchaseCurrencyType currencyType) {
|
||||
}
|
||||
|
||||
public void resignArena(final String steamID, final ArenaType arenaType) {
|
||||
void resignArena(final String steamID, final ArenaType arenaType) {
|
||||
}
|
||||
|
||||
public ArenaClientDataStruct getArenaClientData(final String steamID) {
|
||||
ArenaClientDataStruct getArenaClientData(final String steamID) {
|
||||
return new ArenaClientDataStruct(0, 0, List.of());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.arena;
|
||||
|
||||
public record FetchArenaInstancesResult(ArenaClientDataStruct clientData) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record FetchArenaInstancesResult(ResultCode resultCode, String endpoint,
|
||||
ArenaClientDataStruct clientData) {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.arena;
|
||||
|
||||
public record PurchaseArenaRequest(ArenaType arenaType, ArenaPurchaseCurrencyType currencyType) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record PurchaseArenaRequest(ResultCode resultCode, String endpoint,
|
||||
ArenaType arenaType, ArenaPurchaseCurrencyType currencyType) {
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
package ch.gtache.elderscrollslegends.service.arena;
|
||||
|
||||
public record ResignArenaResult() {
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.arena;
|
||||
|
||||
public record SelectCardResult(ArenaClientDataStruct clientData) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record SelectCardResult(ResultCode resultCode, String endpoint,
|
||||
ArenaClientDataStruct clientData) {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.arena;
|
||||
|
||||
public record SelectClassResult(ArenaClientDataStruct clientData) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record SelectClassResult(ResultCode resultCode, String endpoint,
|
||||
ArenaClientDataStruct clientData) {
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package ch.gtache.elderscrollslegends.service.campaign;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
|
||||
import ch.gtache.elderscrollslegends.service.BaseResult;
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
import ch.gtache.elderscrollslegends.service.account.AccountService;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
@@ -13,7 +15,7 @@ import org.jboss.logging.Logger;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Path("/campaign")
|
||||
@Path("/campaigns")
|
||||
public class CampaignEndpoints extends BaseEndpoints {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(CampaignEndpoints.class);
|
||||
@@ -28,31 +30,35 @@ public class CampaignEndpoints extends BaseEndpoints {
|
||||
@POST
|
||||
@Path("checkCampaignProgress")
|
||||
@Consumes("application/json")
|
||||
public void checkCampaignProgress(@HeaderParam("Authorization") final String authentication,
|
||||
final CheckCampaignRequest request) {
|
||||
@Produces("application/json")
|
||||
public BaseResult checkCampaignProgress(@HeaderParam("Authorization") final String authentication,
|
||||
final CheckCampaignRequest request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("CheckCampaignProgress called by " + steamID + " : " + request);
|
||||
campaignService.getCampaign(steamID, request.campaignId(), request.isMastery());
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("debugAddNextChapter")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public void debugAddNextChapter(@HeaderParam("Authorization") final String authentication,
|
||||
final DebugAddNextChapterRequest request) {
|
||||
public BaseResult debugAddNextChapter(@HeaderParam("Authorization") final String authentication,
|
||||
final DebugAddNextChapterRequest request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("DebugAddNextChapter called by " + steamID + " : " + request);
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("debugAddNextEvent")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public void debugAddNextEvent(@HeaderParam("Authorization") final String authentication,
|
||||
final DebugAddNextEventRequest request) {
|
||||
public BaseResult debugAddNextEvent(@HeaderParam("Authorization") final String authentication,
|
||||
final DebugAddNextEventRequest request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("DebugAddNextEvent called by " + steamID + " : " + request);
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -63,7 +69,7 @@ public class CampaignEndpoints extends BaseEndpoints {
|
||||
final SetChapterDialogStatusRequest request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("SetChapterDialogStatus called by " + steamID + " : " + request);
|
||||
return new SetChapterDialogResult(campaignService.getRewards(steamID, request));
|
||||
return new SetChapterDialogResult(ResultCode.Ok, "", campaignService.getRewards(steamID, request));
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -74,15 +80,15 @@ public class CampaignEndpoints extends BaseEndpoints {
|
||||
final SetChapterEventChoiceRequest request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("SetChapterEventChoice called by " + steamID + " : " + request);
|
||||
return new SetChapterEventResult(campaignService.getRewards(steamID, request));
|
||||
return new SetChapterEventResult(ResultCode.Ok, "", campaignService.getRewards(steamID, request));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("list")
|
||||
@Produces("application/json")
|
||||
public ListCampaignsResponse getList(@HeaderParam("Authorization") final String authentication) {
|
||||
public ListCampaignsResponse list(@HeaderParam("Authorization") final String authentication) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("List called by " + steamID);
|
||||
return new ListCampaignsResponse(campaignService.getCampaigns(steamID));
|
||||
return new ListCampaignsResponse(ResultCode.Ok, "", campaignService.getCampaigns(steamID));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package ch.gtache.elderscrollslegends.service.campaign;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record ListCampaignsResponse(List<UserCampaignData> campaignDatas) {
|
||||
public record ListCampaignsResponse(ResultCode resultCode, String endpoint,
|
||||
List<UserCampaignData> campaignDatas) {
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package ch.gtache.elderscrollslegends.service.campaign;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
import ch.gtache.elderscrollslegends.service.reward.RewardDescription;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record SetChapterDialogResult(List<RewardDescription> rewards) {
|
||||
public record SetChapterDialogResult(ResultCode resultCode, String endpoint,
|
||||
List<RewardDescription> rewards) {
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package ch.gtache.elderscrollslegends.service.campaign;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
import ch.gtache.elderscrollslegends.service.reward.RewardDescription;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record SetChapterEventResult(List<RewardDescription> rewards) {
|
||||
public record SetChapterEventResult(ResultCode resultCode, String endpoint,
|
||||
List<RewardDescription> rewards) {
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package ch.gtache.elderscrollslegends.service.chat;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
|
||||
import ch.gtache.elderscrollslegends.service.BaseResult;
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
import ch.gtache.elderscrollslegends.service.account.AccountService;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
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;
|
||||
@@ -26,10 +29,12 @@ public class ChatEndpoints extends BaseEndpoints {
|
||||
@POST
|
||||
@Path("sendChatMessage")
|
||||
@Consumes("application/json")
|
||||
public void sendChatMessage(@HeaderParam("Authorization") final String authentication,
|
||||
final OutgoingMessage message) {
|
||||
@Produces("application/json")
|
||||
public BaseResult sendChatMessage(@HeaderParam("Authorization") final String authentication,
|
||||
final OutgoingMessage message) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("SendChatMessage called by " + steamID + " : " + message);
|
||||
chatService.sendMessage(steamID, message.toBuid(), message.message());
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package ch.gtache.elderscrollslegends.service.crafting;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
|
||||
import ch.gtache.elderscrollslegends.service.CardService;
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
import ch.gtache.elderscrollslegends.service.account.AccountService;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
@@ -38,7 +39,7 @@ public class CraftingEndpoints extends BaseEndpoints {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("SoulTrapExtras called by " + steamID + " : " + request);
|
||||
final var soulTrapped = craftingService.soulTrap(steamID, request.priority());
|
||||
return new SoulTrapExtrasResponse(soulTrapped);
|
||||
return new SoulTrapExtrasResponse(ResultCode.Ok, "", soulTrapped);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -51,7 +52,7 @@ public class CraftingEndpoints extends BaseEndpoints {
|
||||
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(),
|
||||
return new CraftingResponse(ResultCode.Ok, "", card.id(), result.totalGems(), result.regularRemaining(),
|
||||
result.premiumRemaining(), false);
|
||||
}
|
||||
|
||||
@@ -65,7 +66,7 @@ public class CraftingEndpoints extends BaseEndpoints {
|
||||
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(),
|
||||
return new CraftingResponse(ResultCode.Ok, "", card.id(), result.totalGems(), result.regularRemaining(),
|
||||
result.premiumRemaining(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.crafting;
|
||||
|
||||
public record CraftingResponse(int cardTypeHash, int gems, int numRegular, int numPremium, boolean ghostedChange) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record CraftingResponse(ResultCode resultCode, String endpoint,
|
||||
int cardTypeHash, int gems, int numRegular, int numPremium, boolean ghostedChange) {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.crafting;
|
||||
|
||||
public record SoulTrapExtrasResponse(int numGems) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record SoulTrapExtrasResponse(ResultCode resultCode, String endpoint,
|
||||
int numGems) {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.dailyreward;
|
||||
|
||||
public record AcceptDailyRewardResponse(AcceptDailyRewardResult result) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record AcceptDailyRewardResponse(ResultCode resultCode, String endpoint,
|
||||
AcceptDailyRewardResult result) {
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.dailyreward;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
import ch.gtache.elderscrollslegends.service.account.AccountService;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.GET;
|
||||
@@ -32,7 +33,7 @@ public class DailyRewardsEndpoints extends BaseEndpoints {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("List called by " + steamID);
|
||||
final var rewards = dailyRewardsService.listRewards(steamID);
|
||||
return new ListDailyRewardsResponse(rewards);
|
||||
return new ListDailyRewardsResponse(ResultCode.Ok, "", rewards);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -42,6 +43,6 @@ public class DailyRewardsEndpoints extends BaseEndpoints {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("AcceptReward called by " + steamID);
|
||||
final var result = dailyRewardsService.acceptReward(steamID);
|
||||
return new AcceptDailyRewardResponse(result);
|
||||
return new AcceptDailyRewardResponse(ResultCode.Ok, "", result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package ch.gtache.elderscrollslegends.service.dailyreward;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record ListDailyRewardsResponse(List<DailyRewardDescription> rewards) {
|
||||
public record ListDailyRewardsResponse(ResultCode resultCode, String endpoint,
|
||||
List<DailyRewardDescription> rewards) {
|
||||
}
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
package ch.gtache.elderscrollslegends.service.error;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
|
||||
import ch.gtache.elderscrollslegends.service.BaseResult;
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
import ch.gtache.elderscrollslegends.service.account.AccountService;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
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("/errorreporting")
|
||||
public class ErrorEndpoints extends BaseEndpoints {
|
||||
@@ -19,21 +25,27 @@ public class ErrorEndpoints extends BaseEndpoints {
|
||||
@Inject
|
||||
ErrorEndpoints(final AccountService accountService, final ErrorService errorService) {
|
||||
super(accountService);
|
||||
this.errorService = errorService;
|
||||
this.errorService = Objects.requireNonNull(errorService);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("reportError")
|
||||
public void reportError(@HeaderParam("Authorization") final String authentication,
|
||||
final ErrorReport errorReport) {
|
||||
logger.info("Report error called by " + authentication + " : " + errorReport);
|
||||
errorService.reportError(errorReport.report());
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public BaseResult reportError(@HeaderParam("Authorization") final String authentication,
|
||||
final ErrorReport errorReport) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("Report error called by " + steamID + " : " + errorReport);
|
||||
errorService.reportError(steamID, errorReport.report());
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("reportingConfig")
|
||||
@Produces("application/json")
|
||||
public FetchResponse getReportingConfig(@HeaderParam("Authorization") final String authentication) {
|
||||
logger.info("ReportingConfig called by " + authentication);
|
||||
return new FetchResponse(true);
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("ReportingConfig called by " + steamID);
|
||||
return new FetchResponse(ResultCode.Ok, "", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class ErrorService extends BaseService {
|
||||
super(dataSource);
|
||||
}
|
||||
|
||||
void reportError(final String report) {
|
||||
|
||||
void reportError(final String steamID, final String report) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.error;
|
||||
|
||||
public record FetchResponse(boolean enableReporting) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record FetchResponse(ResultCode resultCode, String endpoint,
|
||||
boolean enableReporting) {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
package ch.gtache.elderscrollslegends.service.events;
|
||||
|
||||
public record ContentEntry() {
|
||||
public record ContentEntry(ContentEntryType ContentType, ContentEntryModifier ContentTypeModifier,
|
||||
int CardTypeHash, String genericInventoryCategory, String genericInventoryItemKey,
|
||||
int Count) {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.events;
|
||||
|
||||
public enum ContentEntryModifier {
|
||||
Regular,
|
||||
Premium,
|
||||
Legendary,
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package ch.gtache.elderscrollslegends.service.events;
|
||||
|
||||
public enum ContentEntryType {
|
||||
deck_guildsworn_premade(-2130065822),
|
||||
Story_clockwork_act_1(-2081695333),
|
||||
cardpack_premium_legendary_skyrim(-2055625898),
|
||||
Story_iom_act_3(-1930544045),
|
||||
cardpack_premium_legendary_core(-1725187377),
|
||||
Deck_paarthurnaxs_roar(-1559585206),
|
||||
deck_warriorsofhammerfell(-1540481132),
|
||||
deck_zumog_phooms_ambition(-1512805701),
|
||||
deck_daggerfall_premade(-1482543116),
|
||||
Collection_forgotten_hero(-1234927939),
|
||||
CardPack_Oblivion(-1189332835),
|
||||
CardPack_Alliance_War(-1134307988),
|
||||
Deck_alduins_apocalypse(-1099276554),
|
||||
cardpack_legendary_alliancewar(-1079248420),
|
||||
CardPack_Dark_Brotherhood(-1060524721),
|
||||
deck_aldmeri_premade(-1020546251),
|
||||
event_tickets(-932913302),
|
||||
deck_convenant_armaments(-895245686),
|
||||
cardpack_legendary_core(-833271125),
|
||||
CardPack_Core(-780195762),
|
||||
Story_iom_act_2(-701526946),
|
||||
CardPack_Elsweyr(-628554270),
|
||||
Deck_redoran_onslaught(-459319658),
|
||||
Deck_brynjolfs_heist(-441621356),
|
||||
Deck_dagoths_might(-393841299),
|
||||
Deck_hlaalu_schemes(-350943676),
|
||||
Deck_telvanni_ambition(-260716247),
|
||||
Collection_mad_prince(-214913246),
|
||||
Story_clockwork_act_2(-195829567),
|
||||
Collection_madhouse(-147102545),
|
||||
cardpack_legendary_elsweyr(-66009394),
|
||||
EventTicket_OldMethod(0),
|
||||
SoulGem_OldMethod(1),
|
||||
Gold_OldMethod(2),
|
||||
Card(3),
|
||||
GenericInventory(4),
|
||||
Story_clockwork_act_3(9898450),
|
||||
Deck_ancanos_cunning(78535902),
|
||||
deck_dominion_dominance(80719945),
|
||||
cardpack_premium_legendary_oblivion(123972390),
|
||||
Deck_tribunal_glory(185858797),
|
||||
deck_pact_assault(289889510),
|
||||
gold(370048465),
|
||||
Story_dark_brotherhood_act_1(570533001),
|
||||
Story_dark_brotherhood_act_3(649298583),
|
||||
deck_guildsworn_prowess(657290049),
|
||||
deck_ebonheart_premade(722328902),
|
||||
CardPack_Morrowind(771479791),
|
||||
Puzzle_divayth_fyrs_trials(875057351),
|
||||
deck_dunmeravengers(907250839),
|
||||
CardPack_Skyrim(976836926),
|
||||
deck_empire_conquest(1053545101),
|
||||
cardpack_legendary_skyrim(1237593212),
|
||||
cardpack_premium_legendary_morrowind(1272634621),
|
||||
cardpack_premium_legendary_alliancewar(1333340848),
|
||||
Collection_new_life_festival(1379264003),
|
||||
deck_empire_premade(1389291549),
|
||||
cardpack_legendary_oblivion(1414942565),
|
||||
cardpack_premium_legendary_elsweyr(1428958207),
|
||||
cardpack_legendary_morrowind(1463484932),
|
||||
Story_dark_brotherhood_act_2(1591190481),
|
||||
Deck_aelas_companions(1591262042),
|
||||
Puzzle_naryus_challengesuzzle(1798920449),
|
||||
Collection_frostfall_premium(1803478726),
|
||||
CardPack_Clockwork_City(1942964363),
|
||||
Collection_frostfall(1961349195),
|
||||
deck_khamiras_rebellion(2038783878),
|
||||
Story_iom_act_1(2039697399),
|
||||
deck_imperialmight(2131899676),
|
||||
gems(2139828615);
|
||||
|
||||
private final int hash;
|
||||
|
||||
ContentEntryType(final int hash) {
|
||||
this.hash = hash;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package ch.gtache.elderscrollslegends.service.events;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
|
||||
import ch.gtache.elderscrollslegends.service.BaseResult;
|
||||
import ch.gtache.elderscrollslegends.service.DeckService;
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
import ch.gtache.elderscrollslegends.service.account.AccountService;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
@@ -33,23 +35,27 @@ public class EventsEndpoints extends BaseEndpoints {
|
||||
@POST
|
||||
@Path("finalizeEvent")
|
||||
@Consumes("application/json")
|
||||
public void finalizeEvent(@HeaderParam("Authorization") final String authentication,
|
||||
final FinalizeEventRequest request) {
|
||||
@Produces("application/json")
|
||||
public BaseResult finalizeEvent(@HeaderParam("Authorization") final String authentication,
|
||||
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);
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("finalizeEventRun")
|
||||
@Consumes("application/json")
|
||||
public void finalizeEventRun(@HeaderParam("Authorization") final String authentication,
|
||||
final FinalizeEventRunRequest request) {
|
||||
@Produces("application/json")
|
||||
public BaseResult finalizeEventRun(@HeaderParam("Authorization") final String authentication,
|
||||
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);
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -62,7 +68,7 @@ public class EventsEndpoints extends BaseEndpoints {
|
||||
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(),
|
||||
return new GetEventLeaderboardResponse(ResultCode.Ok, "", event.id(), leaderboard.totalPages(),
|
||||
leaderboard.userPage(), leaderboard.entries());
|
||||
}
|
||||
|
||||
@@ -70,38 +76,40 @@ public class EventsEndpoints extends BaseEndpoints {
|
||||
@Path("purchaseEvent")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public PurchaseEventResult purchaseEvent(@HeaderParam("Authorization") final String authentication,
|
||||
final PurchaseEventRequest request) {
|
||||
public BaseResult purchaseEvent(@HeaderParam("Authorization") final String authentication,
|
||||
final PurchaseEventRequest request) {
|
||||
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();
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("purchaseEventRun")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public PurchaseEventRunResult purchaseEventRun(@HeaderParam("Authorization") final String authentication,
|
||||
final PurchaseEventRunRequest request) {
|
||||
public BaseResult purchaseEventRun(@HeaderParam("Authorization") final String authentication,
|
||||
final PurchaseEventRunRequest request) {
|
||||
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();
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("selectExplicitDeck")
|
||||
@Consumes("application/json")
|
||||
public void selectExplicitDeck(@HeaderParam("Authorization") final String authentication,
|
||||
final SelectExplicitDeckRequest request) {
|
||||
@Produces("application/json")
|
||||
public BaseResult selectExplicitDeck(@HeaderParam("Authorization") final String authentication,
|
||||
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);
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -114,7 +122,7 @@ public class EventsEndpoints extends BaseEndpoints {
|
||||
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);
|
||||
return new UpdateEventLeaderboardRankResponse(ResultCode.Ok, "", event.id(), ranking);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -124,6 +132,6 @@ public class EventsEndpoints extends BaseEndpoints {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("fetchEvents called by " + steamID);
|
||||
final var events = eventsService.getEvents(steamID);
|
||||
return new ListEventsResponse(events);
|
||||
return new ListEventsResponse(ResultCode.Ok, "", events);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package ch.gtache.elderscrollslegends.service.events;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record GetEventLeaderboardResponse(long eventId, long totalPages, long userPage, List<LeaderboardEntry> list) {
|
||||
public record GetEventLeaderboardResponse(ResultCode resultCode, String endpoint,
|
||||
long eventId, long totalPages, long userPage, List<LeaderboardEntry> list) {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.events;
|
||||
|
||||
public record ListEventsResponse(EventDescriptionStruct eventDescription) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record ListEventsResponse(ResultCode resultCode, String endpoint,
|
||||
EventDescriptionStruct eventDescription) {
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
package ch.gtache.elderscrollslegends.service.events;
|
||||
|
||||
public record PurchaseEventResult() {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package ch.gtache.elderscrollslegends.service.events;
|
||||
|
||||
public record PurchaseEventRunResult() {
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.events;
|
||||
|
||||
public record UpdateEventLeaderboardRankResponse(long eventId, long ranking) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record UpdateEventLeaderboardRankResponse(ResultCode resultCode, String endpoint,
|
||||
long eventId, long ranking) {
|
||||
}
|
||||
|
||||
@@ -30,13 +30,13 @@ public class FriendsEndpoints extends BaseEndpoints {
|
||||
@GET
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public FriendsResponse get(@HeaderParam("Authorization") final String authentication,
|
||||
public FriendsResponse get(@HeaderParam("x-session-token") 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);
|
||||
final var steamID = authenticateTokenOrThrow(authentication);
|
||||
logger.info("get called by " + steamID + " : " + productId + " ; " + startKeys + " ; " + size + " ; " + language + " ; " + detail);
|
||||
return new FriendsResponse(List.of(), 0, 0);
|
||||
}
|
||||
@@ -45,9 +45,9 @@ public class FriendsEndpoints extends BaseEndpoints {
|
||||
@Path("/unfriend")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public ActionResponse unfriend(@HeaderParam("Authorization") final String authentication,
|
||||
public ActionResponse unfriend(@HeaderParam("x-session-token") final String authentication,
|
||||
final ActionBody request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
final var steamID = authenticateTokenOrThrow(authentication);
|
||||
logger.info("unfriend called by " + steamID + " : " + request);
|
||||
for (final var buid : request.buids()) {
|
||||
friendsService.unfriend(steamID, buid);
|
||||
@@ -59,13 +59,13 @@ public class FriendsEndpoints extends BaseEndpoints {
|
||||
@Path("/block")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public BlockedResponse getBlocked(@HeaderParam("Authorization") final String authentication,
|
||||
public BlockedResponse getBlocked(@HeaderParam("x-session-token") 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);
|
||||
final var steamID = authenticateTokenOrThrow(authentication);
|
||||
logger.info("getBlocked called by " + steamID + " : " + productId + " ; " + startKeys + " ; " + size + " ; " + language + " ; " + detail);
|
||||
return new BlockedResponse(List.of(), 0, 0);
|
||||
}
|
||||
@@ -74,9 +74,9 @@ public class FriendsEndpoints extends BaseEndpoints {
|
||||
@Path("/block")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public ActionResponse block(@HeaderParam("Authorization") final String authentication,
|
||||
public ActionResponse block(@HeaderParam("x-session-token") final String authentication,
|
||||
final ActionBody request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
final var steamID = authenticateTokenOrThrow(authentication);
|
||||
logger.info("block called by " + steamID + " : " + request);
|
||||
for (final var buid : request.buids()) {
|
||||
friendsService.block(steamID, buid);
|
||||
@@ -88,9 +88,9 @@ public class FriendsEndpoints extends BaseEndpoints {
|
||||
@Path("/unblock")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public ActionResponse unblock(@HeaderParam("Authorization") final String authentication,
|
||||
public ActionResponse unblock(@HeaderParam("x-session-token") final String authentication,
|
||||
final ActionBody request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
final var steamID = authenticateTokenOrThrow(authentication);
|
||||
logger.info("unblock called by " + steamID + " : " + request);
|
||||
for (final var buid : request.buids()) {
|
||||
friendsService.unblock(steamID, buid);
|
||||
@@ -110,10 +110,10 @@ public class FriendsEndpoints extends BaseEndpoints {
|
||||
@Path("/requests")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public RequestsResponse getRequests(@HeaderParam("Authorization") final String authentication,
|
||||
public RequestsResponse getRequests(@HeaderParam("x-session-token") final String authentication,
|
||||
@QueryParam("start_keys") final int startKeys,
|
||||
@QueryParam("size") final int size) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
final var steamID = authenticateTokenOrThrow(authentication);
|
||||
logger.info("getRequests called by " + steamID + " : " + startKeys + " ; " + size);
|
||||
return new RequestsResponse(List.of(), 0);
|
||||
}
|
||||
@@ -122,9 +122,9 @@ public class FriendsEndpoints extends BaseEndpoints {
|
||||
@Path("/requests")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public ActionResponse requests(@HeaderParam("Authorization") final String authentication,
|
||||
public ActionResponse requests(@HeaderParam("x-session-token") final String authentication,
|
||||
final ActionBody requests) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
final var steamID = authenticateTokenOrThrow(authentication);
|
||||
logger.info("requests called by " + steamID);
|
||||
for (final var buid : requests.buids()) {
|
||||
friendsService.sendRequest(steamID, buid);
|
||||
@@ -136,9 +136,9 @@ public class FriendsEndpoints extends BaseEndpoints {
|
||||
@Path("/requests/cancel")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public ActionResponse cancelRequest(@HeaderParam("Authorization") final String authentication,
|
||||
public ActionResponse cancelRequest(@HeaderParam("x-session-token") final String authentication,
|
||||
final ActionBody request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
final var steamID = authenticateTokenOrThrow(authentication);
|
||||
logger.info("cancelRequest called by " + steamID + " : " + request);
|
||||
for (final var buid : request.buids()) {
|
||||
friendsService.cancelRequest(steamID, buid);
|
||||
@@ -150,9 +150,9 @@ public class FriendsEndpoints extends BaseEndpoints {
|
||||
@Path("/requests/accept")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public ActionResponse acceptRequest(@HeaderParam("Authorization") final String authentication,
|
||||
public ActionResponse acceptRequest(@HeaderParam("x-session-token") final String authentication,
|
||||
final ActionBody request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
final var steamID = authenticateTokenOrThrow(authentication);
|
||||
logger.info("acceptRequest called by " + steamID + " : " + request);
|
||||
for (final var buid : request.buids()) {
|
||||
friendsService.acceptRequest(steamID, buid);
|
||||
@@ -164,9 +164,9 @@ public class FriendsEndpoints extends BaseEndpoints {
|
||||
@Path("/requests/reject")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public ActionResponse rejectRequest(@HeaderParam("Authorization") final String authentication,
|
||||
public ActionResponse rejectRequest(@HeaderParam("x-session-token") final String authentication,
|
||||
final ActionBody request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
final var steamID = authenticateTokenOrThrow(authentication);
|
||||
logger.info("rejectRequest called by " + steamID + " : " + request);
|
||||
for (final var buid : request.buids()) {
|
||||
friendsService.rejectRequest(steamID, buid);
|
||||
@@ -178,12 +178,11 @@ public class FriendsEndpoints extends BaseEndpoints {
|
||||
@Path("/requests/sent")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public SentRequestsResponse getSentRequests(@HeaderParam("Authorization") final String authentication,
|
||||
public SentRequestsResponse getSentRequests(@HeaderParam("x-session-token") final String authentication,
|
||||
@QueryParam("start_keys") final int startKeys,
|
||||
@QueryParam("size") final int size,
|
||||
final ActionBody request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("getSentRequests called by " + steamID + " : " + startKeys + " ; " + size + " ; " + request);
|
||||
@QueryParam("size") final int size) {
|
||||
final var steamID = authenticateTokenOrThrow(authentication);
|
||||
logger.info("getSentRequests called by " + steamID + " : " + startKeys + " ; " + size);
|
||||
return new SentRequestsResponse(List.of(), 0);
|
||||
}
|
||||
|
||||
@@ -191,12 +190,12 @@ public class FriendsEndpoints extends BaseEndpoints {
|
||||
@Path("/search")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public SearchResponse search(@HeaderParam("Authorization") final String authentication,
|
||||
public SearchResponse search(@HeaderParam("x-session-token") final String authentication,
|
||||
@QueryParam("search_term") final String searchTerm,
|
||||
@QueryParam("start_keys") final int startKeys,
|
||||
@QueryParam("size") final int size,
|
||||
final ActionBody request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
final var steamID = authenticateTokenOrThrow(authentication);
|
||||
logger.info("search called by " + steamID + " : " + searchTerm + " ; " + startKeys + " ; " + size + " ; " + request);
|
||||
return new SearchResponse(List.of(), 0);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package ch.gtache.elderscrollslegends.service.inventory;
|
||||
|
||||
public enum Cardback {
|
||||
Default,
|
||||
HousesOfMorrowind,
|
||||
Scale,
|
||||
CaiusTraining,
|
||||
NaryusChallenges,
|
||||
DivaythFyrsTrials,
|
||||
HouseHlaalu,
|
||||
HouseRedoran,
|
||||
TribunalTemple,
|
||||
HouseTelvanni,
|
||||
HouseDagoth,
|
||||
NerevarReborn,
|
||||
Legend,
|
||||
ClockworkCity,
|
||||
DarkBrotherhood,
|
||||
EldenRoot,
|
||||
FlameAtronach,
|
||||
StormAtronach,
|
||||
Twitch2018,
|
||||
NewClient,
|
||||
MadnessSalePremium1,
|
||||
MadnessSalePremium2,
|
||||
PrinceOfMadness,
|
||||
PrinceOfMadnessPremium,
|
||||
IsleOfMadnessSaint,
|
||||
LegendPremium,
|
||||
LegendAltPremium,
|
||||
ElderScrolls25thAnniversary,
|
||||
AllianceWarPremium,
|
||||
LocalContenderPremium,
|
||||
AllianceWarCollector,
|
||||
AllianceWarDaggerfall,
|
||||
AllianceWarEbonheart,
|
||||
AllianceWarAldmeri,
|
||||
AllianceWarGuildsworn,
|
||||
AllianceWarEmpire,
|
||||
E32019,
|
||||
ElsweyrPreorder,
|
||||
SageIntro,
|
||||
SageCollector,
|
||||
SageLich,
|
||||
SageCrossPromo,
|
||||
OblivionPreorder,
|
||||
CadwellNormal,
|
||||
CadwellPremium,
|
||||
ColdharbourNormal,
|
||||
ColdharbourPremium,
|
||||
JawsIntro,
|
||||
JawsCollector,
|
||||
JawsSeptim,
|
||||
EventsShiveringNormal,
|
||||
EventsShiveringPremium,
|
||||
EventsSteedNormal,
|
||||
EventsSteedPremium,
|
||||
EventsGrayFoxNormal,
|
||||
EventsGrayFoxPremium,
|
||||
EventsFightersNormal,
|
||||
EventsFightersPremium,
|
||||
EventsMagesNormal,
|
||||
EventsMagesPremium,
|
||||
EventsThievesNormal,
|
||||
EventsThievesPremium,
|
||||
FutureEvents1Regular,
|
||||
FutureEvents1Premium,
|
||||
FutureEvents2Regular,
|
||||
FutureEvents2Premium,
|
||||
FutureEvents3Regular,
|
||||
FutureEvents3Premium,
|
||||
FutureEvents4Regular,
|
||||
FutureEvents4Premium,
|
||||
FutureEvents5Regular,
|
||||
FutureEvents5Premium,
|
||||
}
|
||||
@@ -2,6 +2,6 @@ package ch.gtache.elderscrollslegends.service.inventory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record CategoryData(String category, String selected, List<String> available,
|
||||
public record CategoryData(GenericInventoryCategory category, String selected, List<String> available,
|
||||
List<String> locked, List<String> descriptions) {
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@ package ch.gtache.elderscrollslegends.service.inventory;
|
||||
import java.util.List;
|
||||
|
||||
public record Deck(long id, String displayName, boolean hasBeenSeen, boolean isValid, boolean isLocked,
|
||||
boolean renameFromuser, int artTypeHash, int deckTypeHash, List<DeckCard> cards, long eventId) {
|
||||
boolean renameFromUser, int artTypeHash, int deckTypeHash, List<DeckCard> cards, long eventId) {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.inventory;
|
||||
|
||||
public enum GenericInventoryCategory {
|
||||
avatar,
|
||||
cardback,
|
||||
title,
|
||||
}
|
||||
@@ -1,11 +1,15 @@
|
||||
package ch.gtache.elderscrollslegends.service.inventory;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
|
||||
import ch.gtache.elderscrollslegends.service.BaseResult;
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
import ch.gtache.elderscrollslegends.service.account.AccountService;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
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;
|
||||
@@ -25,18 +29,26 @@ public class GenericInventoryEndpoints extends BaseEndpoints {
|
||||
|
||||
@GET
|
||||
@Path("fetch")
|
||||
public InventoryFetchResponse fetch(@HeaderParam("Authorization") final String authentication) {
|
||||
@Produces("application/json")
|
||||
public GenericInventoryFetchResponse fetch(@HeaderParam("Authorization") final String authentication) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("fetch called by " + steamID);
|
||||
return new InventoryFetchResponse(genericsInventoryService.getInventory(steamID));
|
||||
final var data = genericsInventoryService.getInventory(steamID);
|
||||
return new GenericInventoryFetchResponse(ResultCode.Ok, "", data);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("setSelected")
|
||||
public void setSelected(@HeaderParam("Authorization") final String authentication,
|
||||
final InventorySetSelectedRequest request) {
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public BaseResult setSelected(@HeaderParam("Authorization") final String authentication,
|
||||
final InventorySetSelectedRequest request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("setSelected called by " + steamID);
|
||||
genericsInventoryService.setSelected(steamID, request.category(), request.itemKey());
|
||||
if (genericsInventoryService.setSelected(steamID, request.category(), request.itemKey())) {
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
} else {
|
||||
return new BaseResult(ResultCode.InternalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package ch.gtache.elderscrollslegends.service.inventory;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record GenericInventoryFetchResponse(ResultCode resultCode, String endpoint,
|
||||
List<CategoryData> categories) {
|
||||
}
|
||||
@@ -3,23 +3,109 @@ package ch.gtache.elderscrollslegends.service.inventory;
|
||||
import ch.gtache.elderscrollslegends.service.BaseService;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
|
||||
@ApplicationScoped
|
||||
class GenericsInventoryService extends BaseService {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(GenericsInventoryService.class);
|
||||
|
||||
private static final String GET_INVENTORY = "SELECT a.name, c.name, t.name FROM profile p " +
|
||||
"LEFT JOIN avatar a ON p.avatar_id=a.id LEFT JOIN cardback c ON p.cardback_id=c.id " +
|
||||
"LEFT JOIN title t ON p.title_id=t.id WHERE p.player_id=(SELECT id FROM player WHERE steam_id=?)";
|
||||
|
||||
@Inject
|
||||
GenericsInventoryService(final DataSource dataSource) {
|
||||
super(dataSource);
|
||||
}
|
||||
|
||||
List<CategoryData> getInventory(final String steamID) {
|
||||
return List.of();
|
||||
final var steamIDHandle = Long.parseLong(steamID);
|
||||
final var mapping = new EnumMap<GenericInventoryCategory, String>(GenericInventoryCategory.class);
|
||||
final var data = new ArrayList<CategoryData>(3);
|
||||
try (final var connection = dataSource().getConnection()) {
|
||||
try (final var statement = connection.prepareStatement(GET_INVENTORY)) {
|
||||
statement.setLong(1, steamIDHandle);
|
||||
try (final var rs = statement.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
final var avatar = rs.getString(1);
|
||||
final var cardback = rs.getString(2);
|
||||
final var title = rs.getString(3);
|
||||
mapping.put(GenericInventoryCategory.avatar, avatar);
|
||||
mapping.put(GenericInventoryCategory.cardback, cardback);
|
||||
mapping.put(GenericInventoryCategory.title, title);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final var value : GenericInventoryCategory.values()) {
|
||||
final var table = value.name();
|
||||
try (final var statement = connection.prepareStatement("SELECT t.name, t.description, pt.available, pt.locked FROM " + table + " t " +
|
||||
"JOIN player_" + table + " pt ON t.id=pt." + table + "_id " +
|
||||
"JOIN player p ON pt.player_id=p.id WHERE p.steam_id=?")) {
|
||||
statement.setLong(1, steamIDHandle);
|
||||
try (final var rs = statement.executeQuery()) {
|
||||
final var list = new ArrayList<Data>();
|
||||
while (rs.next()) {
|
||||
final var name = rs.getString(1);
|
||||
final var description = rs.getString(2);
|
||||
final var available = rs.getBoolean(3);
|
||||
final var locked = rs.getBoolean(4);
|
||||
list.add(new Data(name, description, available, locked));
|
||||
}
|
||||
final var available = list.stream().filter(Data::available).map(Data::name).toList();
|
||||
final var locked = list.stream().filter(Data::locked).map(Data::name).toList();
|
||||
final var descriptions = list.stream().map(Data::description).toList();
|
||||
data.add(new CategoryData(value, mapping.get(value), available, locked, descriptions));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
logger.error("Error getting data for " + steamID, e);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
void setSelected(final String steamID, final String category, final String itemKey) {
|
||||
private record Data(String name, String description, boolean available, boolean locked) {
|
||||
|
||||
}
|
||||
|
||||
String getSelected(final String steamID, final GenericInventoryCategory category) {
|
||||
final var steamIDHandle = Long.parseLong(steamID);
|
||||
final var table = category.name();
|
||||
final var field = table + "_id";
|
||||
try (final var connection = dataSource().getConnection();
|
||||
final var statement = connection.prepareStatement("SELECT t.name FROM " + table + " t JOIN profile p ON p." + field + "=t.id WHERE player_id=(SELECT id FROM player WHERE steam_id=?)")) {
|
||||
statement.setLong(1, steamIDHandle);
|
||||
try (final var rs = statement.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
return rs.getString(1);
|
||||
}
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
logger.error("Error getting " + category + " for " + steamID, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean setSelected(final String steamID, final GenericInventoryCategory category, final String itemKey) {
|
||||
final var steamIDHandle = Long.parseLong(steamID);
|
||||
final var table = category.name();
|
||||
final var field = table + "_id";
|
||||
try (final var connection = dataSource().getConnection();
|
||||
final var statement = connection.prepareStatement("UPDATE profile SET " + field + "=(SELECT id FROM " + table + " WHERE name=?) WHERE player_id=(SELECT id FROM player WHERE steam_id=?)")) {
|
||||
statement.setString(1, itemKey);
|
||||
statement.setLong(2, steamIDHandle);
|
||||
return statement.executeUpdate() == 1;
|
||||
} catch (final SQLException e) {
|
||||
logger.error("Error setting " + category + " for " + steamID, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.inventory;
|
||||
|
||||
public record InventoryCreateDeckResponse(long deckId) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record InventoryCreateDeckResponse(ResultCode resultCode, String endpoint,
|
||||
long deckId) {
|
||||
}
|
||||
|
||||
@@ -1,20 +1,43 @@
|
||||
package ch.gtache.elderscrollslegends.service.inventory;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
|
||||
import ch.gtache.elderscrollslegends.service.BaseResult;
|
||||
import ch.gtache.elderscrollslegends.service.DeckService;
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
import ch.gtache.elderscrollslegends.service.account.AccountService;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
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 static java.util.Objects.requireNonNull;
|
||||
|
||||
@Path("inventory")
|
||||
public class InventoryEndpoints {
|
||||
public class InventoryEndpoints extends BaseEndpoints {
|
||||
private static final Logger logger = Logger.getLogger(InventoryEndpoints.class);
|
||||
|
||||
private final InventoryService inventoryService;
|
||||
private final DeckService deckService;
|
||||
|
||||
@Inject
|
||||
InventoryEndpoints(final AccountService accountService, final InventoryService inventoryService,
|
||||
final DeckService deckService) {
|
||||
super(accountService);
|
||||
this.inventoryService = requireNonNull(inventoryService);
|
||||
this.deckService = requireNonNull(deckService);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("list_v2")
|
||||
@Produces("application/json")
|
||||
public InventoryListResponse list(@HeaderParam("Authorization") final String authentication) {
|
||||
return null;
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("list called by " + steamID);
|
||||
return new InventoryListResponse(ResultCode.Ok, "", inventoryService.getInventory(steamID));
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -23,15 +46,22 @@ public class InventoryEndpoints {
|
||||
@Produces("application/json")
|
||||
public InventoryCreateDeckResponse createDeck(@HeaderParam("Authorization") final String authentication,
|
||||
final InventoryCreateDeckRequest request) {
|
||||
return null;
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("createDeck called by " + steamID + " : " + request);
|
||||
final var createdDeck = deckService.createDeck(steamID, request.displayName());
|
||||
return new InventoryCreateDeckResponse(ResultCode.Ok, "", createdDeck);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("deleteDeck")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public void deleteDeck(@HeaderParam("Authorization") final String authentication,
|
||||
final InventoryDeleteDeckRequest request) {
|
||||
public BaseResult deleteDeck(@HeaderParam("Authorization") final String authentication,
|
||||
final InventoryDeleteDeckRequest request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("deleteDeck called by " + steamID + " : " + request);
|
||||
deckService.deleteDeck(steamID, request.deckId());
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -40,7 +70,10 @@ public class InventoryEndpoints {
|
||||
@Produces("application/json")
|
||||
public InventorySaveResult saveDeck(@HeaderParam("Authorization") final String authentication,
|
||||
final Deck request) {
|
||||
return null;
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("saveDeck called by " + steamID + " : " + request);
|
||||
final var success = deckService.saveDeck(steamID, request);
|
||||
return new InventorySaveResult(ResultCode.Ok, "", success);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -49,8 +82,9 @@ public class InventoryEndpoints {
|
||||
@Produces("application/json")
|
||||
public InventorySaveResult setSeens(@HeaderParam("Authorization") final String authentication,
|
||||
final InventorySetSeens request) {
|
||||
return null;
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("setSeens called by " + steamID + " : " + request);
|
||||
final var success = inventoryService.setSeens(steamID, request);
|
||||
return new InventorySaveResult(ResultCode.Ok, "", success);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
package ch.gtache.elderscrollslegends.service.inventory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record InventoryFetchResponse(List<CategoryData> categories) {
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.inventory;
|
||||
|
||||
public record InventoryListResponse(InventoryDescLoadable inventory) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record InventoryListResponse(ResultCode resultCode, String endpoint,
|
||||
InventoryDescLoadable inventory) {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.inventory;
|
||||
|
||||
public record InventorySaveResult(boolean success) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record InventorySaveResult(ResultCode resultCode, String endpoint,
|
||||
boolean success) {
|
||||
}
|
||||
|
||||
@@ -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 InventoryService extends BaseService {
|
||||
|
||||
@Inject
|
||||
InventoryService(final DataSource dataSource) {
|
||||
super(dataSource);
|
||||
}
|
||||
|
||||
InventoryDescLoadable getInventory(final String steamID) {
|
||||
return new InventoryDescLoadable(10, List.of(), List.of());
|
||||
}
|
||||
|
||||
boolean setSeens(final String steamID, final InventorySetSeens request) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package ch.gtache.elderscrollslegends.service.inventory;
|
||||
|
||||
public record InventorySetSelectedRequest(String category, String itemKey) {
|
||||
public record InventorySetSelectedRequest(GenericInventoryCategory category, String itemKey) {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.matching;
|
||||
|
||||
public record ClientMatchRejoinResult(MatchReady gameReadyPlayerClient) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record ClientMatchRejoinResult(ResultCode resultCode, String endpoint,
|
||||
MatchReady gameReadyPlayerClient) {
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package ch.gtache.elderscrollslegends.service.matching;
|
||||
|
||||
public record ClientMatchRequestResult(String requestId, String poolName, int estimatedWaitSeconds,
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record ClientMatchRequestResult(ResultCode resultCode, String endpoint,
|
||||
String requestId, String poolName, int estimatedWaitSeconds,
|
||||
int refreshPeriodSeconds) {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.matching;
|
||||
|
||||
public record ClientMatchReserveRequestResult(String requestId, MatchErrorType errorType) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record ClientMatchReserveRequestResult(ResultCode resultCode, String endpoint,
|
||||
String requestId, MatchErrorType errorType) {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.matching;
|
||||
|
||||
public record ClientOpponentBuidResult(String opponentBuid) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record ClientOpponentBuidResult(ResultCode resultCode, String endpoint,
|
||||
String opponentBuid) {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.matching;
|
||||
|
||||
public record ClientSpectateRequestResult(String requestId, MatchReady gameReadyPlayerClient) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record ClientSpectateRequestResult(ResultCode resultCode, String endpoint,
|
||||
String requestId, MatchReady gameReadyPlayerClient) {
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package ch.gtache.elderscrollslegends.service.matching;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
|
||||
import ch.gtache.elderscrollslegends.service.BaseResult;
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
import ch.gtache.elderscrollslegends.service.account.AccountService;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
@@ -32,7 +34,7 @@ public class MatchingEndpoints extends BaseEndpoints {
|
||||
public ClientMatchReserveRequestResult reserve(@HeaderParam("Authorization") final String authentication) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("reserve called by " + steamID);
|
||||
return new ClientMatchReserveRequestResult("", MatchErrorType.InternalError);
|
||||
return new ClientMatchReserveRequestResult(ResultCode.Ok, "", "", MatchErrorType.InternalError);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -43,27 +45,31 @@ public class MatchingEndpoints extends BaseEndpoints {
|
||||
final ClientMatchRequest request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("add called by " + steamID + " : " + request);
|
||||
return new ClientMatchRequestResult("", "", Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
return new ClientMatchRequestResult(ResultCode.Ok, "", "", "", Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("cancel")
|
||||
@Consumes("application/json")
|
||||
public void cancel(@HeaderParam("Authorization") final String authentication,
|
||||
final ClientMatchCancelRequest request) {
|
||||
@Produces("application/json")
|
||||
public BaseResult cancel(@HeaderParam("Authorization") final String authentication,
|
||||
final ClientMatchCancelRequest request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("cancel called by " + steamID + " : " + request);
|
||||
matchingService.cancel(steamID, request.requestId(), request.friendBuid());
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("respondchallenge")
|
||||
@Consumes("application/json")
|
||||
public void respondChallenge(@HeaderParam("Authorization") final String authentication,
|
||||
final ClientChallengeRequest request) {
|
||||
@Produces("application/json")
|
||||
public BaseResult respondChallenge(@HeaderParam("Authorization") final String authentication,
|
||||
final ClientChallengeRequest request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("respondChallenge called by " + steamID + " : " + request);
|
||||
matchingService.respondChallenge(steamID, request.friendBuid(), request.type());
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -74,7 +80,7 @@ public class MatchingEndpoints extends BaseEndpoints {
|
||||
final RefreshRequest request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("refresh called by " + steamID + " : " + request);
|
||||
return new RefreshResult(Integer.MAX_VALUE, null);
|
||||
return new RefreshResult(ResultCode.Ok, "", Integer.MAX_VALUE, null);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -83,14 +89,16 @@ public class MatchingEndpoints extends BaseEndpoints {
|
||||
public ClientMatchRejoinResult rejoin(@HeaderParam("Authorization") final String authentication) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("rejoin called by " + steamID);
|
||||
return new ClientMatchRejoinResult(null);
|
||||
return new ClientMatchRejoinResult(ResultCode.Ok, "", null);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("rejoindeny")
|
||||
public void rejoinDeny(@HeaderParam("Authorization") final String authentication) {
|
||||
@Produces("application/json")
|
||||
public BaseResult rejoinDeny(@HeaderParam("Authorization") final String authentication) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("rejoinDeny called by " + steamID);
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -102,7 +110,7 @@ public class MatchingEndpoints extends BaseEndpoints {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("requestOpponent called by " + steamID + " : " + request);
|
||||
final var opponentID = matchingService.requestOpponent(steamID, request.friendBuid());
|
||||
return new ClientOpponentBuidResult(opponentID);
|
||||
return new ClientOpponentBuidResult(ResultCode.Ok, "", opponentID);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -113,7 +121,7 @@ public class MatchingEndpoints extends BaseEndpoints {
|
||||
final ClientSpectateRequest request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("spectate called by " + steamID + " : " + request);
|
||||
return new ClientSpectateRequestResult("", null);
|
||||
return new ClientSpectateRequestResult(ResultCode.Ok, "", "", null);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -124,6 +132,6 @@ public class MatchingEndpoints extends BaseEndpoints {
|
||||
final ClientSpectateRequest request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("dualspectate called by " + steamID + " : " + request);
|
||||
return new ClientSpectateRequestResult("", null);
|
||||
return new ClientSpectateRequestResult(ResultCode.Ok, "", "", null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.matching;
|
||||
|
||||
public record RefreshResult(int estimatedWaitSeconds, MatchReady gameReadyPlayerClient) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record RefreshResult(ResultCode resultCode, String endpoint,
|
||||
int estimatedWaitSeconds, MatchReady gameReadyPlayerClient) {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.packages;
|
||||
|
||||
public record DeliverResponse(Delivered delivered) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record DeliverResponse(ResultCode resultCode, String endpoint,
|
||||
Delivered delivered) {
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package ch.gtache.elderscrollslegends.service.packages;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record ListPackagesResponse(int massOpenMinCount, List<PackageDescription> packageInfos) {
|
||||
public record ListPackagesResponse(ResultCode resultCode, String endpoint,
|
||||
int massOpenMinCount, List<PackageDescription> packageInfos) {
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package ch.gtache.elderscrollslegends.service.packages;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record MassPackOpeningResponse(int remaining, List<ItemDesc> delivered) {
|
||||
public record MassPackOpeningResponse(ResultCode resultCode, String endpoint,
|
||||
int remaining, List<ItemDesc> delivered) {
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.packages;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
import ch.gtache.elderscrollslegends.service.account.AccountService;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
@@ -29,7 +30,7 @@ public class PackagesEndpoints extends BaseEndpoints {
|
||||
public ListPackagesResponse list(@HeaderParam("Authorization") final String authentication) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("list called by " + steamID);
|
||||
return new ListPackagesResponse(0, List.of());
|
||||
return new ListPackagesResponse(ResultCode.Ok, "", 0, List.of());
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -40,7 +41,7 @@ public class PackagesEndpoints extends BaseEndpoints {
|
||||
final DeliverRequest deliverRequest) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("deliver called by " + steamID + " : " + deliverRequest);
|
||||
return new DeliverResponse(new Delivered(0, 0, List.of()));
|
||||
return new DeliverResponse(ResultCode.Ok, "", new Delivered(0, 0, List.of()));
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -51,6 +52,6 @@ public class PackagesEndpoints extends BaseEndpoints {
|
||||
final MassPackOpeningRequest massPackOpeningRequest) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("massPackOpening called by " + steamID + " : " + massPackOpeningRequest);
|
||||
return new MassPackOpeningResponse(0, List.of());
|
||||
return new MassPackOpeningResponse(ResultCode.Ok, "", 0, List.of());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@ public class PresenceEndpoints extends BaseEndpoints {
|
||||
@Path("presence")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public PostPresenceResponse presence(@HeaderParam("Authorization") final String authentication,
|
||||
public PostPresenceResponse presence(@HeaderParam("x-session-token") final String authentication,
|
||||
final PostPresenceBody postPresenceBody) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("presence called by " + steamID + " : " + postPresenceBody);
|
||||
return new PostPresenceResponse("", 0, new PresenceResponse(0));
|
||||
final var steamID = authenticateTokenOrThrow(authentication);
|
||||
logger.debug("presence called by " + steamID + " : " + postPresenceBody);
|
||||
return new PostPresenceResponse("", 0, new PresenceResponse(120));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package ch.gtache.elderscrollslegends.service.profile;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public enum CollectionName {
|
||||
Core("0_Core"),
|
||||
Dark_Brotherhood("Dark_Brotherhood"),
|
||||
Skyrim("Skyrim"),
|
||||
Clockwork_City("Clockwork_City"),
|
||||
Morrowind("Morrowind"),
|
||||
Isles_Of_Madness("Isles_Of_Madness"),
|
||||
Alliance_War("Alliance_War"),
|
||||
Sage("Sage"),
|
||||
Crisis("Crisis");
|
||||
|
||||
private final String databaseName;
|
||||
|
||||
CollectionName(final String databaseName) {
|
||||
this.databaseName = Objects.requireNonNull(databaseName);
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String databaseName() {
|
||||
return databaseName;
|
||||
}
|
||||
|
||||
public static CollectionName getCollection(final String name) {
|
||||
for (final var collection : values()) {
|
||||
if (collection.databaseName().equals(name)) {
|
||||
return collection;
|
||||
}
|
||||
}
|
||||
return valueOf(name);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package ch.gtache.elderscrollslegends.service.profile;
|
||||
|
||||
public record CollectionStat(String collectionTypeName, String rarity, int numTypesOwned, int numTypes) {
|
||||
public record CollectionStat(CollectionName collectionTypeName, Rarity rarity, int numTypesOwned, int numTypes) {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.profile;
|
||||
|
||||
public record FetchProfileResponse(ProfileStruct profile) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record FetchProfileResponse(ResultCode resultCode, String endpoint,
|
||||
ProfileStruct profile) {
|
||||
}
|
||||
|
||||
@@ -1,46 +1,58 @@
|
||||
package ch.gtache.elderscrollslegends.service.profile;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public enum OnboardingProgressType {
|
||||
None,
|
||||
HasSeenIntroVideo,
|
||||
HasSelectedAvatar,
|
||||
HasWonFirstMatch,
|
||||
HasSeenWelcomePopup,
|
||||
HasUnlockedMenu,
|
||||
IsPackOpenTutorialComplete,
|
||||
IsDeckBuilderNoviceTutorialComplete,
|
||||
IsDeckBuilderAdvancedTutorialComplete,
|
||||
HasUnlockedSoloArena,
|
||||
HasSeenSoloArenaIntro,
|
||||
HasSeenSoloArenaClassSelect,
|
||||
HasSeenSoloArenaDraftScreen,
|
||||
HasSeenSoloArenaDraftSecondPick,
|
||||
HasSeenSoloArenaPlayScreen,
|
||||
HasSeenSoloArenaDraftPrize,
|
||||
HasSeenSoloArenaPlayScreenAfterWin,
|
||||
HasSeenSoloArenaPlayScreenAfterLoss,
|
||||
HasUnlockedVersusArena,
|
||||
HasSeenMainMenu,
|
||||
HasSeenPlayerProfile,
|
||||
HasSeenRewardSoulGem,
|
||||
HasSeenRewardTicket,
|
||||
HasSeenSoulSummon,
|
||||
HasSeenSoulTrapExtras,
|
||||
HasSeenStoryPickerWin,
|
||||
HasUnlockedDailyQuests,
|
||||
HasSeenVersusArenaUnlockMsg,
|
||||
HasSeenQuest_CompleteTFHAct2,
|
||||
HasSeenQuest_CompleteTFHAct3,
|
||||
HasSeenQuest_CompleteSoloArena,
|
||||
HasSeenQuest_PlayMode,
|
||||
IsShopTutorialComplete,
|
||||
HasSeenRankedResult,
|
||||
HasSeenRankedLossEnabledStar,
|
||||
HasSeenRankedLegendary,
|
||||
HasSeenRankedSerpent,
|
||||
HasSeenRankedBonus,
|
||||
IsDailyQuestTutorialComplete,
|
||||
HasMadeTriColorDeck,
|
||||
HasSeenEarlyVsWarning,
|
||||
Count
|
||||
None("none"),
|
||||
HasSeenIntroVideo("has_seen_intro_video"),
|
||||
HasSelectedAvatar("has_selected_avatar"),
|
||||
HasWonFirstMatch("has_won_first_match"),
|
||||
HasSeenWelcomePopup("has_seen_welcome_popup"),
|
||||
HasUnlockedMenu("has_unlocked_menu"),
|
||||
IsPackOpenTutorialComplete("is_pack_open_tutorial_complete"),
|
||||
IsDeckBuilderNoviceTutorialComplete("is_deck_builder_novice_tutorial_complete"),
|
||||
IsDeckBuilderAdvancedTutorialComplete("is_deck_builder_advanced_tutorial_complete"),
|
||||
HasUnlockedSoloArena("has_unlocked_solo_arena"),
|
||||
HasSeenSoloArenaIntro("has_seen_solo_arena_intro"),
|
||||
HasSeenSoloArenaClassSelect("has_seen_solo_arena_class_select"),
|
||||
HasSeenSoloArenaDraftScreen("has_seen_solo_arena_draft_screen"),
|
||||
HasSeenSoloArenaDraftSecondPick("has_seen_solo_arena_draft_second_pick"),
|
||||
HasSeenSoloArenaPlayScreen("has_seen_solo_arena_play_screen"),
|
||||
HasSeenSoloArenaDraftPrize("has_seen_solo_arena_draft_prize"),
|
||||
HasSeenSoloArenaPlayScreenAfterWin("has_seen_solo_arena_play_screen_after_win"),
|
||||
HasSeenSoloArenaPlayScreenAfterLoss("has_seen_solo_arena_play_screen_after_loss"),
|
||||
HasUnlockedVersusArena("has_unlocked_versus_arena"),
|
||||
HasSeenMainMenu("has_seen_main_menu"),
|
||||
HasSeenPlayerProfile("has_seen_player_profile"),
|
||||
HasSeenRewardSoulGem("has_seen_reward_soul_gem"),
|
||||
HasSeenRewardTicket("has_seen_reward_ticket"),
|
||||
HasSeenSoulSummon("has_seen_soul_summon"),
|
||||
HasSeenSoulTrapExtras("has_seen_soul_trap_extras"),
|
||||
HasSeenStoryPickerWin("has_seen_story_picker_win"),
|
||||
HasUnlockedDailyQuests("has_unlocked_daily_quests"),
|
||||
HasSeenVersusArenaUnlockMsg("has_seen_versus_arena_unlock_msg"),
|
||||
HasSeenQuest_CompleteTFHAct2("has_seen_quest_complete_tfh_act2"),
|
||||
HasSeenQuest_CompleteTFHAct3("has_seen_quest_complete_tfh_act3"),
|
||||
HasSeenQuest_CompleteSoloArena("has_seen_quest_complete_solo_arena"),
|
||||
HasSeenQuest_PlayMode("has_seen_quest_play_mode"),
|
||||
IsShopTutorialComplete("is_shop_tutorial_complete"),
|
||||
HasSeenRankedResult("has_seen_ranked_result"),
|
||||
HasSeenRankedLossEnabledStar("has_seen_ranked_loss_enabled_star"),
|
||||
HasSeenRankedLegendary("has_seen_ranked_legendary"),
|
||||
HasSeenRankedSerpent("has_seen_ranked_serpent"),
|
||||
HasSeenRankedBonus("has_seen_ranked_bonus"),
|
||||
IsDailyQuestTutorialComplete("is_daily_quest_tutorial_complete"),
|
||||
HasMadeTriColorDeck("has_made_tri_color_deck"),
|
||||
HasSeenEarlyVsWarning("has_seen_early_vs_warning"),
|
||||
Count("count");
|
||||
|
||||
private final String databaseName;
|
||||
|
||||
OnboardingProgressType(final String databaseName) {
|
||||
this.databaseName = Objects.requireNonNull(databaseName);
|
||||
}
|
||||
|
||||
public String databaseName() {
|
||||
return databaseName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package ch.gtache.elderscrollslegends.service.profile;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
|
||||
import ch.gtache.elderscrollslegends.service.BaseResult;
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
import ch.gtache.elderscrollslegends.service.account.AccountService;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
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.List;
|
||||
@@ -27,72 +31,91 @@ public class ProfileEndpoints extends BaseEndpoints {
|
||||
|
||||
@POST
|
||||
@Path("/doE3Reset")
|
||||
public void doE3Reset(@HeaderParam("Authorization") final String authentication) {
|
||||
@Produces("application/json")
|
||||
public BaseResult doE3Reset(@HeaderParam("Authorization") final String authentication) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("doE3Reset called by " + steamID);
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/requestOptOut")
|
||||
public void requestOptOut(@HeaderParam("Authorization") final String authentication) {
|
||||
@Produces("application/json")
|
||||
public BaseResult requestOptOut(@HeaderParam("Authorization") final String authentication) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("requestOptOut called by " + steamID);
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/requestOptIn")
|
||||
public void requestOptIn(@HeaderParam("Authorization") final String authentication) {
|
||||
@Produces("application/json")
|
||||
public BaseResult requestOptIn(@HeaderParam("Authorization") final String authentication) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("requestOptIn called by " + steamID);
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/setOnboardingProgress")
|
||||
public void setOnboardingProgress(@HeaderParam("Authorization") final String authentication,
|
||||
final SetOnboardingProgressRequest request) {
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public BaseResult setOnboardingProgress(@HeaderParam("Authorization") final String authentication,
|
||||
final SetOnboardingProgressRequest request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("setOnboardingProgress called by " + steamID + " : " + request);
|
||||
final var progressType = OnboardingProgressType.values()[(int) request.progressType()];
|
||||
logger.info("setOnboardingProgress called by " + steamID + " : " + progressType);
|
||||
final var result = profileService.setOnboardingProgress(steamID, progressType);
|
||||
return new BaseResult(result ? ResultCode.Ok : ResultCode.InternalError);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/setSeen")
|
||||
public String setSeen(@HeaderParam("Authorization") final String authentication) {
|
||||
@Produces("application/json")
|
||||
public BaseResult setSeen(@HeaderParam("Authorization") final String authentication) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("setSeen called by " + steamID);
|
||||
return null;
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/doSeasonRollover")
|
||||
public String doSeasonRollover(@HeaderParam("Authorization") final String authentication) {
|
||||
@Produces("application/json")
|
||||
public BaseResult doSeasonRollover(@HeaderParam("Authorization") final String authentication) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("doSeasonRollover called by " + steamID);
|
||||
return null;
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("getProfileForBuid")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public ProfileForBuidResponse getProfileForBuid(@HeaderParam("Authorization") final String authentication,
|
||||
final GetProfileForBuidRequest request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("getProfileForBuid called by " + steamID + " : " + request);
|
||||
final var profile = profileService.getProfile(steamID, request.buid());
|
||||
return new ProfileForBuidResponse(profile, List.of());
|
||||
return new ProfileForBuidResponse(ResultCode.Ok, "", profile, List.of());
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("logMatchStart")
|
||||
public void logMatchStart(@HeaderParam("Authorization") final String authentication,
|
||||
final MatchStartLogData request) {
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public BaseResult logMatchStart(@HeaderParam("Authorization") final String authentication,
|
||||
final MatchStartLogData request) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("logMatchStart called by " + steamID + " : " + request);
|
||||
return new BaseResult(ResultCode.Ok);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/fetch")
|
||||
@Produces("application/json")
|
||||
public FetchProfileResponse getFetch(@HeaderParam("Authorization") final String authentication) {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("fetch called by " + steamID);
|
||||
return new FetchProfileResponse(profileService.getProfile(steamID, steamID));
|
||||
return new FetchProfileResponse(ResultCode.Ok, "", profileService.getProfile(steamID, steamID));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package ch.gtache.elderscrollslegends.service.profile;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
import ch.gtache.elderscrollslegends.service.inventory.InventorySelectedItem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record ProfileForBuidResponse(ProfileStruct profile, List<InventorySelectedItem> categories) {
|
||||
public record ProfileForBuidResponse(ResultCode resultCode, String endpoint,
|
||||
ProfileStruct profile, List<InventorySelectedItem> categories) {
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package ch.gtache.elderscrollslegends.service.profile;
|
||||
|
||||
public record ProfileRating(String ratingMode,
|
||||
public record ProfileRating(RatingMode ratingMode,
|
||||
int rank,
|
||||
int rankStars,
|
||||
int rankSeen,
|
||||
|
||||
@@ -1,21 +1,156 @@
|
||||
package ch.gtache.elderscrollslegends.service.profile;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.BaseService;
|
||||
import ch.gtache.elderscrollslegends.service.Card;
|
||||
import ch.gtache.elderscrollslegends.service.CardService;
|
||||
import ch.gtache.elderscrollslegends.service.CollectionService;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@ApplicationScoped
|
||||
public class ProfileService extends BaseService {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ProfileService.class);
|
||||
|
||||
private static final String GET_PROFILE_QUERY = "SELECT name, level, gold, gems, xp, tickets, daily_gold, daily_gems, o.* " +
|
||||
"FROM profile p JOIN onboarding o ON p.player_id = o.player_id " +
|
||||
"WHERE p.player_id=(SELECT id FROM player WHERE steam_id=?)";
|
||||
private static final String GET_RATINGS_QUERY = "SELECT rm.name, is_max, rank, rank_stars, rank_seen, rank_stars_seen, wins, losses " +
|
||||
"FROM rating JOIN rating_mode rm ON rating.rating_mode_id = rm.id WHERE player_id=(SELECT id FROM player WHERE steam_id=?)";
|
||||
private static final String GET_CARDS_QUERY = "SELECT c.id FROM card c JOIN player_card pc ON c.id = pc.card_id WHERE pc.player_id=(SELECT id FROM player WHERE steam_id=?) AND (pc.num_regular > 0 OR pc.num_premium > 0)";
|
||||
|
||||
private final CollectionService collectionService;
|
||||
private final CardService cardService;
|
||||
|
||||
@Inject
|
||||
ProfileService(final DataSource dataSource) {
|
||||
ProfileService(final DataSource dataSource, final CollectionService collectionService, final CardService cardService) {
|
||||
super(dataSource);
|
||||
this.collectionService = Objects.requireNonNull(collectionService);
|
||||
this.cardService = Objects.requireNonNull(cardService);
|
||||
}
|
||||
|
||||
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);
|
||||
final var profileIDHandle = Long.parseLong(profileID);
|
||||
try (final var connection = dataSource().getConnection();
|
||||
final var statement = connection.prepareStatement(GET_PROFILE_QUERY)) {
|
||||
statement.setLong(1, profileIDHandle);
|
||||
try (final var rs = statement.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
var i = 0;
|
||||
final var name = rs.getString(++i);
|
||||
final var level = rs.getInt(++i);
|
||||
final var gold = rs.getInt(++i);
|
||||
final var gems = rs.getInt(++i);
|
||||
final var xp = rs.getInt(++i);
|
||||
final var tickets = rs.getInt(++i);
|
||||
final var dailyGold = rs.getInt(++i);
|
||||
final var dailyGems = rs.getInt(++i);
|
||||
final var onboardingFlags = getOnboardingLong(rs);
|
||||
final var ratings = getRatings(connection, profileIDHandle);
|
||||
final var collectionStats = getCollectionStats(connection, profileIDHandle);
|
||||
final var seasonRollovers = getSeasonRollovers(connection, profileIDHandle);
|
||||
return new ProfileStruct(name, level, gold, gems, xp, tickets, onboardingFlags, dailyGold, dailyGems,
|
||||
ratings.get(false), ratings.get(true), collectionStats, seasonRollovers);
|
||||
}
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
logger.error("Error getting profile " + profileID + " for player " + steamID, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<CollectionStat> getCollectionStats(final Connection connection, final long profileIDHandle) throws SQLException {
|
||||
final var cards = new ArrayList<Card>();
|
||||
try (final var statement = connection.prepareStatement(GET_CARDS_QUERY)) {
|
||||
statement.setLong(1, profileIDHandle);
|
||||
try (final var rs = statement.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
cards.add(cardService.getCard(rs.getInt(1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
final var stats = new ArrayList<CollectionStat>();
|
||||
for (final var collectionName : CollectionName.values()) {
|
||||
for (final var rarity : Rarity.values()) {
|
||||
final var owned = cards.stream().filter(c -> c.collectionName() == collectionName && c.rarity() == rarity).count();
|
||||
final var total = collectionService.getCollection(collectionName).cards().stream().filter(c -> c.rarity() == rarity).count();
|
||||
stats.add(new CollectionStat(collectionName, rarity, (int) owned, (int) total));
|
||||
}
|
||||
}
|
||||
return stats;
|
||||
}
|
||||
|
||||
private List<SeasonRollOverStruct> getSeasonRollovers(final Connection connection, final long profileIDHandle) {
|
||||
return List.of(); //TODO
|
||||
}
|
||||
|
||||
private Map<Boolean, List<ProfileRating>> getRatings(final Connection connection, final long profileIDHandle) throws SQLException {
|
||||
final var ratings = new ArrayList<ProfileRating>();
|
||||
final var maxRatings = new ArrayList<ProfileRating>();
|
||||
try (final var statement = connection.prepareStatement(GET_RATINGS_QUERY)) {
|
||||
statement.setLong(1, profileIDHandle);
|
||||
try (final var rs = statement.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
var i = 0;
|
||||
final var ratingName = rs.getString(++i);
|
||||
final var isMax = rs.getBoolean(++i);
|
||||
final var rank = rs.getInt(++i);
|
||||
final var rankStarts = rs.getInt(++i);
|
||||
final var rankSeen = rs.getInt(++i);
|
||||
final var rankStarsSeen = rs.getInt(++i);
|
||||
final var wins = rs.getInt(++i);
|
||||
final var losses = rs.getInt(++i);
|
||||
final var rating = new ProfileRating(RatingMode.valueOf(ratingName), rank, rankStarts, rankSeen, rankStarsSeen, wins, losses);
|
||||
if (isMax) {
|
||||
maxRatings.add(rating);
|
||||
} else {
|
||||
ratings.add(rating);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Map.of(true, maxRatings, false, ratings);
|
||||
}
|
||||
|
||||
private long getOnboardingLong(final ResultSet rs) throws SQLException {
|
||||
var result = 0L;
|
||||
for (final var type : OnboardingProgressType.values()) {
|
||||
if (rs.getBoolean(type.databaseName())) {
|
||||
result |= 1L << type.ordinal();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
boolean setOnboardingProgress(final String steamID, final OnboardingProgressType progressType) {
|
||||
insertOnboardingIfNeeded(steamID);
|
||||
try (final var connection = dataSource().getConnection();
|
||||
final var statement = connection.prepareStatement("UPDATE onboarding SET " + progressType.databaseName() + "=true WHERE player_id=(SELECT id FROM player WHERE steam_id=?)")) {
|
||||
statement.setLong(1, Long.parseLong(steamID));
|
||||
return statement.executeUpdate() > 0;
|
||||
} catch (final SQLException e) {
|
||||
logger.error("Error updating onboarding progress " + progressType + " for player " + steamID, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void insertOnboardingIfNeeded(final String steamID) {
|
||||
try (final var connection = dataSource().getConnection();
|
||||
final var statement = connection.prepareStatement("INSERT INTO onboarding (player_id) VALUES ((SELECT id FROM player WHERE steam_id=?)) ON CONFLICT DO NOTHING")) {
|
||||
statement.setLong(1, Long.parseLong(steamID));
|
||||
statement.executeUpdate();
|
||||
} catch (final SQLException e) {
|
||||
logger.error("Error inserting onboarding progress for player " + steamID, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package ch.gtache.elderscrollslegends.service.profile;
|
||||
|
||||
public enum Rarity {
|
||||
Common,
|
||||
Rare,
|
||||
Epic,
|
||||
Legendary,
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package ch.gtache.elderscrollslegends.service.profile;
|
||||
|
||||
public enum RatingMode {
|
||||
legend,
|
||||
rankedPvP,
|
||||
soloArena,
|
||||
versusArena,
|
||||
versusArenaV2,
|
||||
arenaLegend
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package ch.gtache.elderscrollslegends.service.profile;
|
||||
|
||||
public record SeasonRollOverStruct(float _timeCreated,
|
||||
RolloverStatus status,
|
||||
String ratingMode,
|
||||
RatingMode ratingMode,
|
||||
int pendingGold,
|
||||
int pendingGems,
|
||||
int pendingTickets,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.pubsub;
|
||||
|
||||
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
import ch.gtache.elderscrollslegends.service.account.AccountService;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.GET;
|
||||
@@ -30,6 +31,6 @@ public class PubSubAuthEndpoints extends BaseEndpoints {
|
||||
final var steamID = authenticateOrThrow(authentication);
|
||||
logger.info("get called by " + steamID);
|
||||
final var chatRooms = pubSubService.getChatRooms(steamID);
|
||||
return new PubSubResponse(authentication.replace("Bearer ", ""), chatRooms);
|
||||
return new PubSubResponse(ResultCode.Ok, "", authentication.replace("Bearer ", ""), chatRooms);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package ch.gtache.elderscrollslegends.service.pubsub;
|
||||
|
||||
public record PubSubResponse(String authToken, ChatRooms chatRooms) {
|
||||
import ch.gtache.elderscrollslegends.service.ResultCode;
|
||||
|
||||
public record PubSubResponse(ResultCode resultCode, String endpoint,
|
||||
String authToken, ChatRooms chatRooms) {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package ch.gtache.elderscrollslegends.service.pubsub;
|
||||
|
||||
public enum WSMessageType {
|
||||
matchready,
|
||||
logged_in_elsewhere,
|
||||
entitlements,
|
||||
purchasecompleted,
|
||||
purchasecompleted_rewardschecked,
|
||||
chatmessage,
|
||||
packages,
|
||||
matchrewards,
|
||||
rewards,
|
||||
challenge,
|
||||
quests_refresh,
|
||||
servermessage,
|
||||
inventory_refresh,
|
||||
packages_refresh,
|
||||
shop_refresh,
|
||||
campaigns_refresh,
|
||||
quests_refreshed
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package ch.gtache.elderscrollslegends.service.pubsub;
|
||||
|
||||
import io.quarkus.websockets.next.OnBinaryMessage;
|
||||
import io.quarkus.websockets.next.OnClose;
|
||||
import io.quarkus.websockets.next.OnError;
|
||||
import io.quarkus.websockets.next.OnOpen;
|
||||
import io.quarkus.websockets.next.OnPingMessage;
|
||||
import io.quarkus.websockets.next.OnPongMessage;
|
||||
import io.quarkus.websockets.next.OnTextMessage;
|
||||
import io.quarkus.websockets.next.WebSocket;
|
||||
import io.quarkus.websockets.next.WebSocketConnection;
|
||||
import io.vertx.core.buffer.Buffer;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@WebSocket(path = "/pubsubconnections")
|
||||
public class WSPubSubConnections {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(WSPubSubConnections.class);
|
||||
|
||||
@OnTextMessage
|
||||
public void onTextMessage(final String message, final WebSocketConnection webSocketConnection) {
|
||||
logger.info("Received text message: " + message);
|
||||
}
|
||||
|
||||
@OnBinaryMessage
|
||||
public void onBinaryMessage(final byte[] message, final WebSocketConnection webSocketConnection) {
|
||||
logger.info("Received binary message: " + Arrays.toString(message));
|
||||
}
|
||||
|
||||
@OnPingMessage
|
||||
public void onPingMessage(final Buffer buffer, final WebSocketConnection webSocketConnection) {
|
||||
logger.info("Received ping message : " + buffer.toString());
|
||||
}
|
||||
|
||||
@OnPongMessage
|
||||
public void onPongMessage(final Buffer buffer, final WebSocketConnection webSocketConnection) {
|
||||
logger.info("Received pong message : " + buffer.toString());
|
||||
}
|
||||
|
||||
@OnOpen
|
||||
public void onOpen(final WebSocketConnection webSocketConnection) {
|
||||
logger.info("WebSocket opened");
|
||||
}
|
||||
|
||||
@OnClose
|
||||
public void onClose(final WebSocketConnection webSocketConnection) {
|
||||
logger.info("WebSocket closed");
|
||||
}
|
||||
|
||||
@OnError
|
||||
public void onError(final Throwable error, final WebSocketConnection webSocketConnection) {
|
||||
logger.error("WebSocket error", error);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package ch.gtache.elderscrollslegends.service.quests;
|
||||
|
||||
public record QuestChoiceStruct(String questType, int questTypeHash, int numGold, int numGems, int numCardPacks,
|
||||
String cardPackType) {
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user