mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-16 05:13:06 +00:00
QFIX: User status (#7601)
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
bc4c94ae2a
commit
bfe2960787
@ -553,6 +553,13 @@ export interface Session {
|
||||
query: DocumentQuery<T>,
|
||||
options?: FindOptions<T>
|
||||
) => Promise<void>
|
||||
findAllRaw: <T extends Doc>(
|
||||
ctx: MeasureContext,
|
||||
pipeline: Pipeline,
|
||||
_class: Ref<Class<T>>,
|
||||
query: DocumentQuery<T>,
|
||||
options?: FindOptions<T>
|
||||
) => Promise<FindResult<T>>
|
||||
searchFulltext: (ctx: ClientSessionCtx, query: SearchQuery, options: SearchOptions) => Promise<void>
|
||||
tx: (ctx: ClientSessionCtx, tx: Tx) => Promise<void>
|
||||
loadChunk: (ctx: ClientSessionCtx, domain: Domain, idx?: number) => Promise<void>
|
||||
|
@ -716,21 +716,38 @@ class TSessionManager implements SessionManager {
|
||||
const user = pipeline.context.modelDb.getAccountByEmail(session.getUser())
|
||||
if (user === undefined) return
|
||||
|
||||
const status = (await pipeline.findAll(ctx, core.class.UserStatus, { user: user._id }, { limit: 1 }))[0]
|
||||
const clientCtx: ClientSessionCtx = {
|
||||
requestId: undefined,
|
||||
pipeline,
|
||||
sendResponse: async (msg) => {
|
||||
// No response
|
||||
},
|
||||
ctx,
|
||||
sendError: async (msg, error: Status) => {
|
||||
// Assume no error send
|
||||
},
|
||||
sendPong: () => {}
|
||||
}
|
||||
const status = (
|
||||
await session.findAllRaw(ctx, pipeline, core.class.UserStatus, { user: user._id }, { limit: 1 })
|
||||
)[0]
|
||||
const txFactory = new TxFactory(user._id, true)
|
||||
if (status === undefined) {
|
||||
const tx = txFactory.createTxCreateDoc(core.class.UserStatus, core.space.Space, {
|
||||
online,
|
||||
user: user._id
|
||||
})
|
||||
await pipeline.tx(ctx, [tx])
|
||||
await session.tx(clientCtx, tx)
|
||||
} else if (status.online !== online) {
|
||||
const tx = txFactory.createTxUpdateDoc(status._class, status.space, status._id, {
|
||||
online
|
||||
})
|
||||
await pipeline.tx(ctx, [tx])
|
||||
await session.tx(clientCtx, tx)
|
||||
}
|
||||
} catch {}
|
||||
} catch (err: any) {
|
||||
ctx.error('failed to set status', { err })
|
||||
Analytics.handleError(err)
|
||||
}
|
||||
}
|
||||
|
||||
async close (ctx: MeasureContext, ws: ConnectionSocket, wsid: string): Promise<void> {
|
||||
|
Loading…
Reference in New Issue
Block a user