Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@appquality/tryber-database": "^0.46.4",
"@appquality/tryber-database": "^0.46.9",
"@appquality/wp-auth": "^1.0.7",
"@aws-crypto/sha256-js": "^5.2.0",
"@aws-sdk/hash-node": "^3.374.0",
Expand Down
22 changes: 15 additions & 7 deletions src/reference/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6048,6 +6048,7 @@ paths:
- string
notes: string
notify_everyone: 0
ux_notify: 1
outOfScope: string
productLink: string
productType: 0
Expand All @@ -6068,8 +6069,10 @@ paths:
schema:
allOf:
- $ref: '#/components/schemas/DossierCreationData'
- properties:
- type: object
properties:
duplicate:
type: object
properties:
campaign:
type: integer
Expand All @@ -6083,9 +6086,8 @@ paths:
type: integer
useCases:
type: integer
type: object
type: object
- properties:
- type: object
properties:
autoApply:
maximum: 1
minimum: 0
Expand Down Expand Up @@ -6115,14 +6117,20 @@ paths:
maximum: 1
minimum: 0
type: integer
type: object
- properties:
- type: object
properties:
notify_everyone:
default: 0
enum:
- 0
- 1
type: object
ux_notify:
type: integer
x-stoplight:
id: 0gogh4w9jbf6i
minimum: 0
maximum: 1
example: 1
responses:
'201':
content:
Expand Down
27 changes: 27 additions & 0 deletions src/routes/dossiers/_post/creation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1362,5 +1362,32 @@ describe("Route POST /dossiers", () => {
])
);
});

it("Should insert send_ux_notification = 1 if ux_notify = 1 is passed", async () => {
const postResponse = await request(app)
.post("/dossiers")
.set("authorization", "Bearer admin")
.send({ ...baseRequest, ux_notify: 1 });

const data = await tryber.tables.WpAppqEvdCampaign.do()
.select("send_ux_notification")
.where({ id: postResponse.body.id })
.first();

expect(data).toHaveProperty("send_ux_notification", 1);
});

it("Should insert send_ux_notification = 0 if ux_notify is not passed", async () => {
const postResponse = await request(app)
.post("/dossiers")
.set("authorization", "Bearer admin")
.send({ ...baseRequest });
const data = await tryber.tables.WpAppqEvdCampaign.do()
.select("send_ux_notification")
.where({ id: postResponse.body.id })
.first();

expect(data).toHaveProperty("send_ux_notification", 0);
});
});
});
20 changes: 19 additions & 1 deletion src/routes/dossiers/_post/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ export default class PostDossiers extends UserRoute<{
}

protected async prepare(): Promise<void> {
const { skipPagesAndTasks, bugLanguage, notify_everyone } = this.getBody();
const { skipPagesAndTasks, bugLanguage, notify_everyone, ux_notify } =
this.getBody();

try {
const campaignId = await this.createCampaign();
Expand All @@ -121,6 +122,10 @@ export default class PostDossiers extends UserRoute<{
await this.setupNotifications(campaignId);
}

if (ux_notify === 1) {
await this.enableUXTaskNotifications(campaignId);
}

const webhook = new WebhookTrigger({
type: "campaign_created",
data: {
Expand Down Expand Up @@ -894,6 +899,19 @@ export default class PostDossiers extends UserRoute<{
}
}

private async enableUXTaskNotifications(campaignId: number) {
try {
await tryber.tables.WpAppqEvdCampaign.do()
.update({
send_ux_notification: 1,
})
.where("id", campaignId);
} catch (error) {
console.error("Error enabling UX task notifications:", error);
return;
}
}

private async retrieveProjectAndWorkspaceUsers(): Promise<
{ users: { id: number }[] } | undefined
> {
Expand Down
2 changes: 2 additions & 0 deletions src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2994,6 +2994,8 @@ export interface operations {
} & {
/** @enum {undefined} */
notify_everyone?: 0 | 1;
/** @example 1 */
ux_notify?: number;
};
};
};
Expand Down
38 changes: 19 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
"@babel/parser" "^7.22.5"
"@babel/traverse" "^7.22.5"

"@appquality/tryber-database@^0.46.4":
version "0.46.4"
resolved "https://registry.yarnpkg.com/@appquality/tryber-database/-/tryber-database-0.46.4.tgz#5ff0c9459aa19a7428b2817d00618971e70df3a4"
integrity sha512-ohjjM8lwEHQaO+Tk9k5irJF3mUAEZ/Sm4E1e7w8FpC3OmFUuQhXQgY4zVKa+BdBYAXm/ADErgfzdQ2FXrupSuA==
"@appquality/tryber-database@^0.46.9":
version "0.46.9"
resolved "https://registry.yarnpkg.com/@appquality/tryber-database/-/tryber-database-0.46.9.tgz#a3e600157144828f2aa82672e82d0fee177e0069"
integrity sha512-uXknjuEU1VevX1ozv47j0rK6wqK7DgCzEYG1gbQNs1NXVrFb9X+tR82BmTMiBP1FY3Aqov5Zu61KvoZw9zvDww==
dependencies:
better-sqlite3 "^8.1.0"
knex "^2.5.1"
better-sqlite3 "^12.5.0"
knex "^3.1.0"
mysql "^2.18.1"

"@appquality/wp-auth@^1.0.7":
Expand Down Expand Up @@ -2415,10 +2415,10 @@ better-sqlite3@^11.9.1:
bindings "^1.5.0"
prebuild-install "^7.1.1"

better-sqlite3@^8.1.0:
version "8.7.0"
resolved "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-8.7.0.tgz#bcc341856187b1d110a8a47234fa89c48c8ef538"
integrity sha512-99jZU4le+f3G6aIl6PmmV0cxUIWqKieHxsiF7G34CVFiE+/UabpYqkU0NJIkY/96mQKikHeBjtR27vFfs5JpEw==
better-sqlite3@^12.5.0:
version "12.5.0"
resolved "https://registry.yarnpkg.com/better-sqlite3/-/better-sqlite3-12.5.0.tgz#c570873d9635b5d56baa52f7e72634c2c589f35f"
integrity sha512-WwCZ/5Diz7rsF29o27o0Gcc1Du+l7Zsv7SYtVPG0X3G/uUI1LqdxrQI7c9Hs2FWpqXXERjW9hp6g3/tH7DlVKg==
dependencies:
bindings "^1.5.0"
prebuild-install "^7.1.1"
Expand Down Expand Up @@ -4724,10 +4724,10 @@ kleur@^3.0.3:
resolved "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz"
integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==

knex@^2.5.1:
version "2.5.1"
resolved "https://registry.npmjs.org/knex/-/knex-2.5.1.tgz#a6c6b449866cf4229f070c17411f23871ba52ef9"
integrity sha512-z78DgGKUr4SE/6cm7ku+jHvFT0X97aERh/f0MUKAKgFnwCYBEW4TFBqtHWFYiJFid7fMrtpZ/gxJthvz5mEByA==
knex@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/knex/-/knex-3.1.0.tgz#b6ddd5b5ad26a6315234a5b09ec38dc4a370bd8c"
integrity sha512-GLoII6hR0c4ti243gMs5/1Rb3B+AjwMOfjYm97pu0FOQa7JH56hgBxYf5WK2525ceSbBY1cjeZ9yk99GPMB6Kw==
dependencies:
colorette "2.0.19"
commander "^10.0.0"
Expand All @@ -4738,7 +4738,7 @@ knex@^2.5.1:
getopts "2.3.0"
interpret "^2.2.0"
lodash "^4.17.21"
pg-connection-string "2.6.1"
pg-connection-string "2.6.2"
rechoir "^0.8.0"
resolve-from "^5.0.0"
tarn "^3.0.2"
Expand Down Expand Up @@ -5575,10 +5575,10 @@ path-type@^4.0.0:
resolved "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz"
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==

pg-connection-string@2.6.1:
version "2.6.1"
resolved "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.6.1.tgz#78c23c21a35dd116f48e12e23c0965e8d9e2cbfb"
integrity sha512-w6ZzNu6oMmIzEAYVw+RLK0+nqHPt8K3ZnknKi+g48Ak2pr3dtljJW3o+D/n2zzCG07Zoe9VOX3aiKpj+BN0pjg==
pg-connection-string@2.6.2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.6.2.tgz#713d82053de4e2bd166fab70cd4f26ad36aab475"
integrity sha512-ch6OwaeaPYcova4kKZ15sbJ2hKb/VP48ZD2gE7i1J+L4MspCtBMAx8nMgz7bksc7IojCIIWuEhHibSMFH8m8oA==

php-serialize@^4.1.1:
version "4.1.1"
Expand Down
Loading