Skip to content

Commit

Permalink
electron: fix base64 mode and key order
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Aug 31, 2024
1 parent f1b6c3d commit 12b9a93
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pkg/connector/electron.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ func (gc *GVClient) runElectron(ctx context.Context) {
defer responseWaiters.Delete(reqID)
defer close(waiter)
payload := map[string]string{
"thread_id": base64.RawStdEncoding.EncodeToString(threadIDHash[:]),
"destinations": base64.RawStdEncoding.EncodeToString(recipientsHash[:]),
"message_ids": base64.RawStdEncoding.EncodeToString(messageIDHash[:]),
"thread_id": base64.StdEncoding.EncodeToString(threadIDHash[:]),
"destinations": base64.StdEncoding.EncodeToString(recipientsHash[:]),
"message_ids": base64.StdEncoding.EncodeToString(messageIDHash[:]),
}
zerolog.Ctx(ctx).Debug().
Str("req_id", reqID).
Expand Down
7 changes: 4 additions & 3 deletions pkg/connector/electron.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ const loadScript = ({script_source, checksum}) => {
})
}

const executeScript = ({payload, program, global_name}) => {
console.log("Executing", window.globalName, "with", payload)
const executeScript = ({payload: {message_ids, destinations, thread_id}, program, global_name}) => {
const reorderedPayload = { message_ids, destinations, thread_id }
console.log("Executing", global_name, "with", reorderedPayload)
return new Promise((resolve, reject) => {
new Promise(resolve => {
window[global_name].a(program, (fn1, fn2, fn3, fn4) => {
Expand All @@ -46,7 +47,7 @@ const executeScript = ({payload, program, global_name}) => {
}).then(fns => {
fns.fn1(result => {
resolve(result)
}, [payload, undefined, undefined, undefined])
}, [reorderedPayload, undefined, undefined, undefined])
}, reject)
})
}
Expand Down

0 comments on commit 12b9a93

Please sign in to comment.