Merge remote-tracking branch 'origin/develop' into staging

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2024-12-25 22:40:43 +07:00
commit 17df8e193b
No known key found for this signature in database
GPG Key ID: BD80F68D68D8F7F2
27 changed files with 130 additions and 86 deletions

3
.vscode/launch.json vendored
View File

@ -441,7 +441,6 @@
"CLIENT_SECRET": "${env:POD_GITHUB_CLIENT_SECRET}",
"PRIVATE_KEY": "${env:POD_GITHUB_PRIVATE_KEY}",
"COLLABORATOR_URL": "ws://localhost:3078",
"SYSTEM_EMAIL": "anticrm@hc.engineering",
"MINIO_ENDPOINT": "localhost",
"MINIO_ACCESS_KEY": "minioadmin",
"MINIO_SECRET_KEY": "minioadmin",
@ -463,7 +462,6 @@
"args": ["src/index.ts"],
"env": {
"ACCOUNTS_URL": "http://localhost:3000",
"SYSTEM_EMAIL": "anticrm@hc.engineering",
"SECRET": "secret",
"DOCS_RELEASE_INTERVAL": "10000",
"DOCS_IN_REVIEW_CHECK_INTERVAL": "10000",
@ -523,7 +521,6 @@
"MINIO_ACCESS_KEY": "minioadmin",
"MINIO_SECRET_KEY": "minioadmin",
"SERVICE_ID": "sign-service",
"SYSTEM_EMAIL": "",
"ACCOUNTS_URL": "http://localhost:3000",
"BRANDING_PATH": "${workspaceRoot}/services/sign/pod-sign/debug/branding.json"
},

View File

@ -81,7 +81,7 @@ async function moveWorkspace (
tables = tables.filter((t) => include.has(t))
}
await createTables(new MeasureMetricsContext('', {}), pgClient, tables)
await createTables(new MeasureMetricsContext('', {}), pgClient, '', tables)
const token = generateToken(systemAccountEmail, wsId)
const endpoint = await getTransactorEndpoint(token, 'external')
const connection = (await connect(endpoint, wsId, undefined, {

View File

@ -361,7 +361,8 @@ export function createModel (builder: Builder): void {
viewOptions: {
groupBy: [],
orderBy: [],
other: [vacancyHideArchivedOption]
other: [vacancyHideArchivedOption],
storageKey: 'vacancyViewOptions'
}
},
recruit.viewlet.TableVacancy
@ -502,7 +503,8 @@ export function createModel (builder: Builder): void {
viewOptions: {
groupBy: [],
orderBy: [],
other: [applicationDoneOption, hideApplicantsFromArchivedVacanciesOption]
other: [applicationDoneOption, hideApplicantsFromArchivedVacanciesOption],
storageKey: 'applicantViewOptions'
}
},
recruit.viewlet.ApplicantTable
@ -559,7 +561,8 @@ export function createModel (builder: Builder): void {
action: view.function.ShowEmptyGroups,
label: view.string.ShowEmptyGroups
}
]
],
storageKey: 'applicantViewOptions'
}
if (colors) {
model.other.push(showColorsViewOption)
@ -784,7 +787,8 @@ export function createModel (builder: Builder): void {
['modifiedOn', SortingOrder.Descending],
['createdOn', SortingOrder.Descending]
],
other: [vacancyHideArchivedOption]
other: [vacancyHideArchivedOption],
storageKey: 'vacancyViewOptions'
}
},
recruit.viewlet.ListVacancy

View File

@ -14,7 +14,7 @@
-->
<script lang="ts">
import { Attachment } from '@hcengineering/attachment'
import { Account, Class, Doc, IdMap, Markup, Ref, Space, generateId, toIdMap } from '@hcengineering/core'
import { RateLimiter, Account, Class, Doc, IdMap, Markup, Ref, Space, generateId, toIdMap } from '@hcengineering/core'
import { Asset, IntlString, setPlatformStatus, unknownError } from '@hcengineering/platform'
import {
DraftController,
@ -183,12 +183,14 @@
await tick()
const list = inputFile.files
if (list === null || list.length === 0) return
const limiter = new RateLimiter(10)
for (let index = 0; index < list.length; index++) {
const file = list.item(index)
if (file !== null) {
await createAttachment(file)
await limiter.add(() => createAttachment(file))
}
}
await limiter.waitProcessing()
inputFile.value = ''
progress = false
}
@ -196,13 +198,16 @@
async function fileDrop (e: DragEvent): Promise<void> {
progress = true
const list = e.dataTransfer?.files
const limiter = new RateLimiter(10)
if (list === undefined || list.length === 0) return
for (let index = 0; index < list.length; index++) {
const file = list.item(index)
if (file !== null) {
await createAttachment(file)
await limiter.add(() => createAttachment(file))
}
}
await limiter.waitProcessing()
progress = false
}
@ -257,17 +262,17 @@
return
}
saved = true
const promises: Promise<any>[] = []
const limiter = new RateLimiter(10)
newAttachments.forEach((p) => {
const attachment = attachments.get(p)
if (attachment !== undefined) {
promises.push(saveAttachment(attachment))
void limiter.add(() => saveAttachment(attachment))
}
})
removedAttachments.forEach((p) => {
promises.push(deleteAttachment(p))
void limiter.add(() => deleteAttachment(p))
})
await Promise.all(promises)
await limiter.waitProcessing()
newAttachments.clear()
removedAttachments.clear()
saveDraft()

View File

@ -125,7 +125,7 @@ export function adjustSelectionIndent (
let insertionOffset = 0
for (const range of ranges) {
if (direction > 0 ? range.text === '' : range.indent === 0) {
if (direction > 0 ? range.text === '' && ranges.length > 1 : range.indent === 0) {
continue
}
const indentOffset = indentLevelOffset(range.indent, direction)

View File

@ -117,7 +117,8 @@ export const MermaidExtension = CodeBlockLowlight.extend<MermaidOptions>({
},
addProseMirrorPlugins () {
return [...(this.parent?.() ?? []), MermaidDecorator(this.options)]
const parent = (this.parent?.() ?? []).filter((p) => p.props.handlePaste === undefined)
return [...parent, MermaidDecorator(this.options)]
},
addNodeView () {

View File

@ -31,8 +31,11 @@ export function isDropdownType (viewOption: ViewOptionModel): viewOption is Drop
return viewOption.type === 'dropdown'
}
export function makeViewOptionsKey (viewlet: Ref<Viewlet>, variant?: string): string {
const prefix = viewlet + (variant !== undefined ? `-${variant}` : '')
function makeViewOptionsKey (viewlet: Viewlet, variant?: string, ignoreViewletKey = false): string {
const prefix =
viewlet.viewOptions?.storageKey !== undefined && !ignoreViewletKey
? viewlet.viewOptions.storageKey
: viewlet._id + (variant !== undefined ? `-${variant}` : '')
const loc = getCurrentResolvedLocation()
loc.fragment = undefined
loc.query = undefined
@ -40,7 +43,7 @@ export function makeViewOptionsKey (viewlet: Ref<Viewlet>, variant?: string): st
}
export function setViewOptions (viewlet: Viewlet, options: ViewOptions): void {
const key = makeViewOptionsKey(viewlet._id, viewlet.variant)
const key = makeViewOptionsKey(viewlet, viewlet.variant)
localStorage.setItem(key, JSON.stringify(options))
setStore(key, options)
}
@ -52,13 +55,19 @@ function setStore (key: string, options: ViewOptions): void {
}
function _getViewOptions (viewlet: Viewlet, viewOptionStore: Map<string, ViewOptions>): ViewOptions | null {
const key = makeViewOptionsKey(viewlet._id, viewlet.variant)
const key = makeViewOptionsKey(viewlet, viewlet.variant)
const store = viewOptionStore.get(key)
if (store !== undefined) {
return store
}
const options = localStorage.getItem(key)
if (options === null) return null
let options = localStorage.getItem(key)
if (options === null) {
const key = makeViewOptionsKey(viewlet, viewlet.variant, true)
options = localStorage.getItem(key)
if (options === null) {
return null
}
}
const res = JSON.parse(options)
setStore(key, res)
return res

View File

@ -794,6 +794,7 @@ export interface ViewOptionsModel {
orderBy: OrderOption[]
other: ViewOptionModel[]
groupDepth?: number
storageKey?: string
}
/**

View File

@ -173,11 +173,10 @@ export async function OnUserStatus (txes: Tx[], control: TriggerControl): Promis
async function roomJoinHandler (info: ParticipantInfo, control: TriggerControl): Promise<Tx[]> {
const roomInfos = await control.queryFind(control.ctx, love.class.RoomInfo, {})
const roomInfo = roomInfos.find((ri) => ri.room === info.room)
if (roomInfo !== undefined) {
roomInfo.persons.push(info.person)
if (roomInfo !== undefined && !roomInfo.persons.includes(info.person)) {
return [
control.txFactory.createTxUpdateDoc(love.class.RoomInfo, core.space.Workspace, roomInfo._id, {
persons: Array.from(new Set([...roomInfo.persons, info.person]))
$push: { persons: info.person }
})
]
} else {
@ -221,7 +220,6 @@ async function setDefaultRoomAccess (info: ParticipantInfo, control: TriggerCont
const roomInfos = await control.queryFind(control.ctx, love.class.RoomInfo, {})
const oldRoomInfo = roomInfos.find((ri) => ri.persons.includes(info.person))
if (oldRoomInfo !== undefined) {
oldRoomInfo.persons = oldRoomInfo.persons.filter((p) => p !== info.person)
if (oldRoomInfo.persons.length === 0) {
res.push(control.txFactory.createTxRemoveDoc(oldRoomInfo._class, oldRoomInfo.space, oldRoomInfo._id))
@ -237,7 +235,7 @@ async function setDefaultRoomAccess (info: ParticipantInfo, control: TriggerCont
} else {
res.push(
control.txFactory.createTxUpdateDoc(love.class.RoomInfo, core.space.Workspace, oldRoomInfo._id, {
persons: oldRoomInfo.persons
$pull: { persons: info.person }
})
)
}
@ -433,23 +431,44 @@ async function isRoomEmpty (
return false
}
function combineAttributes (attributes: any[], key: string, operator: string, arrayKey: string): any[] {
return Array.from(
new Set(
attributes.flatMap((attr) =>
Array.isArray(attr[operator]?.[key]?.[arrayKey]) ? attr[operator]?.[key]?.[arrayKey] : attr[operator]?.[key]
)
)
).filter((v) => v != null)
}
async function OnRoomInfo (txes: TxCUD<RoomInfo>[], control: TriggerControl): Promise<Tx[]> {
const result: Tx[] = []
const personsByRoom = new Map<Ref<RoomInfo>, Ref<Person>[]>()
for (const tx of txes) {
if (tx._class === core.class.TxRemoveDoc) {
const roomInfo = control.removedMap.get(tx.objectId) as RoomInfo
if (roomInfo === undefined) continue
if (roomInfo.room === love.ids.Reception) continue
personsByRoom.delete(tx.objectId)
result.push(...(await finishRoomMeetings(roomInfo.room, tx.modifiedOn, control)))
continue
}
if (tx._class === core.class.TxUpdateDoc) {
const newPersons = (tx as TxUpdateDoc<RoomInfo>).operations.persons
if (newPersons === undefined) continue
const updateTx = tx as TxUpdateDoc<RoomInfo>
const pulled = combineAttributes([updateTx.operations], 'persons', '$pull', '$in')
const pushed = combineAttributes([updateTx.operations], 'persons', '$push', '$each')
if (pulled.length === 0 && pushed.length === 0) continue
const roomInfos = await control.queryFind(control.ctx, love.class.RoomInfo, {})
const roomInfo = roomInfos.find((r) => r._id === tx.objectId)
if (roomInfo === undefined) continue
if (roomInfo.room === love.ids.Reception) continue
const currentPersons = personsByRoom.get(tx.objectId) ?? roomInfo.persons
const newPersons = currentPersons.filter((p) => !pulled.includes(p)).concat(pushed)
personsByRoom.set(tx.objectId, newPersons)
if (await isRoomEmpty(roomInfo.room, roomInfo.isOffice, newPersons, control)) {
result.push(...(await finishRoomMeetings(roomInfo.room, tx.modifiedOn, control)))
}

View File

@ -761,8 +761,7 @@ export async function createAcc (
const salt = randomBytes(32)
const hash = password !== null ? hashWithSalt(password, salt) : null
const systemEmails = [systemAccountEmail]
if (systemEmails.includes(email)) {
if (systemAccountEmail === email) {
ctx.error('system email used for account', { email })
throw new PlatformError(new Status(Severity.ERROR, platform.status.AccountAlreadyExists, { account: email }))
}

View File

@ -37,6 +37,7 @@ import core, {
type ModelDb,
type ObjQueryType,
type Projection,
RateLimiter,
type Ref,
type ReverseLookups,
type SessionData,
@ -1506,13 +1507,18 @@ interface OperationBulk {
mixins: TxMixin<Doc, Doc>[]
}
const initRateLimit = new RateLimiter(1)
class PostgresAdapter extends PostgresAdapterBase {
async init (ctx: MeasureContext, domains?: string[], excludeDomains?: string[]): Promise<void> {
let resultDomains = domains ?? this.hierarchy.domains()
if (excludeDomains !== undefined) {
resultDomains = resultDomains.filter((it) => !excludeDomains.includes(it))
}
await createTables(ctx, this.client, resultDomains)
const url = this.refClient.url()
await initRateLimit.exec(async () => {
await createTables(ctx, this.client, url, resultDomains)
})
this._helper.domains = new Set(resultDomains as Domain[])
}
@ -1789,7 +1795,10 @@ class PostgresAdapter extends PostgresAdapterBase {
class PostgresTxAdapter extends PostgresAdapterBase implements TxAdapter {
async init (ctx: MeasureContext, domains?: string[], excludeDomains?: string[]): Promise<void> {
const resultDomains = domains ?? [DOMAIN_TX, DOMAIN_MODEL_TX]
await createTables(ctx, this.client, resultDomains)
await initRateLimit.exec(async () => {
const url = this.refClient.url()
await createTables(ctx, this.client, url, resultDomains)
})
this._helper.domains = new Set(resultDomains as Domain[])
}

View File

@ -72,8 +72,13 @@ export const NumericTypes = [
core.class.Collection
]
export async function createTables (ctx: MeasureContext, client: postgres.Sql, domains: string[]): Promise<void> {
const filtered = domains.filter((d) => !loadedDomains.has(d))
export async function createTables (
ctx: MeasureContext,
client: postgres.Sql,
url: string,
domains: string[]
): Promise<void> {
const filtered = domains.filter((d) => !loadedDomains.has(url + translateDomain(d)))
if (filtered.length === 0) {
return
}
@ -90,17 +95,15 @@ export async function createTables (ctx: MeasureContext, client: postgres.Sql, d
const exists = new Set(tables.map((it) => it.table_name))
await retryTxn(client, async (client) => {
await ctx.with('load-schemas', {}, () =>
getTableSchema(
client,
mapped.filter((it) => exists.has(it))
)
)
const domainsToLoad = mapped.filter((it) => exists.has(it))
if (domainsToLoad.length > 0) {
await ctx.with('load-schemas', {}, () => getTableSchema(client, domainsToLoad))
}
for (const domain of mapped) {
if (!exists.has(domain)) {
await ctx.with('create-table', {}, () => createTable(client, domain))
}
loadedDomains.add(domain)
loadedDomains.add(url + domain)
}
})
}
@ -188,6 +191,8 @@ export async function shutdown (): Promise<void> {
export interface PostgresClientReference {
getClient: () => Promise<postgres.Sql>
close: () => void
url: () => string
}
class PostgresClientReferenceImpl {
@ -195,6 +200,7 @@ class PostgresClientReferenceImpl {
client: postgres.Sql | Promise<postgres.Sql>
constructor (
readonly connectionString: string,
client: postgres.Sql | Promise<postgres.Sql>,
readonly onclose: () => void
) {
@ -202,6 +208,10 @@ class PostgresClientReferenceImpl {
this.client = client
}
url (): string {
return this.connectionString
}
async getClient (): Promise<postgres.Sql> {
if (this.client instanceof Promise) {
this.client = await this.client
@ -233,6 +243,10 @@ export class ClientRef implements PostgresClientReference {
clientRefs.set(this.id, this)
}
url (): string {
return this.client.url()
}
closed = false
async getClient (): Promise<postgres.Sql> {
if (!this.closed) {
@ -274,7 +288,7 @@ export function getDBClient (connectionString: string, database?: string): Postg
...extraOptions
})
existing = new PostgresClientReferenceImpl(sql, () => {
existing = new PostgresClientReferenceImpl(connectionString, sql, () => {
connections.delete(key)
})
connections.set(key, existing)

View File

@ -23,7 +23,6 @@ interface Config {
Secret: string
Credentials: string
WATCH_URL: string
SystemEmail: string
InitLimit: number
}
@ -37,7 +36,6 @@ const envMap: { [key in keyof Config]: string } = {
ServiceID: 'SERVICE_ID',
Secret: 'SECRET',
Credentials: 'Credentials',
SystemEmail: 'SYSTEM_EMAIL',
WATCH_URL: 'WATCH_URL',
InitLimit: 'INIT_LIMIT'
}
@ -52,7 +50,6 @@ const config: Config = (() => {
AccountsURL: process.env[envMap.AccountsURL],
ServiceID: process.env[envMap.ServiceID] ?? 'calendar-service',
Secret: process.env[envMap.Secret],
SystemEmail: process.env[envMap.SystemEmail] ?? 'anticrm@hc.engineering',
Credentials: process.env[envMap.Credentials],
InitLimit: parseNumber(process.env[envMap.InitLimit]) ?? 50,
WATCH_URL: process.env[envMap.WATCH_URL]

View File

@ -18,6 +18,7 @@ import contact, { Channel, Contact, type Employee, type PersonAccount } from '@h
import core, {
TxOperations,
TxProcessor,
systemAccountEmail,
toIdMap,
type Account,
type Client,
@ -34,7 +35,6 @@ import { Collection, type Db } from 'mongodb'
import { CalendarClient } from './calendar'
import { CalendarController } from './calendarController'
import { getClient } from './client'
import config from './config'
import { SyncHistory, type ProjectCredentials, type User } from './types'
export class WorkspaceClient {
@ -159,7 +159,7 @@ export class WorkspaceClient {
}
private async initClient (workspace: string): Promise<Client> {
const token = generateToken(config.SystemEmail, { name: workspace })
const token = generateToken(systemAccountEmail, { name: workspace })
const client = await getClient(token)
client.notify = (...tx: Tx[]) => {
void this.txHandler(...tx)

View File

@ -5,7 +5,7 @@
import client, { ClientSocket } from '@hcengineering/client'
import clientResources from '@hcengineering/client-resources'
import { Client, ClientConnectEvent } from '@hcengineering/core'
import { Client, ClientConnectEvent, systemAccountEmail } from '@hcengineering/core'
import { setMetadata } from '@hcengineering/platform'
import { getTransactorEndpoint } from '@hcengineering/server-client'
import serverToken, { generateToken } from '@hcengineering/server-token'
@ -30,7 +30,7 @@ export async function createPlatformClient (
setMetadata(serverToken.metadata.Secret, config.ServerSecret)
const token = generateToken(
config.SystemEmail,
systemAccountEmail,
{
name: workspace
},

View File

@ -4,7 +4,7 @@
//
import { CollaboratorClient, getClient as getCollaboratorClient } from '@hcengineering/collaborator-client'
import { WorkspaceId } from '@hcengineering/core'
import { systemAccountEmail, WorkspaceId } from '@hcengineering/core'
import { generateToken } from '@hcengineering/server-token'
import config from './config'
@ -12,6 +12,6 @@ import config from './config'
* @public
*/
export function createCollaboratorClient (workspaceId: WorkspaceId): CollaboratorClient {
const token = generateToken(config.SystemEmail, workspaceId, { mode: 'github' })
const token = generateToken(systemAccountEmail, workspaceId, { mode: 'github' })
return getCollaboratorClient(workspaceId, token, config.CollaboratorURL)
}

View File

@ -2,13 +2,10 @@
// Copyright © 2023 Hardcore Engineering Inc.
//
import { systemAccountEmail } from '@hcengineering/core'
interface Config {
AccountsURL: string
ServiceID: string
ServerSecret: string
SystemEmail: string
FrontURL: string
// '*' means all workspaces
@ -36,7 +33,6 @@ const envMap: { [key in keyof Config]: string } = {
AccountsURL: 'ACCOUNTS_URL',
ServiceID: 'SERVICE_ID',
ServerSecret: 'SERVER_SECRET',
SystemEmail: 'SYSTEM_EMAIL',
FrontURL: 'FRONT_URL',
AppID: 'APP_ID',
@ -62,7 +58,6 @@ const required: Array<keyof Config> = [
'AccountsURL',
'ServerSecret',
'ServiceID',
'SystemEmail',
'FrontURL',
'AppID',
'ClientID',
@ -82,7 +77,6 @@ const config: Config = (() => {
AccountsURL: process.env[envMap.AccountsURL],
ServerSecret: process.env[envMap.ServerSecret],
ServiceID: process.env[envMap.ServiceID] ?? 'github-service',
SystemEmail: process.env[envMap.SystemEmail] ?? systemAccountEmail,
AllowedWorkspaces: process.env[envMap.AllowedWorkspaces]?.split(',') ?? ['*'],
FrontURL: process.env[envMap.FrontURL] ?? '',

View File

@ -14,6 +14,7 @@ import core, {
MeasureContext,
RateLimiter,
Ref,
systemAccountEmail,
TxOperations
} from '@hcengineering/core'
import github, { GithubAuthentication, makeQuery, type GithubIntegration } from '@hcengineering/github'
@ -730,7 +731,7 @@ export class PlatformWorker {
}
await rateLimiter.add(async () => {
const token = generateToken(
config.SystemEmail,
systemAccountEmail,
{
name: workspace
},

View File

@ -24,7 +24,6 @@ interface Config {
Secret: string
Credentials: string
WATCH_TOPIC_NAME: string
SystemEmail: string
FooterMessage: string
InitLimit: number
}
@ -39,7 +38,6 @@ const envMap: { [key in keyof Config]: string } = {
ServiceID: 'SERVICE_ID',
Secret: 'SECRET',
Credentials: 'Credentials',
SystemEmail: 'SYSTEM_EMAIL',
WATCH_TOPIC_NAME: 'WATCH_TOPIC_NAME',
FooterMessage: 'FOOTER_MESSAGE',
InitLimit: 'INIT_LIMIT'
@ -55,7 +53,6 @@ const config: Config = (() => {
AccountsURL: process.env[envMap.AccountsURL],
ServiceID: process.env[envMap.ServiceID] ?? 'gmail-service',
Secret: process.env[envMap.Secret],
SystemEmail: process.env[envMap.SystemEmail] ?? 'anticrm@hc.engineering',
Credentials: process.env[envMap.Credentials],
WATCH_TOPIC_NAME: process.env[envMap.WATCH_TOPIC_NAME],
InitLimit: parseNumber(process.env[envMap.InitLimit]) ?? 50,

View File

@ -20,6 +20,7 @@ import core, {
type Doc,
MeasureContext,
type Ref,
systemAccountEmail,
type Tx,
type TxCreateDoc,
TxProcessor,
@ -31,7 +32,6 @@ import type { StorageAdapter } from '@hcengineering/server-core'
import { generateToken } from '@hcengineering/server-token'
import { type Db } from 'mongodb'
import { getClient } from './client'
import config from './config'
import { GmailClient } from './gmail'
import { type Channel, type ProjectCredentials, type User } from './types'
@ -121,7 +121,7 @@ export class WorkspaceClient {
}
private async initClient (workspace: string): Promise<Client> {
const token = generateToken(config.SystemEmail, { name: workspace })
const token = generateToken(systemAccountEmail, { name: workspace })
console.log('token', token, workspace)
const client = await getClient(token)
client.notify = (...tx: Tx[]) => {

View File

@ -16,7 +16,6 @@
interface Config {
AccountsURL: string
Port: number
SystemEmail: string
ServiceID: string
LiveKitHost: string
@ -42,7 +41,6 @@ const envMap: { [key in keyof Config]: string } = {
StorageProviderName: 'STORAGE_PROVIDER_NAME',
Secret: 'SECRET',
ServiceID: 'SERVICE_ID',
SystemEmail: 'SYSTEM_EMAIL',
MongoUrl: 'MONGO_URL'
}
@ -59,7 +57,6 @@ const config: Config = (() => {
StorageProviderName: process.env[envMap.StorageProviderName] ?? 's3',
Secret: process.env[envMap.Secret],
ServiceID: process.env[envMap.ServiceID] ?? 'love-service',
SystemEmail: process.env[envMap.SystemEmail] ?? 'anticrm@hc.engineering',
MongoUrl: process.env[envMap.MongoUrl]
}

View File

@ -12,13 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import core, { Client, Ref, TxOperations, type Blob, Data, MeasureContext } from '@hcengineering/core'
import attachment, { Attachment } from '@hcengineering/attachment'
import core, {
Client,
Data,
MeasureContext,
Ref,
systemAccountEmail,
TxOperations,
type Blob
} from '@hcengineering/core'
import drive, { createFile } from '@hcengineering/drive'
import love, { MeetingMinutes } from '@hcengineering/love'
import { generateToken } from '@hcengineering/server-token'
import attachment, { Attachment } from '@hcengineering/attachment'
import { getClient } from './client'
import config from './config'
export class WorkspaceClient {
private client!: TxOperations
@ -39,7 +46,7 @@ export class WorkspaceClient {
}
private async initClient (workspace: string): Promise<Client> {
const token = generateToken(config.SystemEmail, { name: workspace })
const token = generateToken(systemAccountEmail, { name: workspace })
const client = await getClient(token)
this.client = new TxOperations(client, core.account.System)
return this.client

View File

@ -11,7 +11,6 @@ export interface Config {
Port: number
Secret: string
ServiceID: string
SystemEmail: string
BrandingPath: string
}
@ -25,7 +24,6 @@ const config: Config = (() => {
Port: parseNumber(process.env.PORT) ?? 4006,
Secret: process.env.SECRET,
ServiceID: process.env.SERVICE_ID,
SystemEmail: process.env.SYSTEM_EMAIL ?? 'anticrm@hc.engineering',
BrandingPath: process.env.BRANDING_PATH ?? ''
}

View File

@ -6,7 +6,7 @@ import { P12Signer } from '@signpdf/signer-p12'
import signpdf from '@signpdf/signpdf'
import { PDFDocument, StandardFonts, degrees, degreesToRadians, rgb } from 'pdf-lib'
import config from './config'
import { systemAccountEmail } from '@hcengineering/core'
interface Rect {
x: number
@ -50,7 +50,7 @@ export async function signPDF (file: Buffer, certp12: Buffer, pwd: string, ctx:
// Make it configurable when will be needed to allow signing for different reasons.
const options: Options = {
name: ctx.title,
contactInfo: config.SystemEmail,
contactInfo: systemAccountEmail,
appName: ctx.title,
reason: 'Export from the system',
location: 'N/A'

View File

@ -13,11 +13,10 @@
// limitations under the License.
//
import { type Client } from '@hcengineering/core'
import { systemAccountEmail, type Client } from '@hcengineering/core'
import { generateToken, type Token } from '@hcengineering/server-token'
import { createClient, getTransactorEndpoint } from '@hcengineering/server-client'
import config from './config'
export class SignController {
private readonly clients: Map<string, Client> = new Map<string, Client>()
@ -50,7 +49,7 @@ export class SignController {
}
private async createPlatformClient (workspace: string): Promise<Client> {
const token = generateToken(config.SystemEmail, {
const token = generateToken(systemAccountEmail, {
name: workspace
})
const endpoint = await getTransactorEndpoint(token)

View File

@ -12,7 +12,6 @@ interface Config {
AccountsURL: string
ServiceID: string
Secret: string
SystemEmail: string
}
const envMap: { [key in keyof Config]: string } = {
@ -28,8 +27,7 @@ const envMap: { [key in keyof Config]: string } = {
AccountsURL: 'ACCOUNTS_URL',
ServiceID: 'SERVICE_ID',
Secret: 'SECRET',
SystemEmail: 'SYSTEM_EMAIL'
Secret: 'SECRET'
}
const defaults: Partial<Config> = {
@ -45,7 +43,6 @@ const defaults: Partial<Config> = {
AccountsURL: undefined,
ServiceID: 'telegram-service',
SystemEmail: 'anticrm@hc.engineering',
Secret: undefined
}
@ -76,7 +73,6 @@ const config = (() => {
MongoURI: process.env[envMap.MongoURI],
AccountsURL: process.env[envMap.AccountsURL],
ServiceID: process.env[envMap.ServiceID],
SystemEmail: process.env[envMap.SystemEmail],
Secret: process.env[envMap.Secret]
}

View File

@ -15,6 +15,7 @@ import core, {
Hierarchy,
MeasureContext,
Ref,
systemAccountEmail,
Tx,
TxCreateDoc,
TxCUD,
@ -31,7 +32,6 @@ import telegramP, { NewTelegramMessage } from '@hcengineering/telegram'
import type { Collection } from 'mongodb'
import { Api } from 'telegram'
import { v4 as uuid } from 'uuid'
import config from './config'
import { platformToTelegram, telegramToPlatform } from './markup'
import { MsgQueue } from './queue'
import type { TelegramConnectionInterface } from './telegram'
@ -151,7 +151,7 @@ export class WorkspaceWorker {
lastMsgStorage: Collection<LastMsgRecord>,
channelsStorage: Collection<WorkspaceChannel>
): Promise<WorkspaceWorker> {
const token = generateToken(config.SystemEmail, { name: workspace })
const token = generateToken(systemAccountEmail, { name: workspace })
const client = await createPlatformClient(token)
const worker = new WorkspaceWorker(