Skip to content

Commit

Permalink
App: Avoid some deserialization issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
e3ndr committed Jul 26, 2024
1 parent cef122f commit 2a2b954
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ public static class Command {
private Action responseAction; // Must be EXECUTE on ALWAYS
private String response;

@JsonDeserializationMethod("platform")
private void $deserialize_platform(JsonElement e) {
// Thanks JavaScript.
if (e.isJsonString()) {
String str = e.getAsString();
if (!str.equalsIgnoreCase("null")) {
this.platform = UserPlatform.valueOf(str);
}
} // Otherwise, null
}

@JsonDeserializationMethod("type")
private void $migrate_trigger(JsonElement e) {
switch (e.getAsString()) {
Expand Down Expand Up @@ -72,6 +83,17 @@ public static class Shout {
private Action responseAction;
private String response;

@JsonDeserializationMethod("platform")
private void $deserialize_platform(JsonElement e) {
// Thanks JavaScript.
if (e.isJsonString()) {
String str = e.getAsString();
if (!str.equalsIgnoreCase("null")) {
this.platform = UserPlatform.valueOf(str);
}
} // Otherwise, null
}

@JsonDeserializationMethod("text")
private void $migrate_response(JsonElement e) {
this.responseAction = Action.REPLY_WITH;
Expand Down

0 comments on commit 2a2b954

Please sign in to comment.