File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -235,8 +235,9 @@ export default class ProjectModel extends AbstractModel<ProjectDBScheme> impleme
235235 /**
236236 * Creates new notification rule and add it to start of the array of notifications rules
237237 * @param payload - rule data to save
238+ * @param isAutoAdded - true when rule is created automatically (on project creation or conversion of old projects)
238239 */
239- public async createNotificationsRule ( payload : CreateProjectNotificationsRulePayload ) : Promise < ProjectNotificationsRuleDBScheme > {
240+ public async createNotificationsRule ( payload : CreateProjectNotificationsRulePayload , isAutoAdded : boolean = false ) : Promise < ProjectNotificationsRuleDBScheme > {
240241 const rule : ProjectNotificationsRuleDBScheme = {
241242 _id : new ObjectId ( ) ,
242243 uidAdded : new ObjectId ( payload . uidAdded ) ,
@@ -246,6 +247,10 @@ export default class ProjectModel extends AbstractModel<ProjectDBScheme> impleme
246247 including : payload . including ,
247248 excluding : payload . excluding ,
248249 } ;
250+
251+ if ( isAutoAdded ) {
252+ rule . autoAdded = '$$NOW' ;
253+ }
249254
250255 if ( rule . whatToReceive === ReceiveTypes . SEEN_MORE ) {
251256 rule . threshold = payload . threshold ;
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ module.exports = {
6161
6262 try {
6363 await project . createNotificationsRule ( {
64+ uidAdded : user . id ,
6465 isEnabled : true ,
6566 whatToReceive : ReceiveTypes . SEEN_MORE ,
6667 including : [ ] ,
@@ -84,7 +85,7 @@ module.exports = {
8485 minPeriod : 60 ,
8586 } ,
8687 } ,
87- } ) ;
88+ } , true ) ;
8889
8990 project = await factories . projectsFactory . findById ( project . _id ) ;
9091 } catch ( err ) {
You can’t perform that action at this time.
0 commit comments