Skip to content

Commit

Permalink
feat: allow injection of dynamic proposal ID in webhook url
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Jul 15, 2023
1 parent 611802c commit c3c62b1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ export async function sendEvent(event, to, method = 'POST') {
event.token = sha256(`${to}${serviceEventsSalt}`);
event.secret = sha256(`${to}${serviceEventsSalt}`);
const headerSecret = sha256(`${to}${process.env.SERVICE_EVENTS_SALT}`);
const url = to.replace('[PROPOSAL-ID]', event.id.split('/')[1]);
try {
const res = await fetch(to, {
const res = await fetch(url, {
method,
headers: {
'Content-Type': 'application/json',
Expand All @@ -83,7 +84,7 @@ export async function sendEvent(event, to, method = 'POST') {
});
return res.text();
} catch (error) {
console.log('[events] Error sending event data to webhook', to, JSON.stringify(error));
console.log('[events] Error sending event data to webhook', url, JSON.stringify(error));
return;
}
}
Expand Down

0 comments on commit c3c62b1

Please sign in to comment.