Skip to content

Commit d245b1c

Browse files
authored
Merge branch 'develop' into ai-bot-improvements
2 parents 6179dba + 499b3bb commit d245b1c

File tree

9 files changed

+60
-44
lines changed

9 files changed

+60
-44
lines changed

packages/ui/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ export interface CalendarItem {
465465
date: Timestamp
466466
dueDate: Timestamp
467467
day: number
468+
blockTime: boolean
468469
access: 'freeBusyReader' | 'reader' | 'writer' | 'owner'
469470
}
470471

plugins/calendar-resources/src/components/DayCalendar.svelte

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
allDay: event.allDay,
119119
date: eventStart,
120120
dueDate: eventEnd,
121+
blockTime: event.blockTime,
121122
day,
122123
access: event.access
123124
})
@@ -136,6 +137,7 @@
136137
result.push({
137138
_id: event._id,
138139
allDay: event.allDay,
140+
blockTime: event.blockTime,
139141
date: eventStart,
140142
dueDate: eventEnd,
141143
day: -1,
@@ -343,8 +345,9 @@
343345
}
344346
}
345347
346-
const calcTime = (events: CalendarItem[]): number => {
347-
if (events.length === 0) return 0
348+
const calcTime = (_events: CalendarItem[]): number => {
349+
if (_events.length === 0) return 0
350+
const events = _events.filter((ev) => ev.blockTime)
348351
349352
// Extract and sort intervals by start time
350353
const intervals = events.map((it) => [it.date, it.dueDate]).sort((a, b) => a[0] - b[0])

plugins/tracker-resources/src/components/myissues/MyIssues.svelte

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
-->
1515
<script lang="ts">
1616
import { getCurrentEmployee } from '@hcengineering/contact'
17-
import { Doc, DocumentQuery, getCurrentAccount, Ref } from '@hcengineering/core'
17+
import core, { DocumentQuery, getCurrentAccount, Ref } from '@hcengineering/core'
1818
import type { IntlString, Asset } from '@hcengineering/platform'
19-
import { createQuery } from '@hcengineering/presentation'
19+
import { createQuery, getClient } from '@hcengineering/presentation'
2020
import type { Issue, IssueStatus } from '@hcengineering/tracker'
2121
import { IModeSelector, resolvedLocationStore } from '@hcengineering/ui'
2222
import { createEventDispatcher } from 'svelte'
@@ -28,6 +28,8 @@
2828
export let config: [string, IntlString, object][] = []
2929
export let icon: Asset | undefined = undefined
3030
31+
const client = getClient()
32+
const hierarchy = client.getHierarchy()
3133
const socialIds = getCurrentAccount().socialIds
3234
const acc = getCurrentAccount().uuid
3335
const dispatch = createEventDispatcher()
@@ -64,16 +66,16 @@
6466
6567
const subscribedQuery = createQuery()
6668
$: subscribedQuery.query(
67-
tracker.class.Issue,
68-
{ 'notification:mixin:Collaborators.collaborators': acc },
69-
(result) => {
70-
const newSub = result.map((p) => p._id as Ref<Doc> as Ref<Issue>)
69+
core.class.Collaborator,
70+
{ collaborator: acc, attachedToClass: { $in: hierarchy.getDescendants(tracker.class.Issue) } },
71+
(collaborators) => {
72+
const newSub = collaborators.map((it) => it.attachedTo as Ref<Issue>)
7173
const curSub = subscribed._id.$in
7274
if (curSub.length !== newSub.length || curSub.some((id, i) => newSub[i] !== id)) {
7375
subscribed = { _id: { $in: newSub } }
7476
}
7577
},
76-
{ sort: { _id: 1 }, projection: { _id: 1 } }
78+
{ sort: { attachedTo: 1 }, projection: { attachedTo: 1 } }
7779
)
7880
7981
$: queries = { assigned, active, backlog, created, subscribed }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
huly-schedule ghcr.io/hcengineering/service_huly-schedule:v0.0.6
1+
huly-schedule ghcr.io/hcengineering/service_huly-schedule:v0.0.7

server-plugins/calendar-resources/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ async function onEventCreate (ctx: TxCreateDoc<Event>, control: TriggerControl):
372372
const { _class, space, attachedTo, attachedToClass, collection, ...attr } = event
373373
const data = attr as any as Data<Event>
374374
const calendars = await control.findAll(control.ctx, calendar.class.Calendar, { hidden: false })
375+
const events = await control.findAll(control.ctx, calendar.class.Event, { eventId: event.eventId })
375376
const access = 'reader'
376377
for (const part of event.participants) {
377378
const socialIds = await getSocialIds(control, part as Ref<Person>)
@@ -382,6 +383,7 @@ async function onEventCreate (ctx: TxCreateDoc<Event>, control: TriggerControl):
382383
const user = primarySocialString
383384
const calendar = getCalendar(calendars, socialStrings)
384385
if (calendar === undefined) continue
386+
if (events.find((p) => p.user === user) !== undefined) continue
385387
const innerTx = control.txFactory.createTxCreateDoc(
386388
_class,
387389
space,

server-plugins/notification-resources/src/index.ts

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,7 @@ async function getTxCollabs (
853853
(await control.findAll(ctx, core.class.Collaborator, {
854854
attachedTo: doc._id
855855
}))
856+
cache.set(doc._id, collaborators)
856857
const collabs = collaborators.map((c) => c.collaborator)
857858
const ops = isMixinTx(tx) ? tx.attributes : (tx as TxUpdateDoc<Doc>).operations
858859
const newCollaborators = (await getNewCollaborators(ops, mixin, doc._class, control)).filter(
@@ -1375,45 +1376,51 @@ async function updateCollaborators (
13751376
tx: TxCUD<Doc>,
13761377
cache: Map<Ref<Doc>, Collaborator[]>
13771378
): Promise<Tx[]> {
1378-
if (tx._class !== core.class.TxCreateDoc && tx._class !== core.class.TxRemoveDoc) return []
1379-
if (tx.objectClass !== core.class.Collaborator) return []
1379+
if (tx._class !== core.class.TxUpdateDoc && tx._class !== core.class.TxMixin) return []
13801380

13811381
const hierarchy = control.hierarchy
13821382

1383+
if (hierarchy.classHierarchyMixin(tx.objectClass, activity.mixin.ActivityDoc) === undefined) return []
1384+
13831385
const mixin = getClassCollaborators(control.modelDb, hierarchy, tx.objectClass)
1384-
if (mixin === undefined || tx.attachedToClass === undefined || tx.attachedTo === undefined) return []
1386+
if (mixin === undefined) return []
13851387

1386-
if (hierarchy.classHierarchyMixin(tx.attachedToClass, activity.mixin.ActivityDoc) === undefined) return []
1388+
const doc = (await control.findAll(ctx, tx.objectClass, { _id: tx.objectId }, { limit: 1 }))[0]
1389+
if (doc === undefined) return []
1390+
1391+
const collabsResult = await getTxCollabs(ctx, tx, control, cache, doc)
1392+
if (collabsResult.added.length === 0 && collabsResult.removed.length === 0) return []
13871393

1388-
const contexts = await control.findAll(control.ctx, notification.class.DocNotifyContext, { objectId: tx.attachedTo })
13891394
const res: Tx[] = []
1390-
if (tx._class === core.class.TxCreateDoc) {
1391-
const collab = TxProcessor.createDoc2Doc(tx as TxCreateDoc<Collaborator>)
1392-
const addedInfo = await getReceiversInfo(ctx, [collab.collaborator], control)
1393-
1394-
for (const info of addedInfo.values()) {
1395-
const context = getDocNotifyContext(control, contexts, tx.attachedTo, info.account)
1396-
if (context !== undefined) {
1397-
if (context.hidden) {
1398-
res.push(control.txFactory.createTxUpdateDoc(context._class, context.space, context._id, { hidden: false }))
1399-
}
1395+
1396+
const { txes: collabTxes } = await createSyncCollaboratorsTxes(
1397+
ctx,
1398+
control,
1399+
cache,
1400+
doc._id,
1401+
doc._class,
1402+
doc.space,
1403+
collabsResult.added,
1404+
collabsResult.removed
1405+
)
1406+
1407+
res.push(...collabTxes)
1408+
1409+
const contexts = await control.findAll(control.ctx, notification.class.DocNotifyContext, { objectId: tx.attachedTo })
1410+
const addedInfo = collabsResult.added.length > 0 ? await getReceiversInfo(ctx, collabsResult.added, control) : []
1411+
1412+
for (const info of addedInfo) {
1413+
const context = getDocNotifyContext(control, contexts, doc._id, info.account)
1414+
if (context !== undefined) {
1415+
if (context.hidden) {
1416+
res.push(control.txFactory.createTxUpdateDoc(context._class, context.space, context._id, { hidden: false }))
14001417
}
1401-
await createNotifyContext(
1402-
ctx,
1403-
control,
1404-
tx.attachedTo,
1405-
tx.attachedToClass,
1406-
tx.objectSpace,
1407-
info,
1408-
tx.modifiedBy,
1409-
undefined,
1410-
tx
1411-
)
14121418
}
1413-
} else {
1414-
const removed = control.removedMap.get(tx.objectId) as Collaborator
1415-
if (removed === undefined) return []
1416-
await removeContexts(ctx, contexts, [removed.collaborator], control)
1419+
await createNotifyContext(ctx, control, doc._id, doc._class, doc.space, info, tx.modifiedBy, undefined, tx)
1420+
}
1421+
1422+
if (collabsResult.removed.length > 0) {
1423+
await removeContexts(ctx, contexts, collabsResult.removed, control)
14171424
}
14181425

14191426
return res

server/account/src/operations.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
buildSocialIdString,
2222
concatLink,
2323
isActiveMode,
24+
isDeletingMode,
2425
isWorkspaceCreating,
2526
type MeasureContext,
2627
type Person,
@@ -1320,7 +1321,7 @@ export async function getUserWorkspaces (
13201321
const { account } = decodeTokenVerbose(ctx, token)
13211322

13221323
return (await db.getAccountWorkspaces(account)).filter(
1323-
(ws) => !ws.status.isDisabled || isWorkspaceCreating(ws.status.mode)
1324+
(ws) => isWorkspaceCreating(ws.status.mode) || !(isDeletingMode(ws.status.mode) || ws.status.isDisabled)
13241325
)
13251326
}
13261327

server/postgres/src/storage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,8 +1488,8 @@ abstract class PostgresAdapterBase implements DbAdapter {
14881488
return type === 'common'
14891489
? `${tlkey} = ${vars.add(value, valType)}`
14901490
: type === 'array'
1491-
? `${tkey} @> '${typeof value === 'string' ? '{"' + value + '"}' : value}'`
1492-
: `${tkey} @> '${typeof value === 'string' ? '"' + value + '"' : value}'`
1491+
? `${tkey} @> '${typeof value === 'string' ? '{"' + escape(value) + '"}' : value}'`
1492+
: `${tkey} @> '${typeof value === 'string' ? '"' + escape(value) + '"' : value}'`
14931493
}
14941494

14951495
private getReverseProjection (vars: ValuesVariables, join: JoinProps): string[] {

0 commit comments

Comments
 (0)