Fix kicked accounts could become active after upgrade (#2314)

* remove force contact reactivation
* add active attribute for contact in tests

add debug launch for dev/tool upgrade

Signed-off-by: Ruslan Bayandinov <wazsone@ya.ru>
This commit is contained in:
Ruslan Bayandinov 2022-10-20 14:04:46 +07:00 committed by GitHub
parent 2c1f088735
commit 986c22332b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 82 additions and 29 deletions

85
.vscode/launch.json vendored
View File

@ -8,7 +8,9 @@
"name": "Debug server",
"type": "node",
"request": "launch",
"args": ["src/__start.ts"],
"args": [
"src/__start.ts"
],
"env": {
"ELASTIC_URL": "http://localhost:9200",
"MONGO_URL": "mongodb://localhost:27017",
@ -19,7 +21,11 @@
"MINIO_SECRET_KEY": "minioadmin",
"SERVER_SECRET": "secret"
},
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
"runtimeArgs": [
"--nolazy",
"-r",
"ts-node/register"
],
"sourceMaps": true,
"cwd": "${workspaceRoot}/server/server",
"protocol": "inspector"
@ -28,13 +34,19 @@
"name": "Debug Account",
"type": "node",
"request": "launch",
"args": ["src/index.ts"],
"args": [
"src/index.ts"
],
"env": {
"MONGO_URL": "mongodb://localhost:27017",
"SERVER_SECRET": "secret",
"TRANSACTOR_URL": "ws:/localhost:3333"
},
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
"runtimeArgs": [
"--nolazy",
"-r",
"ts-node/register"
],
"sourceMaps": true,
"cwd": "${workspaceRoot}/pods/account",
"protocol": "inspector"
@ -45,7 +57,13 @@
"name": "Debug Jest tests",
"program": "${fileDirname}/../../node_modules/@rushstack/heft/lib/start.js",
"cwd": "${fileDirname}/../../",
"args": ["--debug", "test", "--clean", "--test-path-pattern", "${file}"],
"args": [
"--debug",
"test",
"--clean",
"--test-path-pattern",
"${file}"
],
"console": "integratedTerminal",
"sourceMaps": true,
"protocol": "inspector"
@ -54,23 +72,37 @@
"name": "Debug generator",
"type": "node",
"request": "launch",
"args": ["src/index.ts", "gen-recruit", "ws1", "20"],
"args": [
"src/index.ts",
"gen-recruit",
"ws1",
"20"
],
"env": {
"TRANSACTOR_URL": "ws:/localhost:3333",
"MINIO_ACCESS_KEY": "minioadmin",
"MINIO_SECRET_KEY": "minioadmin",
"MINIO_ENDPOINT": "localhost"
},
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
"runtimeArgs": [
"--nolazy",
"-r",
"ts-node/register"
],
"sourceMaps": true,
"cwd": "${workspaceRoot}/dev/generator",
"protocol": "inspector"
},
{
"name": "Debug tool",
"name": "Debug tool import-lead-csv",
"type": "node",
"request": "launch",
"args": ["src/index.ts", "import-lead-csv", "ws1", "../../../suho/COMPANIES_Agency_of_AlexeyS.csv"],
"args": [
"src/index.ts",
"import-lead-csv",
"ws1",
"../../../suho/COMPANIES_Agency_of_AlexeyS.csv"
],
"env": {
"MINIO_ACCESS_KEY": "minioadmin",
"MINIO_SECRET_KEY": "minioadmin",
@ -80,9 +112,40 @@
"TELEGRAM_DATABASE": "telegram-service",
"ELASTIC_URL": "http://localhost:9200"
},
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
"runtimeArgs": [
"--nolazy",
"-r",
"ts-node/register"
],
"sourceMaps": true,
"cwd": "${workspaceRoot}/dev/tool"
},
{
"name": "Debug tool upgrade",
"type": "node",
"request": "launch",
"args": [
"src/index.ts",
"upgrade"
],
"env": {
"SERVER_SECRET": "secret",
"MINIO_ACCESS_KEY": "minioadmin",
"MINIO_SECRET_KEY": "minioadmin",
"MINIO_ENDPOINT": "localhost",
"MONGO_URL": "mongodb://localhost:27017",
"TRANSACTOR_URL": "ws:/localhost:3333",
"TELEGRAM_DATABASE": "telegram-service",
"ELASTIC_URL": "http://localhost:9200",
"REKONI_URL": "http://localhost:4004"
},
"runtimeArgs": [
"--nolazy",
"-r",
"ts-node/register"
],
"sourceMaps": true,
"cwd": "${workspaceRoot}/dev/tool"
}
]
}
}

View File

@ -17,7 +17,7 @@ import { Employee, EmployeeAccount } from '@hcengineering/contact'
import { AccountRole, DOMAIN_TX, TxCreateDoc, TxOperations } from '@hcengineering/core'
import { MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model'
import core from '@hcengineering/model-core'
import contact, { DOMAIN_CONTACT } from './index'
import contact from './index'
async function createSpace (tx: TxOperations): Promise<void> {
const current = await tx.findOne(core.class.Space, {
@ -56,19 +56,6 @@ async function createSpace (tx: TxOperations): Promise<void> {
}
}
async function setActiveEmployee (client: MigrationClient): Promise<void> {
await client.update(
DOMAIN_CONTACT,
{
_class: contact.class.Employee
},
{
active: true
}
)
await setActiveEmployeeTx(client)
}
async function setActiveEmployeeTx (client: MigrationClient): Promise<void> {
await client.update<TxCreateDoc<Employee>>(
DOMAIN_TX,
@ -99,7 +86,7 @@ async function setRole (client: MigrationClient): Promise<void> {
export const contactOperation: MigrateOperation = {
async migrate (client: MigrationClient): Promise<void> {
await setActiveEmployee(client)
await setActiveEmployeeTx(client)
await setRole(client)
},
async upgrade (client: MigrationUpgradeClient): Promise<void> {

View File

@ -7,7 +7,8 @@
"modifiedOn": 1643184924040,
"name": "Chen,Rosamund",
"city": "Mountain View",
"channels": 0
"channels": 0,
"active": true
},
{
"_id": "61f1031cff96c329e8f3d68c",

View File

@ -11,7 +11,8 @@
"attributes": {
"email": "rosamund@hc.engineering",
"employee": "61f1031bff96c329e8f3d61c",
"name": "Chen,Rosamund"
"name": "Chen,Rosamund",
"active": true
}
},
{
@ -899,7 +900,8 @@
"modifiedBy": "61f1031bff96c329e8f3d61d",
"attributes": {
"name": "Chen,Rosamund",
"city": "Mountain View"
"city": "Mountain View",
"active": true
}
},
{