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!

Added status of transferred project

Yevhenii Kulisidia715bf1528a2
diff --git a/migrations/mysql/2023_04_09.sql b/migrations/mysql/2023_04_09.sql
new file mode 100644
index 000000000..f9971cdac
--- /dev/null
+++ b/migrations/mysql/2023_04_09.sql
@@ -0,0 +1 @@
+alter table project add column `isTransferring` tinyint NOT NULL DEFAULT '0' AFTER public;
diff --git a/src/project/entity/project-subscriber.entity.ts b/src/project/entity/project-subscriber.entity.ts
index 7e3238db2..f049aa0d1 100644
--- a/src/project/entity/project-subscriber.entity.ts
+++ b/src/project/entity/project-subscriber.entity.ts
@@ -27,6 +27,9 @@ export class ProjectSubscriber {
@Column('boolean', { default: false })
isConfirmed: boolean
+ @Column('boolean', { default: false })
+ isTransferring: boolean
+
@CreateDateColumn()
addedAt: Date
diff --git a/src/project/entity/project.entity.ts b/src/project/entity/project.entity.ts
index b7dd9c736..ff12ad7dc 100644
--- a/src/project/entity/project.entity.ts
+++ b/src/project/entity/project.entity.ts
@@ -50,6 +50,9 @@ export class Project {
})
public: boolean
+ @Column('boolean', { default: false })
+ isTransferring: boolean
+
// Swetrix CAPTCHA related stuff
@ApiProperty()
@Column('boolean', { default: true })
diff --git a/src/project/project.controller.ts b/src/project/project.controller.ts
index d30bc96c5..0cb638fbe 100644
--- a/src/project/project.controller.ts
+++ b/src/project/project.controller.ts
@@ -1358,6 +1358,6 @@ export class ProjectController {
throw new NotFoundException('Project not found.')
}
- await this.projectService.cancelTransferProject(actionToken.id)
+ await this.projectService.cancelTransferProject(actionToken.id, project.id)
}
}
diff --git a/src/project/project.service.ts b/src/project/project.service.ts
index 8cd0278f1..a9b5b3b30 100644
--- a/src/project/project.service.ts
+++ b/src/project/project.service.ts
@@ -644,6 +644,13 @@ export class ProjectService {
projectId,
)
+ await this.projectsRepository.update(
+ { id: projectId },
+ {
+ isTransferring: true,
+ },
+ )
+
const url = `${
isDevelopment ? origin : PRODUCTION_ORIGIN
}/projects/${projectId}/transfer?token=${actionToken.id}`
@@ -662,7 +669,7 @@ export class ProjectService {
) {
await this.projectsRepository.update(
{ id: projectId },
- { admin: { id: userId } },
+ { admin: { id: userId }, isTransferring: false },
)
await this.projectShareRepository.save({
user: { id: oldAdminId },
@@ -673,7 +680,11 @@ export class ProjectService {
await this.actionTokens.deleteActionToken(token)
}
- async cancelTransferProject(token: string) {
+ async cancelTransferProject(token: string, projectId: string) {
+ await this.projectsRepository.update(
+ { id: projectId },
+ { isTransferring: false },
+ )
await this.actionTokens.deleteActionToken(token)
}
}