Skip to content

Commit

Permalink
Fix types. Add contractID to message
Browse files Browse the repository at this point in the history
  • Loading branch information
corrideat committed Nov 30, 2024
1 parent ec2d5d7 commit 99aa0c0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ sbp('sbp/selectors/register', {
},
'backend/server/broadcastEntry': async function (deserializedHEAD: Object, entry: string) {
const pubsub = sbp('okTurtles.data/get', PUBSUB_INSTANCE)
const pubsubMessage = createMessage(NOTIFICATION_TYPE.ENTRY, entry)
const pubsubMessage = createMessage(NOTIFICATION_TYPE.ENTRY, entry, { contractID: deserializedHEAD.contractID })
const subscribers = pubsub.enumerateSubscribers(deserializedHEAD.contractID)
console.debug(chalk.blue.bold(`[pubsub] Broadcasting ${deserializedHEAD.description()}`))
await pubsub.broadcast(pubsubMessage, { to: subscribers })
Expand Down
2 changes: 1 addition & 1 deletion shared/declarations.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Have the script explain which files represent what.

// Our globals.
declare function fetchServerTime(): Promise<string>
declare function fetchServerTime(fallback: ?boolean): Promise<string>
declare var logger: Object
// Nodejs globals.
declare var process: any
Expand Down
4 changes: 2 additions & 2 deletions shared/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ export function createClient (url: string, options?: Object = {}): PubSubClient
return client
}

export function createMessage (type: string, data: JSONType): string {
return JSON.stringify({ type, data })
export function createMessage (type: string, data: JSONType, meta: ?Object): string {
return JSON.stringify({ ...meta, type, data })
}

export function createKvMessage (channelID: string, key: string, data: JSONType): string {
Expand Down

0 comments on commit 99aa0c0

Please sign in to comment.