File tree Expand file tree Collapse file tree 3 files changed +37
-3
lines changed
Expand file tree Collapse file tree 3 files changed +37
-3
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " hawk.api" ,
3- "version" : " 1.1.24 " ,
3+ "version" : " 1.1.25 " ,
44 "main" : " index.ts" ,
55 "license" : " UNLICENSED" ,
66 "scripts" : {
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import { v4 as uuid } from 'uuid';
99 */
1010export enum ReceiveTypes {
1111 /**
12- * All notifications
12+ * Notify if more than n error occurrences in the given period
1313 */
1414 SEEN_MORE = 'SEEN_MORE' ,
1515
Original file line number Diff line number Diff line change 1+ import { ReceiveTypes } from '@hawk.so/types' ;
12import * as telegram from '../utils/telegram' ;
23const mongo = require ( '../mongo' ) ;
34const { ApolloError, UserInputError } = require ( 'apollo-server-express' ) ;
@@ -55,7 +56,40 @@ module.exports = {
5556 image,
5657 } ;
5758
58- const project = await factories . projectsFactory . create ( options ) ;
59+ let project = await factories . projectsFactory . create ( options ) ;
60+ const userData = await factories . usersFactory . findById ( user . id ) ;
61+
62+ try {
63+ await project . createNotificationsRule ( {
64+ isEnabled : true ,
65+ whatToReceive : ReceiveTypes . SEEN_MORE ,
66+ including : [ ] ,
67+ excluding : [ ] ,
68+ threshold : 20 ,
69+ thresholdPeriod : 3600000 ,
70+ channels : {
71+ email : {
72+ isEnabled : true ,
73+ endpoint : userData . email ,
74+ minPeriod : 60 ,
75+ } ,
76+ telegram : {
77+ isEnabled : false ,
78+ endpoint : '' ,
79+ minPeriod : 60 ,
80+ } ,
81+ slack : {
82+ isEnabled : false ,
83+ endpoint : '' ,
84+ minPeriod : 60 ,
85+ } ,
86+ } ,
87+ } ) ;
88+
89+ project = await factories . projectsFactory . findById ( project . _id ) ;
90+ } catch ( err ) {
91+ telegram . sendMessage ( `❌ Failed to enable default notifications for project ${ name } ` ) ;
92+ }
5993
6094 /**
6195 * Create collections for storing events and setup indexes
You can’t perform that action at this time.
0 commit comments