Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
@@ -1,6 +1,6 @@
{
"name": "hawk.api",
"version": "1.1.24",
"version": "1.1.25",
"main": "index.ts",
"license": "UNLICENSED",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/models/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { v4 as uuid } from 'uuid';
*/
export enum ReceiveTypes {
/**
* All notifications
* Notify if more than n error occurrences in the given period
*/
SEEN_MORE = 'SEEN_MORE',

Expand Down
32 changes: 31 additions & 1 deletion src/resolvers/project.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ReceiveTypes } from '@hawk.so/types';
import * as telegram from '../utils/telegram';
const mongo = require('../mongo');
const { ApolloError, UserInputError } = require('apollo-server-express');
Expand Down Expand Up @@ -55,7 +56,36 @@ module.exports = {
image,
};

const project = await factories.projectsFactory.create(options);
let project = await factories.projectsFactory.create(options);
const userData = await factories.usersFactory.findById(user.id);

await project.createNotificationsRule({
isEnabled: true,
whatToReceive: ReceiveTypes.SEEN_MORE,
including: [],
excluding: [],
threshold: 20,
thresholdPeriod: 3600000,
channels: {
email: {
isEnabled: true,
endpoint: userData.email,
minPeriod: 60,
},
telegram: {
isEnabled: false,
endpoint: '',
minPeriod: 60,
},
slack: {
isEnabled: false,
endpoint: '',
minPeriod: 60,
},
},
});

project = await factories.projectsFactory.findById(project._id);

/**
* Create collections for storing events and setup indexes
Expand Down
Loading