Fix calendar service (#8981)
Some checks are pending
CI / test (push) Blocked by required conditions
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions

This commit is contained in:
Denis Bykhov 2025-05-19 00:41:31 +05:00 committed by GitHub
parent 6691ac27a2
commit 3fcc9035bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 6 deletions

View File

@ -1,5 +1,11 @@
import calendar from '@hcengineering/calendar' 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 { getClient as getKvsClient } from '@hcengineering/kvs-client'
import { createClient, getAccountClient } from '@hcengineering/server-client' import { createClient, getAccountClient } from '@hcengineering/server-client'
import { generateToken } from '@hcengineering/server-token' import { generateToken } from '@hcengineering/server-token'
@ -129,6 +135,7 @@ async function migrateCalendarIntegrations (
if (ws == null) { if (ws == null) {
continue continue
} }
if (!isActiveMode(ws.mode)) continue
token.workspace = ws.uuid token.workspace = ws.uuid
const personId = await getPersonIdByEmail(ws.uuid, token.email, token.userId) const personId = await getPersonIdByEmail(ws.uuid, token.email, token.userId)
@ -215,6 +222,7 @@ async function migrateCalendarHistory (
if (ws == null) { if (ws == null) {
continue continue
} }
if (!isActiveMode(ws.mode)) continue
const personId = await getPersonIdByEmail(ws.uuid, history.email, history.userId) const personId = await getPersonIdByEmail(ws.uuid, history.email, history.userId)
if (personId == null) { if (personId == null) {

View File

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

View File

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