Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility for attributes and message example #15

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main

env:
IMAGE_NAME: ghcr.io/neoscript/pubsub-emulator-ui:latest
IMAGE_NAME: ghcr.io/neoscript/pubsub-emulator-ui:v1.1.1

jobs:
push:
Expand Down
16 changes: 16 additions & 0 deletions webapp/exampleMessage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"data": {
"name": "projects/.../../...",
"createTime": "2023-11-14T17:37:39.884736Z",
"furtherObjects": "ENABLED",
"furtherObjects2": {
"furtherSubObjects": {}
},
"furtherObjects3": "\"160a203e401ec0\"",
"furtherObjects4": true
},
"attributes": {
"pubSubMessageAttributes": "projects/175091777038/secrets/env",
"versionId": "projects/.../../..."
}
}
16 changes: 13 additions & 3 deletions webapp/src/app/components/projects/projects.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,19 @@ export class ProjectsComponent implements OnInit {

handlePublishRequest(event: { topic: Topic, message: string }) {
console.log("publish message request:", event.message)

const pubsubMessage: PubsubMessage = {
data: btoa(event.message)
let messObj;
try{ messObj = JSON.parse(event.message); }
catch(error) { console.log("Message is not JSON Object thus old logic is used") };
let pubsubMessage: PubsubMessage;
if( messObj?.data !== undefined ){
pubsubMessage = {
data: btoa(JSON.stringify(messObj?.data)),
attributes: messObj?.attributes
};
} else {
pubsubMessage = {
data: btoa(event.message)
}
}

this.pubsub.publishMessages(event.topic.name, [pubsubMessage]).subscribe(result => {
Expand Down