Fix context create (#51)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina
2025-05-07 19:29:44 +04:00
committed by GitHub
parent b4dcc00ccf
commit f349f8aad9
5 changed files with 18 additions and 6 deletions
+1 -1
View File
@@ -1 +1 @@
0.1.176
0.1.178
@@ -81,6 +81,7 @@ export interface AddedCollaboratorsEvent extends BaseResponseEvent {
card: CardID
cardType: CardType
collaborators: AccountID[]
date: Date
}
export interface RemovedCollaboratorsEvent extends BaseResponseEvent {
+4 -2
View File
@@ -191,7 +191,8 @@ export class DatabaseMiddleware extends BaseMiddleware implements Middleware {
}
private async addCollaborators(event: AddCollaboratorsEvent): Promise<Result> {
const added = await this.db.addCollaborators(event.card, event.cardType, event.collaborators, event.date)
const date = event.date ?? new Date()
const added = await this.db.addCollaborators(event.card, event.cardType, event.collaborators, date)
if (added.length === 0) return {}
return {
responseEvent: {
@@ -199,7 +200,8 @@ export class DatabaseMiddleware extends BaseMiddleware implements Middleware {
type: NotificationResponseEventType.AddedCollaborators,
card: event.card,
cardType: event.cardType,
collaborators: added
collaborators: added,
date
}
}
}
+1 -1
View File
@@ -71,7 +71,7 @@ async function onMessagesRemoved(ctx: TriggerCtx, event: MessagesRemovedEvent):
replies: 'decrement'
}
return [threadEvent]
return [patchEvent, threadEvent]
})
}
+11 -2
View File
@@ -14,10 +14,11 @@
//
import {
LabelRequestEventType,
NotificationResponseEventType,
type AddedCollaboratorsEvent,
LabelRequestEventType,
type NotificationContextUpdatedEvent,
NotificationRequestEventType,
NotificationResponseEventType,
type RemovedCollaboratorsEvent,
type RequestEvent
} from '@hcengineering/communication-sdk-types'
@@ -36,6 +37,14 @@ async function onAddedCollaborators(ctx: TriggerCtx, event: AddedCollaboratorsEv
account: collaborator,
label: SubscriptionLabelID
})
result.push({
type: NotificationRequestEventType.CreateNotificationContext,
account: collaborator,
card,
lastUpdate: event.date,
lastView: event.date
})
}
return result
}