Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • svdh/ocm-engine
1 result
Show changes
Commits on Source (2)
......@@ -3,6 +3,13 @@
All notable changes to this project will be documented in this file. See
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.24.2](https://code.vereign.com/gaiax/ocm/ocm-engine/compare/v1.24.1...v1.24.2) (2024-02-22)
### Bug Fixes
* add topic type to each webhook ([b8a1520](https://code.vereign.com/gaiax/ocm/ocm-engine/commit/b8a15207f59f30c8e3e3f9355aa9dc8ad21c8b74))
## [1.24.1](https://code.vereign.com/gaiax/ocm/ocm-engine/compare/v1.24.0...v1.24.1) (2024-02-21)
......
......@@ -599,10 +599,10 @@ export const attachDidWebHandler = (
}
});
};
export const webHookHandler = async (
export const webHookHandler = async <T>(
addr: string,
ev: TrustPingResponseReceivedEvent,
webHookTopic: string,
payload: T,
) => {
const promises: Promise<AxiosResponse>[] = [];
......@@ -611,18 +611,11 @@ export const webHookHandler = async (
for (const pair of tokenUrlPairs) {
const [token, url] = pair.split("@");
const promise = axios.post(
url,
{
thid: ev.payload.message.threadId,
connectionId: ev.payload.connectionRecord.id,
const promise = axios.post(`${url}/topic/${webHookTopic}`, payload, {
headers: {
"X-Api-Key": token,
},
{
headers: {
"X-Api-Key": token,
},
},
);
});
promises.push(promise);
}
......@@ -634,10 +627,10 @@ export const webHookHandler = async (
if (promiseResult.status === "rejected") {
console.log(
`Failed to send web hook to ${url}. Reason ${promiseResult.reason}`,
`Failed to send web hook to ${url}/topic/${webHookTopic}. Reason ${promiseResult.reason}`,
);
continue;
}
console.log(`Successfully sent web hook to ${url}`);
console.log(`Successfully sent web hook to ${url}/topic/${webHookTopic}`);
}
};
......@@ -73,7 +73,10 @@ export class AgentEventListenerService implements OnModuleInit {
throw new Error("Agent config is missing agentWebHook");
}
return webHookHandler(this.agentConfig?.agentWebHook, ev);
return webHookHandler(this.agentConfig?.agentWebHook, "ping", {
thid: ev.payload.message.threadId,
connectionId: ev.payload.connectionRecord.id,
});
},
);
}
......