mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
fix problem with lost update
This commit is contained in:
parent
3e32726fa1
commit
eaa4161d14
@ -28,6 +28,10 @@ export class FederationClient {
|
||||
})
|
||||
}
|
||||
|
||||
getEndpoint = () => {
|
||||
return this.endpoint
|
||||
}
|
||||
|
||||
getPublicKey = async (): Promise<string | undefined> => {
|
||||
logger.debug('Federation: getPublicKey from endpoint', this.endpoint)
|
||||
try {
|
||||
|
||||
@ -47,15 +47,25 @@ export class FederationClientFactory {
|
||||
const instance = FederationClientFactory.instanceArray.find(
|
||||
(instance) => instance.id === dbCom.id,
|
||||
)
|
||||
if (instance) {
|
||||
// TODO: found a way to prevent double code with FederationClient::constructor
|
||||
const endpoint = `${dbCom.endPoint.endsWith('/') ? dbCom.endPoint : dbCom.endPoint + '/'}${
|
||||
dbCom.apiVersion
|
||||
}/`
|
||||
// check if endpoint is still the same and not changed meanwhile
|
||||
if (instance && instance.client.getEndpoint() === endpoint) {
|
||||
return instance.client
|
||||
}
|
||||
const client = FederationClientFactory.createFederationClient(dbCom)
|
||||
if (client) {
|
||||
FederationClientFactory.instanceArray.push({
|
||||
id: dbCom.id,
|
||||
client,
|
||||
} as FederationClientInstance)
|
||||
// only update instance if we already have one
|
||||
if (instance) {
|
||||
instance.client = client
|
||||
} else {
|
||||
FederationClientFactory.instanceArray.push({
|
||||
id: dbCom.id,
|
||||
client,
|
||||
} as FederationClientInstance)
|
||||
}
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user