Skip to content

Commit b0b61a7

Browse files
authored
Refactor connection types to be used across application. (#1095)
* changelog * Fixup * lint
1 parent c298430 commit b0b61a7

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

changelog.d/1095.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a case where outbound webhooks would not work if you had not enabled openproject (due to a mixed up config check).

src/Connections/GenericHook.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ export class GenericHookConnection
243243
event: StateEvent<Record<string, unknown>>,
244244
{ as, intent, config, messageClient, storage }: InstantiateConnectionOpts,
245245
) {
246-
if (!config.generic?.outbound) {
246+
if (!config.generic?.enabled) {
247247
throw Error("Generic webhooks are not configured");
248248
}
249249
// Generic hooks store the hookId in the account data
@@ -294,7 +294,7 @@ export class GenericHookConnection
294294
data: Partial<Record<keyof GenericHookConnectionState, unknown>> = {},
295295
{ as, intent, config, messageClient, storage }: ProvisionConnectionOpts,
296296
) {
297-
if (!config.generic) {
297+
if (!config.generic?.enabled) {
298298
throw Error("Generic Webhooks are not configured");
299299
}
300300
const hookId = randomUUID();

tests/config/config.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import { DefaultConfigRoot } from "../../src/config/Defaults";
33
import { expect } from "chai";
44
import { ConnectionType } from "../../src/Connections/type";
55

6+
const minimalConfig = {
7+
bridge: DefaultConfigRoot.bridge,
8+
logging: DefaultConfigRoot.logging,
9+
passFile: DefaultConfigRoot.passFile,
10+
};
11+
612
describe("Config/BridgeConfig", () => {
713
describe("will handle the legacy queue.monolitihc option", () => {
814
it("with no parameters", () => {
@@ -101,17 +107,7 @@ describe("Config/BridgeConfig", () => {
101107
});
102108
});
103109

104-
/**
105-
Jira = "jira",
106-
OpenProject = "openproject",
107-
*/
108-
109110
describe("publicConfig", () => {
110-
const minimalConfig = {
111-
bridge: DefaultConfigRoot.bridge,
112-
logging: DefaultConfigRoot.logging,
113-
passFile: DefaultConfigRoot.passFile,
114-
};
115111
it("for ChallengeHound", async () => {
116112
const config = new BridgeConfig({
117113
...minimalConfig,
@@ -121,6 +117,7 @@ describe("Config/BridgeConfig", () => {
121117
await config.getPublicConfigForService(ConnectionType.ChallengeHound),
122118
).to.deep.equal({});
123119
});
120+
124121
it("for Feeds", async () => {
125122
const config = new BridgeConfig({
126123
...minimalConfig,
@@ -130,6 +127,7 @@ describe("Config/BridgeConfig", () => {
130127
await config.getPublicConfigForService(ConnectionType.Feeds),
131128
).to.deep.equal({ pollIntervalSeconds: 150 });
132129
});
130+
133131
it("for Figma", async () => {
134132
const config = new BridgeConfig({
135133
...minimalConfig,
@@ -144,6 +142,7 @@ describe("Config/BridgeConfig", () => {
144142
await config.getPublicConfigForService(ConnectionType.Figma),
145143
).to.deep.equal({});
146144
});
145+
147146
it("for Generic (inbound)", async () => {
148147
const config = new BridgeConfig({
149148
...minimalConfig,
@@ -165,6 +164,7 @@ describe("Config/BridgeConfig", () => {
165164
waitForComplete: undefined,
166165
});
167166
});
167+
168168
it("for Generic (outbound)", async () => {
169169
const config = new BridgeConfig({
170170
...minimalConfig,
@@ -181,6 +181,7 @@ describe("Config/BridgeConfig", () => {
181181
await config.getPublicConfigForService(ConnectionType.GenericOutbound),
182182
).to.deep.equal({});
183183
});
184+
184185
it("for Github", async () => {
185186
const config = new BridgeConfig({
186187
...minimalConfig,
@@ -202,6 +203,7 @@ describe("Config/BridgeConfig", () => {
202203
newInstallationUrl: undefined,
203204
});
204205
});
206+
205207
it("for Gitlab", async () => {
206208
const config = new BridgeConfig({
207209
...minimalConfig,
@@ -223,6 +225,7 @@ describe("Config/BridgeConfig", () => {
223225
userIdPrefix: "_foobar_",
224226
});
225227
});
228+
226229
it("for Jira", async () => {
227230
const config = new BridgeConfig({
228231
...minimalConfig,
@@ -236,6 +239,7 @@ describe("Config/BridgeConfig", () => {
236239
await config.getPublicConfigForService(ConnectionType.Jira),
237240
).to.deep.equal({});
238241
});
242+
239243
it("for OpenProject", async () => {
240244
const config = new BridgeConfig({
241245
...minimalConfig,

0 commit comments

Comments
 (0)