Fix calendar service

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2025-05-18 20:29:32 +05:00
parent b79afafa77
commit e66202a13a
No known key found for this signature in database
GPG Key ID: 211936D31001B31C
3 changed files with 8 additions and 6 deletions

View File

@ -1,5 +1,5 @@
import calendar from '@hcengineering/calendar'
import { type PersonId, type WorkspaceInfoWithStatus, type WorkspaceUuid, systemAccountUuid } from '@hcengineering/core'
import { type PersonId, type WorkspaceInfoWithStatus, type WorkspaceUuid, isActiveMode, systemAccountUuid } from '@hcengineering/core'
import { getClient as getKvsClient } from '@hcengineering/kvs-client'
import { createClient, getAccountClient } from '@hcengineering/server-client'
import { generateToken } from '@hcengineering/server-token'
@ -129,6 +129,7 @@ async function migrateCalendarIntegrations (
if (ws == null) {
continue
}
if (!isActiveMode(ws.mode)) continue
token.workspace = ws.uuid
const personId = await getPersonIdByEmail(ws.uuid, token.email, token.userId)
@ -215,6 +216,7 @@ async function migrateCalendarHistory (
if (ws == null) {
continue
}
if (!isActiveMode(ws.mode)) continue
const personId = await getPersonIdByEmail(ws.uuid, history.email, history.userId)
if (personId == null) {

View File

@ -25,7 +25,7 @@ import { getClient } from './client'
import { addUserByEmail, removeUserByEmail } from './kvsUtils'
import { IncomingSyncManager, lock } from './sync'
import { CALENDAR_INTEGRATION, GoogleEmail, SCOPES, State, Token, User } from './types'
import { getGoogleClient, getServiceToken } from './utils'
import { getGoogleClient, getWorkspaceToken } from './utils'
import { WatchController } from './watch'
interface AuthResult {
@ -58,7 +58,7 @@ export class AuthController {
await ctx.with('Create auth controller', { workspace: state.workspace, user: state.userId }, async () => {
const mutex = await lock(`${state.workspace}:${state.userId}`)
try {
const client = await getClient(getServiceToken())
const client = await getClient(getWorkspaceToken(state.workspace))
const txOp = new TxOperations(client, core.account.System)
const controller = new AuthController(ctx, accountClient, txOp, state)
await controller.process(code)
@ -78,7 +78,7 @@ export class AuthController {
await ctx.with('Signout auth controller', { workspace, userId }, async () => {
const mutex = await lock(`${workspace}:${userId}`)
try {
const client = await getClient(getServiceToken())
const client = await getClient(getWorkspaceToken(workspace))
const txOp = new TxOperations(client, core.account.System)
const controller = new AuthController(ctx, accountClient, txOp, {
userId,

View File

@ -19,7 +19,7 @@ import { getClient } from './client'
import { getUserByEmail } from './kvsUtils'
import { IncomingSyncManager } from './sync'
import { GoogleEmail, Token } from './types'
import { getGoogleClient, getServiceToken } from './utils'
import { getGoogleClient, getWorkspaceToken } from './utils'
export class PushHandler {
constructor (
@ -29,7 +29,7 @@ export class PushHandler {
async sync (token: Token, calendarId: string | null): Promise<void> {
await this.ctx.with('Push handler', { workspace: token.workspace, user: token.userId }, async () => {
const client = await getClient(getServiceToken())
const client = await getClient(getWorkspaceToken(token.workspace))
const txOp = new TxOperations(client, core.account.System)
const res = getGoogleClient()
res.auth.setCredentials(token)