mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-23 07:42:10 +00:00
add notification rule
This commit is contained in:
parent
9dfdd0841f
commit
4d7ddf7be1
@ -47,6 +47,8 @@ import MailService from './MailService';
|
||||
import logger from '../Utils/Logger';
|
||||
import Email from 'Common/Types/Email';
|
||||
import EmailTemplateType from 'Common/Types/Email/EmailTemplateType';
|
||||
import UserService from './UserService';
|
||||
import UserNotificationRuleService from './UserNotificationRuleService';
|
||||
|
||||
export class Service extends DatabaseService<Model> {
|
||||
public constructor(postgresDatabase?: PostgresDatabase) {
|
||||
@ -324,15 +326,15 @@ export class Service extends DatabaseService<Model> {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
createdItem = await this.addDefaultIncidentSeverity(createdItem);
|
||||
createdItem = await this.addDefaultProjectTeams(createdItem);
|
||||
createdItem = await this.addDefaultMonitorStatus(createdItem);
|
||||
createdItem = await this.addDefaultIncidentState(createdItem);
|
||||
createdItem = await this.addDefaultScheduledMaintenanceState(
|
||||
createdItem
|
||||
);
|
||||
createdItem = await this.addDefaultIncidentSeverity(createdItem);
|
||||
|
||||
|
||||
return createdItem;
|
||||
}
|
||||
|
||||
@ -604,6 +606,21 @@ export class Service extends DatabaseService<Model> {
|
||||
createdItem.createdByUserId!
|
||||
);
|
||||
|
||||
const user: User | null = await UserService.findOneById({
|
||||
id: createdItem.createdByUserId!,
|
||||
props: {
|
||||
isRoot: true,
|
||||
},
|
||||
select:{
|
||||
isEmailVerified: true,
|
||||
email: true
|
||||
}
|
||||
});
|
||||
|
||||
if(user && user.isEmailVerified){
|
||||
await UserNotificationRuleService.addDefaultNotifictionRuleForUser(createdItem.id!, user.id!, user.email!);
|
||||
}
|
||||
|
||||
return createdItem;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ import logger from '../Utils/Logger';
|
||||
import BadDataException from 'Common/Types/Exception/BadDataException';
|
||||
import PositiveNumber from 'Common/Types/PositiveNumber';
|
||||
import TeamMember from 'Model/Models/TeamMember';
|
||||
import UserNotificationRuleService from './UserNotificationRuleService';
|
||||
|
||||
export class TeamMemberService extends DatabaseService<TeamMember> {
|
||||
public constructor(postgresDatabase?: PostgresDatabase) {
|
||||
@ -153,6 +154,10 @@ export class TeamMemberService extends DatabaseService<TeamMember> {
|
||||
},
|
||||
select: {
|
||||
userId: true,
|
||||
user: {
|
||||
email: true,
|
||||
isEmailVerified: true,
|
||||
},
|
||||
projectId: true,
|
||||
},
|
||||
limit: LIMIT_MAX,
|
||||
@ -165,6 +170,10 @@ export class TeamMemberService extends DatabaseService<TeamMember> {
|
||||
|
||||
for (const item of items) {
|
||||
await this.refreshTokens(item.userId!, item.projectId!);
|
||||
|
||||
if(updateBy.data.hasAcceptedInvitation && item.user?.isEmailVerified) {
|
||||
await UserNotificationRuleService.addDefaultNotifictionRuleForUser(item.projectId!, item.userId!, item.user?.email!);
|
||||
}
|
||||
}
|
||||
|
||||
return { updateBy, carryForward: onUpdate.carryForward };
|
||||
|
@ -103,6 +103,7 @@ export class Service extends DatabaseService<Model> {
|
||||
await TeamMemberService.findBy({
|
||||
query: {
|
||||
userId: user.id!,
|
||||
hasAcceptedInvitation: true
|
||||
},
|
||||
select: {
|
||||
projectId: true,
|
||||
|
Loading…
Reference in New Issue
Block a user