Skip to content
Merged
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hawk.api",
"version": "1.1.25",
"version": "1.1.26",
"main": "index.ts",
"license": "UNLICENSED",
"scripts": {
Expand Down Expand Up @@ -37,7 +37,7 @@
"@graphql-tools/schema": "^8.5.1",
"@graphql-tools/utils": "^8.9.0",
"@hawk.so/nodejs": "^3.1.1",
"@hawk.so/types": "^0.1.28",
"@hawk.so/types": "^0.1.31",
"@types/amqp-connection-manager": "^2.0.4",
"@types/bson": "^4.0.5",
"@types/debug": "^4.1.5",
Expand Down
7 changes: 6 additions & 1 deletion src/models/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,9 @@ export default class ProjectModel extends AbstractModel<ProjectDBScheme> impleme
/**
* Creates new notification rule and add it to start of the array of notifications rules
* @param payload - rule data to save
* @param isAutoAdded - true when rule is created automatically (on project creation or conversion of old projects)
*/
public async createNotificationsRule(payload: CreateProjectNotificationsRulePayload): Promise<ProjectNotificationsRuleDBScheme> {
public async createNotificationsRule(payload: CreateProjectNotificationsRulePayload, isAutoAdded = false): Promise<ProjectNotificationsRuleDBScheme> {
const rule: ProjectNotificationsRuleDBScheme = {
_id: new ObjectId(),
uidAdded: new ObjectId(payload.uidAdded),
Expand All @@ -247,6 +248,10 @@ export default class ProjectModel extends AbstractModel<ProjectDBScheme> impleme
excluding: payload.excluding,
};

if (isAutoAdded) {
rule.autoAdded = '$$NOW';
}

if (rule.whatToReceive === ReceiveTypes.SEEN_MORE) {
rule.threshold = payload.threshold;
rule.thresholdPeriod = payload.thresholdPeriod;
Expand Down
3 changes: 2 additions & 1 deletion src/resolvers/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ module.exports = {

try {
await project.createNotificationsRule({
uidAdded: user.id,
isEnabled: true,
whatToReceive: ReceiveTypes.SEEN_MORE,
including: [],
Expand All @@ -84,7 +85,7 @@ module.exports = {
minPeriod: 60,
},
},
});
}, true);

project = await factories.projectsFactory.findById(project._id);
} catch (err) {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,10 @@
dependencies:
"@types/mongodb" "^3.5.34"

"@hawk.so/types@^0.1.28":
version "0.1.28"
resolved "https://registry.yarnpkg.com/@hawk.so/types/-/types-0.1.28.tgz#a479f411a4ae1855a6661084fa4396c7f323b170"
integrity sha512-W8xNlbkQuffwhVn/ja5Bo4EglN0waSM0Rx3R+jGmcrbYi1a4g6kGPQFYkMSd0WadikOH1nd9NrfmyJB9cVOBWA==
"@hawk.so/types@^0.1.31":
version "0.1.31"
resolved "https://registry.yarnpkg.com/@hawk.so/types/-/types-0.1.31.tgz#fba2c3451e927558bfcc3b1d942baaf8e72ad214"
integrity sha512-o1LeA3JVIUPRSIZegKwAdl4noQ1KYxwr80eisJMlghP9knu6PbYw20rIMyan5qQ3epOWs8gO1CU3iwHZprFiCg==
dependencies:
"@types/mongodb" "^3.5.34"

Expand Down
Loading