mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-13 13:17:45 +02:00
Fix context create (#51)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
@@ -81,6 +81,7 @@ export interface AddedCollaboratorsEvent extends BaseResponseEvent {
|
||||
card: CardID
|
||||
cardType: CardType
|
||||
collaborators: AccountID[]
|
||||
date: Date
|
||||
}
|
||||
|
||||
export interface RemovedCollaboratorsEvent extends BaseResponseEvent {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ async function onMessagesRemoved(ctx: TriggerCtx, event: MessagesRemovedEvent):
|
||||
replies: 'decrement'
|
||||
}
|
||||
|
||||
return [threadEvent]
|
||||
return [patchEvent, threadEvent]
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user