Skip to content

Commit

Permalink
Fix issues introduced by previous GitHubEvent serialization fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Mar 7, 2024
1 parent 38df501 commit a258fdb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<div style="clear: both"></div>
</div>
<div class="description" v-show="gitHubEvent.showPayload">
<pre>{{ gitHubEvent.parsedPayload }}</pre>
<pre>{{ gitHubEvent.payload | pretty }}</pre>
</div>
</div>
</div>
Expand Down Expand Up @@ -185,7 +185,7 @@
return;
}
gitHubEventsApp.waitForEvents = false;

let gitHubEvent = JSON.parse(message.data);
if (!gitHubEventsApp.visible) {
gitHubEvent.new = true;
Expand All @@ -208,7 +208,7 @@
},
updateEventSourceStatus: function () {
localGitHubEventsApp = gitHubEventsApp ? gitHubEventsApp : this;

if (eventSource.readyState == 0) {
localGitHubEventsApp.eventSourceStatusColor = 'ui grey button small';
localGitHubEventsApp.eventSourceStatusIcon = 'notched circle loading icon';
Expand All @@ -225,7 +225,7 @@
console.error('could not find event for ' + deliveryId);
return;
}

this.reconnectEventSource();

const gitHubEvent = gitHubEventsApp.gitHubEventsMap.get(deliveryId);
Expand Down Expand Up @@ -257,7 +257,7 @@
}

const gitHubEvent = gitHubEventsApp.gitHubEventsMap.get(deliveryId);
navigator.clipboard.writeText(JSON.stringify(gitHubEvent.parsedPayload, null, 4));
navigator.clipboard.writeText(JSON.stringify(JSON.parse(gitHubEvent.payload), null, 4));
},
markInvisible: function() {
gitHubEventsApp.visible = false;
Expand All @@ -271,6 +271,11 @@
favicon.reset();
gitHubEventsApp.visible = true;
}
},
filters: {
pretty: function(value) {
return JSON.stringify(JSON.parse(value), null, 4);
}
}
});
</script>
Expand Down
21 changes: 12 additions & 9 deletions runtime/src/main/java/io/quarkiverse/githubapp/GitHubEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class GitHubEvent {

private final String action;

private final String eventAction;

private final String payload;

private final boolean replayed;
Expand All @@ -37,6 +39,15 @@ public GitHubEvent(Long installationId, String appName, String deliveryId, Strin
this.action = action;
this.payload = payload;
this.replayed = replayed;

StringBuilder eventActionSb = new StringBuilder();
if (event != null && !event.isBlank()) {
eventActionSb.append(event);
}
if (action != null && !action.isBlank()) {
eventActionSb.append(".").append(action);
}
this.eventAction = eventActionSb.toString();
}

public Long getInstallationId() {
Expand Down Expand Up @@ -69,16 +80,8 @@ public String getAction() {
return action;
}

@JsonIgnore
public String getEventAction() {
StringBuilder sb = new StringBuilder();
if (event != null && !event.isBlank()) {
sb.append(event);
}
if (action != null && !action.isBlank()) {
sb.append(".").append(action);
}
return sb.toString();
return eventAction;
}

public String getPayload() {
Expand Down

0 comments on commit a258fdb

Please sign in to comment.