mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-22 15:38:09 +00:00
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
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:
parent
6691ac27a2
commit
3fcc9035bb
@ -1,5 +1,11 @@
|
||||
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 +135,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 +222,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) {
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user