mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-25 09:50:19 +00:00
UBERF-5364: Fix targeted broadcast on server (#4565)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
d98fb41ac3
commit
2d9eb8ec32
server/core/src
@ -69,6 +69,7 @@ import { FullTextPipelineStage } from './indexer/types'
|
||||
import serverCore from './plugin'
|
||||
import { Triggers } from './triggers'
|
||||
import type {
|
||||
BroadcastFunc,
|
||||
ContentTextAdapter,
|
||||
ContentTextAdapterConfiguration,
|
||||
FullTextAdapter,
|
||||
@ -626,11 +627,11 @@ class TServerStorage implements ServerStorage {
|
||||
findAllCtx: findAll,
|
||||
modelDb: this.modelDb,
|
||||
hierarchy: this.hierarchy,
|
||||
apply: async (tx, broadcast) => {
|
||||
return await this.apply(ctx, tx, broadcast)
|
||||
apply: async (tx, broadcast, target) => {
|
||||
return await this.apply(ctx, tx, broadcast, target)
|
||||
},
|
||||
applyCtx: async (ctx, tx, broadcast) => {
|
||||
return await this.apply(ctx, tx, broadcast)
|
||||
applyCtx: async (ctx, tx, broadcast, target) => {
|
||||
return await this.apply(ctx, tx, broadcast, target)
|
||||
},
|
||||
// Will create a live query if missing and return values immediately if already asked.
|
||||
queryFind: async (_class, query, options) => {
|
||||
@ -719,14 +720,14 @@ class TServerStorage implements ServerStorage {
|
||||
return { passed, onEnd }
|
||||
}
|
||||
|
||||
async apply (ctx: MeasureContext, txes: Tx[], broadcast: boolean): Promise<TxResult> {
|
||||
async apply (ctx: MeasureContext, txes: Tx[], broadcast: boolean, target?: string[]): Promise<TxResult> {
|
||||
const result = await this.processTxes(ctx, txes)
|
||||
let derived: Tx[] = []
|
||||
|
||||
derived = result[1]
|
||||
|
||||
if (broadcast) {
|
||||
this.options?.broadcast?.([...txes, ...derived])
|
||||
this.options?.broadcast?.([...txes, ...derived], target)
|
||||
}
|
||||
|
||||
return result[0]
|
||||
@ -867,7 +868,7 @@ export interface ServerStorageOptions {
|
||||
// Indexing is not required to be started for upgrade mode.
|
||||
upgrade: boolean
|
||||
|
||||
broadcast?: (tx: Tx[]) => void
|
||||
broadcast?: BroadcastFunc
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
|
@ -76,8 +76,8 @@ export class Triggers {
|
||||
ctx,
|
||||
txFactory: new TxFactory(tx.modifiedBy, true),
|
||||
findAll: async (clazz, query, options) => await ctrl.findAllCtx(ctx, clazz, query, options),
|
||||
apply: async (tx, broadcast) => {
|
||||
return await ctrl.applyCtx(ctx, tx, broadcast)
|
||||
apply: async (tx, broadcast, target) => {
|
||||
return await ctrl.applyCtx(ctx, tx, broadcast, target)
|
||||
}
|
||||
}))
|
||||
)
|
||||
|
@ -135,8 +135,8 @@ export interface TriggerControl {
|
||||
fx: (f: () => Promise<void>) => void
|
||||
|
||||
// Bulk operations in case trigger require some
|
||||
apply: (tx: Tx[], broadcast: boolean) => Promise<TxResult>
|
||||
applyCtx: (ctx: MeasureContext, tx: Tx[], broadcast: boolean) => Promise<TxResult>
|
||||
apply: (tx: Tx[], broadcast: boolean, target?: string[]) => Promise<TxResult>
|
||||
applyCtx: (ctx: MeasureContext, tx: Tx[], broadcast: boolean, target?: string[]) => Promise<TxResult>
|
||||
|
||||
// Will create a live query if missing and return values immediately if already asked.
|
||||
queryFind: <T extends Doc>(
|
||||
|
Loading…
Reference in New Issue
Block a user