UBERF-4289: Allow to configure user agent (#3995)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2023-11-15 14:05:05 +07:00 committed by GitHub
parent f8d0237bbb
commit b74971e29d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 3 deletions

View File

@ -64,6 +64,7 @@ export function serveAccount (methods: Record<string, AccountMethod>, productId
}
setMetadata(toolPlugin.metadata.Endpoint, endpointUri)
setMetadata(toolPlugin.metadata.Transactor, transactorUri)
setMetadata(toolPlugin.metadata.UserAgent, 'AccountService')
let client: MongoClient

View File

@ -21,6 +21,7 @@ import serverToken from '@hcengineering/server-token'
import got from 'got'
import { ObjectId } from 'mongodb'
import config from './config'
import toolPlugin from '@hcengineering/server-tool'
/**
* @public
@ -72,6 +73,8 @@ export class PlatformWorker {
secretKey: config.MinioSecretKey
})
setMetadata(toolPlugin.metadata.UserAgent, config.ServiceID)
await this.backup().then(() => {
void this.schedule()
})

View File

@ -16,8 +16,9 @@
import client, { clientId } from '@hcengineering/client'
import { Client, systemAccountEmail, WorkspaceId } from '@hcengineering/core'
import { addLocation, getResource, setMetadata } from '@hcengineering/platform'
import { addLocation, getMetadata, getResource, setMetadata } from '@hcengineering/platform'
import { generateToken } from '@hcengineering/server-token'
import plugin from './plugin'
/**
* @public
@ -37,7 +38,14 @@ export async function connect (
setMetadata(client.metadata.UseBinaryProtocol, true)
setMetadata(client.metadata.UseProtocolCompression, true)
setMetadata(client.metadata.ClientSocketFactory, (url) => new WebSocket(url))
setMetadata(client.metadata.ClientSocketFactory, (url) => {
const socket = new WebSocket(url, {
headers: {
'User-Agent': getMetadata(plugin.metadata.UserAgent) ?? 'Anticrm Tool Client'
}
})
return socket
})
addLocation(clientId, () => import('@hcengineering/client-resources'))
return await (

View File

@ -12,7 +12,8 @@ const toolPlugin = plugin(toolId, {
metadata: {
Endpoint: '' as Metadata<string>,
Transactor: '' as Metadata<string>,
InitWorkspace: '' as Metadata<string>
InitWorkspace: '' as Metadata<string>,
UserAgent: '' as Metadata<string>
}
})