Skip to content

πŸ“ˆ Open source, privacy-first web analytics β€” a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

some crucial fixes

Blue Mouse8a1a8165dc06
diff --git a/src/alert/alert.controller.ts b/src/alert/alert.controller.ts
index cc03b2cb7..dfbdc1573 100644
--- a/src/alert/alert.controller.ts
+++ b/src/alert/alert.controller.ts
@@ -87,14 +87,14 @@ export class AlertController {
const project = await this.projectService.findOneWhere({
id: alertDTO.pid,
}, {
- relations: ['alerts'],
+ relations: ['alerts', 'admin'],
})
if (_isEmpty(project)) {
throw new NotFoundException('Project not found')
}
- this.projectService.allowedToManage(project, uid, user.roles, 'You are not allowed to manage this project')
+ this.projectService.allowedToManage(project, uid, user.roles, 'You are not allowed to add alerts to this project')
const pids = _map(user.projects, (project) => project.id)
const alertsCount = await this.alertService.count({ project: In(pids) })
diff --git a/src/alert/alert.service.ts b/src/alert/alert.service.ts
index 8042c3c63..cd12afe4e 100644
--- a/src/alert/alert.service.ts
+++ b/src/alert/alert.service.ts
@@ -36,7 +36,7 @@ export class AlertService {
}
findOneWithRelations(id: string): Promise<Alert | null> {
- return this.alertsReporsitory.findOne(id, { relations: ['project'] })
+ return this.alertsReporsitory.findOne(id, { relations: ['project', 'project.admin'] })
}
async count(options: object = {}): Promise<number> {
diff --git a/src/task-manager/task-manager.service.ts b/src/task-manager/task-manager.service.ts
index 3e5ab2114..c79d83523 100644
--- a/src/task-manager/task-manager.service.ts
+++ b/src/task-manager/task-manager.service.ts
@@ -383,7 +383,7 @@ export class TaskManagerService {
@Cron(CronExpression.EVERY_5_MINUTES)
// @Cron(CronExpression.EVERY_5_SECONDS)
- async checkUserOnline(): Promise<void> {
+ async checkOnlineUsersAlerts(): Promise<void> {
const projects = await this.projectService.findWhere(
{
admin: {
@@ -397,7 +397,7 @@ export class TaskManagerService {
project: In(_map(projects, 'id')),
active: true,
queryMetric: QueryMetric.ONLINE_USERS,
- })
+ }, ['project'])
for (let i = 0; i < _size(alerts); ++i) {
const alert = alerts[i]
@@ -424,7 +424,7 @@ export class TaskManagerService {
this.bot.telegram.sendMessage(
project.admin.telegramChatId,
- `πŸ”” Alert *${alert.name}* got triggered!\nYour project *${project.name}* has *${online}* online users right now!}`,
+ `πŸ”” Alert *${alert.name}* got triggered!\nYour project *${project.name}* has *${online}* online users right now!`,
{
parse_mode: 'Markdown',
},
@@ -435,7 +435,7 @@ export class TaskManagerService {
@Cron(CronExpression.EVERY_5_MINUTES)
// @Cron(CronExpression.EVERY_5_SECONDS)
- async checkAdditionalAlerts(): Promise<void> {
+ async checkMetricAlerts(): Promise<void> {
const projects = await this.projectService.findWhere(
{
admin: {
@@ -449,7 +449,7 @@ export class TaskManagerService {
project: In(_map(projects, 'id')),
active: true,
queryMetric: Not(QueryMetric.ONLINE_USERS),
- })
+ }, ['project'])
for (let i = 0; i < _size(alerts); ++i) {
const alert = alerts[i]