mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-27 12:04:56 +02:00
UBERF-11414: Integrations (#9610)
* UBERF-11414: Use common integration kind Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Allow multiple gmail Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Merge with develop Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Refactor integration kinds Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Add integrations package Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Integrations Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Integration state and config Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Add integration events Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Refresh integration states Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Rename to integration-client Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Add filter button Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Add translations for filters Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Synced channels count Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Actions Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Add isLoading for connect Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Create connection and integration Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Use social id from hulygram Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Remove old integrations Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Gmail state Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Gmail state and disconnect all handler Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Add tests Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Formatting Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Gmail sync state Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Fix rush check Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Fix gmail tests Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Fix calendar actions and config Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Calendar state Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Access config Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Github integration state Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Fix svelte errors Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Fix formatting Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Fix typos Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Fix validate Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Fix translations Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-11414: Retry on network issues Signed-off-by: Artem Savchenko <armisav@gmail.com> --------- Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import type { AccountClient, IntegrationSecret } from '@hcengineering/account-cl
|
||||
import core, { systemAccountUuid, type MeasureContext, type PersonId, type WorkspaceUuid } from '@hcengineering/core'
|
||||
import { getAccountClient } from '@hcengineering/server-client'
|
||||
import { generateToken } from '@hcengineering/server-token'
|
||||
import { githubUserIntegrationKind } from '@hcengineering/github'
|
||||
import type { GithubUserRecord } from './types'
|
||||
|
||||
export class UserManager {
|
||||
@@ -20,7 +21,7 @@ export class UserManager {
|
||||
if (res !== undefined) {
|
||||
return res
|
||||
}
|
||||
const secrets = await this.accountClient.listIntegrationsSecrets({ kind: 'github-user', key: login })
|
||||
const secrets = await this.accountClient.listIntegrationsSecrets({ kind: githubUserIntegrationKind, key: login })
|
||||
if (secrets.length === 0) {
|
||||
return
|
||||
}
|
||||
@@ -63,7 +64,10 @@ export class UserManager {
|
||||
// Ignore failed refs
|
||||
return
|
||||
}
|
||||
const secrets = await this.accountClient.listIntegrationsSecrets({ kind: 'github-user', socialId: ref })
|
||||
const secrets = await this.accountClient.listIntegrationsSecrets({
|
||||
kind: githubUserIntegrationKind,
|
||||
socialId: ref
|
||||
})
|
||||
if (secrets.length === 0) {
|
||||
return
|
||||
}
|
||||
@@ -90,14 +94,14 @@ export class UserManager {
|
||||
|
||||
// Need to check if user integeration exists.
|
||||
const existing = await this.accountClient.getIntegration({
|
||||
kind: 'github-user',
|
||||
kind: githubUserIntegrationKind,
|
||||
workspaceUuid: null,
|
||||
socialId: dta.account
|
||||
})
|
||||
|
||||
if (existing == null) {
|
||||
await this.accountClient.createIntegration({
|
||||
kind: 'github-user',
|
||||
kind: githubUserIntegrationKind,
|
||||
workspaceUuid: null,
|
||||
socialId: dta.account,
|
||||
data: {
|
||||
@@ -108,7 +112,7 @@ export class UserManager {
|
||||
|
||||
const exists = await this.accountClient.getIntegrationSecret({
|
||||
key: dta._id,
|
||||
kind: 'github-user',
|
||||
kind: githubUserIntegrationKind,
|
||||
socialId: dta.account,
|
||||
workspaceUuid: null
|
||||
})
|
||||
@@ -116,7 +120,7 @@ export class UserManager {
|
||||
if (exists !== null) {
|
||||
await this.accountClient.updateIntegrationSecret({
|
||||
key: dta._id,
|
||||
kind: 'github-user',
|
||||
kind: githubUserIntegrationKind,
|
||||
socialId: dta.account,
|
||||
secret: JSON.stringify(dta),
|
||||
workspaceUuid: null
|
||||
@@ -124,7 +128,7 @@ export class UserManager {
|
||||
} else {
|
||||
await this.accountClient.addIntegrationSecret({
|
||||
key: dta._id,
|
||||
kind: 'github-user',
|
||||
kind: githubUserIntegrationKind,
|
||||
socialId: dta.account,
|
||||
secret: JSON.stringify(dta),
|
||||
workspaceUuid: null
|
||||
@@ -140,7 +144,7 @@ export class UserManager {
|
||||
this.userCache.clear()
|
||||
this.refUserCache.clear()
|
||||
|
||||
const secerts = await this.accountClient.listIntegrationsSecrets({ kind: 'github-user', key: login })
|
||||
const secerts = await this.accountClient.listIntegrationsSecrets({ kind: githubUserIntegrationKind, key: login })
|
||||
for (const s of secerts) {
|
||||
await this.accountClient.deleteIntegrationSecret(s)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user