UBERF-10590: Suport disabled integrations

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2025-05-15 10:59:08 +07:00
parent 5ee8cc8027
commit 38cf875daf
No known key found for this signature in database
GPG Key ID: BD80F68D68D8F7F2
7 changed files with 50 additions and 18 deletions

View File

@ -370,7 +370,8 @@ export default function buildModel (): Builder {
description: github.string.ConfigDescription,
enabled: true,
beta: false,
icon: github.icon.Github
icon: github.icon.Github,
classFilter: defaultFilter
}
],
[

View File

@ -823,7 +823,9 @@ export function pluginFilterTx (
}
}
}
console.log('exclude plugin', msg)
if (typeof window !== 'undefined') {
console.log('exclude plugin', msg)
}
systemTx = systemTx.filter((t) => !totalExcluded.has(t._id))
return systemTx
}

View File

@ -375,7 +375,9 @@ class Connection implements ClientConnection {
this.lastHash = (resp as HelloResponse).lastHash
const serverVersion = helloResp.serverVersion
console.log('Connected to server:', serverVersion)
if (typeof window !== 'undefined') {
console.log('Connected to server:', serverVersion)
}
if (this.opt?.onHello !== undefined && !this.opt.onHello(serverVersion)) {
this.closed = true

View File

@ -196,7 +196,6 @@ function returnClientTxes (txes: Tx[]): Tx[] {
'text-editor:class:TextEditorAction' as Ref<Class<Doc>>,
'templates:class:TemplateField' as Ref<Class<Doc>>,
'activity:class:DocUpdateMessageViewlet' as Ref<Class<Doc>>,
'core:class:PluginConfiguration' as Ref<Class<Doc>>,
'core:class:DomainIndexConfiguration' as Ref<Class<Doc>>,
'view:class:ViewletDescriptor' as Ref<Class<Doc>>,
'presentation:class:ComponentPointExtension' as Ref<Class<Doc>>,

View File

@ -177,14 +177,17 @@ export class PlatformWorker {
triggerCheckWorkspaces = (): void => {}
async doSyncWorkspaces (): Promise<void> {
let oldErrors = ''
let sameErrors = 1
while (!this.canceled) {
let errors = false
let errors: string[] = []
try {
errors = await this.checkWorkspaces()
} catch (err: any) {
Analytics.handleError(err)
this.ctx.error('check workspace', err)
errors = true
errors.push(err.message)
}
await new Promise<void>((resolve) => {
this.triggerCheckWorkspaces = () => {
@ -192,10 +195,19 @@ export class PlatformWorker {
this.triggerCheckWorkspaces = () => {}
resolve()
}
if (errors) {
if (errors.length > 0) {
const timeout = 15000 * sameErrors
const ne = errors.join(',')
if (oldErrors === ne) {
if (sameErrors < 25) {
sameErrors++
}
} else {
oldErrors = ne
}
setTimeout(() => {
this.triggerCheckWorkspaces()
}, 5000)
}, timeout)
}
})
}
@ -836,7 +848,7 @@ export class PlatformWorker {
return { workspaceInfo, needRecheck: true }
}
private async checkWorkspaces (): Promise<boolean> {
private async checkWorkspaces (): Promise<string[]> {
this.ctx.info('************************* Check workspaces ************************* ', {
workspaces: this.clients.size
})
@ -844,7 +856,7 @@ export class PlatformWorker {
const toDelete = new Set<WorkspaceUuid>(this.clients.keys())
const rateLimiter = new RateLimiter(5)
let errors = 0
const rechecks: string[] = []
let idx = 0
const connecting = new Map<string, number>()
const st = Date.now()
@ -870,7 +882,7 @@ export class PlatformWorker {
const { workspaceInfo, needRecheck } = await this.checkWorkspaceIsActive(token, workspace)
if (workspaceInfo === undefined) {
if (needRecheck) {
errors++
rechecks.push(workspace)
}
return
}
@ -946,13 +958,12 @@ export class PlatformWorker {
total: workspaces.length
}
)
errors++
rechecks.push(workspace)
}
} catch (e: any) {
Analytics.handleError(e)
this.ctx.info("Couldn't create WS worker", { workspace, error: e })
console.error(e)
errors++
rechecks.push(workspace)
} finally {
connecting.delete(workspaceInfo.uuid)
}
@ -966,7 +977,6 @@ export class PlatformWorker {
await rateLimiter.waitProcessing()
} catch (e: any) {
Analytics.handleError(e)
errors++
}
clearInterval(connectingInfo)
@ -986,14 +996,13 @@ export class PlatformWorker {
})
} catch (err: any) {
Analytics.handleError(err)
errors++
}
}
}
this.ctx.info('************************* Check workspaces done ************************* ', {
workspaces: this.clients.size
})
return errors > 0
return rechecks
}
getWorkers (): GithubWorker[] {

View File

@ -200,6 +200,20 @@ export abstract class IssueSyncManagerBase {
)
await this.client.diffUpdate(doc, issueData, lastModified, account)
this.provider.sync()
} else if (doc === undefined) {
await derivedClient.diffUpdate(
syncData,
{
external,
externalVersion: githubExternalSyncVersion,
needSync: '',
derivedVersion: '', // Check derived changes
lastModified,
lastGithubUser: account,
...extraSyncUpdate
},
lastModified
)
}
}
if (needSync) {

View File

@ -1660,6 +1660,11 @@ export class GithubWorker implements IntegrationManager {
reconnect(workspace.uuid, event)
}))
const githubEnabled = (await client.findOne(core.class.PluginConfiguration, { pluginId: githubId }))?.enabled
if (githubEnabled === false) {
return undefined
}
await GithubWorker.checkIntegrations(client, installations)
const worker = new GithubWorker(
@ -1679,12 +1684,12 @@ export class GithubWorker implements IntegrationManager {
} catch (err: any) {
ctx.error('timeout during to connect', { workspace, error: err })
await client?.close()
return undefined
}
}
static async checkIntegrations (client: Client, installations: Map<number, InstallationRecord>): Promise<void> {
const wsIntegerations = await client.findAll(github.class.GithubIntegration, {})
for (const intValue of wsIntegerations) {
if (!installations.has(intValue.installationId)) {
const ops = new TxOperations(client, core.account.System)