Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract trigger for pushes #7767

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions models/notification/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ export class TInboxNotification extends TDoc implements InboxNotification {
@Prop(TypeBoolean(), core.string.Boolean)
archived!: boolean

objectId!: Ref<Doc>
objectClass!: Ref<Class<Doc>>

declare space: Ref<PersonSpace>

title?: IntlString
Expand Down
9 changes: 9 additions & 0 deletions models/server-notification/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,13 @@ export function createModel (builder: Builder): void {
mixin: contact.mixin.Employee
}
})

builder.createDoc(serverCore.class.Trigger, core.space.Model, {
trigger: serverNotification.trigger.PushNotificationsHandler,
isAsync: true,
txMatch: {
_class: core.class.TxCreateDoc,
objectClass: notification.class.InboxNotification
}
})
}
2 changes: 2 additions & 0 deletions plugins/notification/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ export interface InboxNotification extends Doc<PersonSpace> {
isViewed: boolean

docNotifyContext: Ref<DocNotifyContext>
objectId: Ref<Doc>
objectClass: Ref<Class<Doc>>

// For browser notifications
title?: IntlString
Expand Down
8 changes: 2 additions & 6 deletions server-plugins/activity-resources/src/references.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ export async function getPersonNotificationTxes (
messageHtml: reference.message,
mentionedIn: reference.attachedDocId ?? reference.srcDocId,
mentionedInClass: reference.attachedDocClass ?? reference.srcDocClass,
objectId: reference.srcDocId,
objectClass: reference.srcDocClass,
user: receiver[0]._id,
isViewed: false,
archived: false
Expand Down Expand Up @@ -238,24 +240,18 @@ export async function getPersonNotificationTxes (
modifiedOn: originTx.modifiedOn,
modifiedBy: sender._id
}
const subscriptions = await control.findAll(control.ctx, notification.class.PushSubscription, {
user: receiverInfo._id
})

const msg = control.hierarchy.isDerived(data.mentionedInClass, activity.class.ActivityMessage)
? (await control.findAll(control.ctx, data.mentionedInClass, { _id: data.mentionedIn }))[0]
: undefined
await applyNotificationProviders(
notificationData,
notifyResult,
reference.srcDocId,
reference.srcDocClass,
control,
res,
doc,
receiverInfo,
senderInfo,
subscriptions,
notification.class.MentionInboxNotification,
msg as ActivityMessage
)
Expand Down
Loading
Loading