Add plan & latest product ver to licenses

This commit is contained in:
Braydon 2023-12-02 03:52:57 -05:00
parent f32a92fe54
commit c6f968851a
7 changed files with 44 additions and 2 deletions

@ -141,6 +141,8 @@ public final class LicenseClient {
JsonElement description = json.get("description"); JsonElement description = json.get("description");
JsonElement ownerSnowflake = json.get("ownerSnowflake"); JsonElement ownerSnowflake = json.get("ownerSnowflake");
JsonElement ownerName = json.get("ownerName"); JsonElement ownerName = json.get("ownerName");
JsonElement plan = json.get("plan");
JsonElement latestVersion = json.get("latestVersion");
// Parsing the expiration date if we have one // Parsing the expiration date if we have one
JsonElement expires = json.get("expires"); JsonElement expires = json.get("expires");
@ -155,6 +157,8 @@ public final class LicenseClient {
description.isJsonNull() ? null : description.getAsString(), description.isJsonNull() ? null : description.getAsString(),
ownerSnowflake.isJsonNull() ? -1 : ownerSnowflake.getAsLong(), ownerSnowflake.isJsonNull() ? -1 : ownerSnowflake.getAsLong(),
ownerName.isJsonNull() ? null : ownerName.getAsString(), ownerName.isJsonNull() ? null : ownerName.getAsString(),
plan.getAsString(),
latestVersion.getAsString(),
expires.isJsonNull() ? null : expiresDate expires.isJsonNull() ? null : expiresDate
); );
} else { } else {
@ -292,6 +296,16 @@ public final class LicenseClient {
*/ */
private String ownerName; private String ownerName;
/**
* The plan for this license.
*/
@NonNull private String plan;
/**
* The latest version of the product this license is for.
*/
@NonNull private String latestVersion;
/** /**
* The optional expiration {@link Date} of the license. * The optional expiration {@link Date} of the license.
*/ */

@ -18,10 +18,12 @@ public final class Main {
System.err.println("Invalid license: " + response.getError()); System.err.println("Invalid license: " + response.getError());
return; return;
} }
System.out.println("response = " + response);
// License is valid // License is valid
System.out.println("License is valid!"); System.out.println("License is valid!");
if (response.getOwnerName() != null) { if (response.getOwnerName() != null) {
System.out.println("Welcome " + response.getOwnerName() + "!"); System.out.println("Welcome " + response.getOwnerName() + "! Your plan is " + response.getPlan() + " and the latest version is " + response.getLatestVersion());
} }
if (response.getDescription() != null) { if (response.getDescription() != null) {
System.out.println("Description: " + response.getDescription()); // License description System.out.println("Description: " + response.getDescription()); // License description

@ -101,6 +101,8 @@ public final class LicenseController {
license.getDescription(), license.getDescription(),
license.getOwnerSnowflake(), license.getOwnerSnowflake(),
license.getOwnerName(), license.getOwnerName(),
license.getPlan(),
license.getLatestVersion(),
license.getExpires() license.getExpires()
)); ));
} catch (APIException ex) { // Handle the exception } catch (APIException ex) { // Handle the exception

@ -7,6 +7,7 @@ package me.braydon.license.dto;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull;
import lombok.ToString; import lombok.ToString;
import me.braydon.license.model.License; import me.braydon.license.model.License;
@ -40,6 +41,16 @@ public class LicenseDTO {
*/ */
private String ownerName; private String ownerName;
/**
* The plan for this license.
*/
@NonNull private String plan;
/**
* The latest version of the product this license is for.
*/
@NonNull private String latestVersion;
/** /**
* The optional expiration {@link Date} of this license. * The optional expiration {@link Date} of this license.
*/ */

@ -62,6 +62,16 @@ public class License {
@Field("owner.name") @Field("owner.name")
private String ownerName; private String ownerName;
/**
* The plan for this license.
*/
@NonNull private String plan;
/**
* The latest version of the product this license is for.
*/
@NonNull private String latestVersion;
/** /**
* The amount of uses this license has. * The amount of uses this license has.
*/ */

@ -63,7 +63,7 @@ public final class DiscordService {
/** /**
* The version of this Springboot application. * The version of this Springboot application.
*/ */
@NonNull private String applicationVersion = "n/a"; @NonNull private final String applicationVersion = "n/a";
/** /**
* The salt to use for hashing license keys. * The salt to use for hashing license keys.
@ -317,6 +317,7 @@ public final class DiscordService {
expires == -1L ? "Never" : "<t:" + expires + ":R>", expires == -1L ? "Never" : "<t:" + expires + ":R>",
true true
) )
.addField("Plan", license.getPlan(), true)
.addField("Uses", String.valueOf(license.getUses()), true) .addField("Uses", String.valueOf(license.getUses()), true)
.addField("Last Used", .addField("Last Used",
lastUsed == -1L ? "Never" : "<t:" + lastUsed + ":R>", lastUsed == -1L ? "Never" : "<t:" + lastUsed + ":R>",

@ -106,6 +106,8 @@ public final class LicenseService {
license.setDescription(description); // Use the given description, if any license.setDescription(description); // Use the given description, if any
license.setOwnerSnowflake(ownerSnowflake); license.setOwnerSnowflake(ownerSnowflake);
license.setOwnerName(ownerName); license.setOwnerName(ownerName);
license.setPlan("Basic");
license.setLatestVersion("1.0");
license.setIps(new HashSet<>()); license.setIps(new HashSet<>());
license.setHwids(new HashSet<>()); license.setHwids(new HashSet<>());
license.setIpLimit(ipLimit); // Use the given IP limit license.setIpLimit(ipLimit); // Use the given IP limit