From 3295adee5707c8ea6fe603b2f883da81d0625ae9 Mon Sep 17 00:00:00 2001 From: Kristina Date: Mon, 12 May 2025 11:42:58 +0400 Subject: [PATCH] Implement @everyone/@here (#8890) Signed-off-by: Kristina Fefelova --- models/notification/src/index.ts | 40 +- models/notification/src/plugin.ts | 3 +- models/server-activity/src/index.ts | 3 +- models/server-chunter/src/index.ts | 3 +- models/server-notification/src/index.ts | 9 + packages/core/src/storage.ts | 2 + packages/presentation/package.json | 1 + .../src/components/SearchResult.svelte | 30 +- .../src/components/markup/ObjectNode.svelte | 9 +- .../src/components/AttachmentRefInput.svelte | 2 + .../chat-message/ChatMessageInput.svelte | 1 + plugins/contact-assets/lang/cs.json | 6 +- plugins/contact-assets/lang/de.json | 6 +- plugins/contact-assets/lang/en.json | 6 +- plugins/contact-assets/lang/es.json | 6 +- plugins/contact-assets/lang/fr.json | 6 +- plugins/contact-assets/lang/it.json | 6 +- plugins/contact-assets/lang/ja.json | 6 +- plugins/contact-assets/lang/pt.json | 6 +- plugins/contact-assets/lang/ru.json | 6 +- plugins/contact-assets/lang/zh.json | 6 +- plugins/contact/src/index.ts | 10 +- .../inbox/InboxGroupedListView.svelte | 5 +- .../MentionInboxNotificationPresenter.svelte | 47 +++ .../settings/NotificationGroupSetting.svelte | 25 +- .../settings/NotificationSettings.svelte | 4 +- plugins/notification-resources/src/index.ts | 2 + plugins/notification-resources/src/utils.ts | 4 +- plugins/notification/src/index.ts | 29 +- .../src/components/MentionList.svelte | 5 + .../src/components/MentionPopup.svelte | 84 +++- .../src/components/ReferenceInput.svelte | 5 +- .../src/components/extension/reference.ts | 10 +- .../src/components/extension/suggestion.ts | 10 +- .../activity-resources/src/references.ts | 374 ++++++++---------- server-plugins/chunter-resources/src/index.ts | 43 +- server-plugins/gmail-resources/src/index.ts | 6 +- .../notification-resources/src/index.ts | 22 +- .../notification-resources/src/types.ts | 4 +- .../notification-resources/src/utils.ts | 69 ++-- server-plugins/notification/src/index.ts | 6 +- server-plugins/time-resources/src/index.ts | 11 +- server/core/src/types.ts | 3 + server/middleware/src/index.ts | 1 + server/middleware/src/triggers.ts | 1 + server/middleware/src/userStatus.ts | 79 ++++ server/server-pipeline/src/pipeline.ts | 4 +- 47 files changed, 675 insertions(+), 351 deletions(-) create mode 100644 plugins/notification-resources/src/components/inbox/MentionInboxNotificationPresenter.svelte create mode 100644 server/middleware/src/userStatus.ts diff --git a/models/notification/src/index.ts b/models/notification/src/index.ts index d8b2bc8717..69caac5bbf 100644 --- a/models/notification/src/index.ts +++ b/models/notification/src/index.ts @@ -63,10 +63,9 @@ import { DOMAIN_DOC_NOTIFY, type ActivityInboxNotification, type ActivityNotificationViewlet, - type BaseNotificationType, + type NotificationType, type BrowserNotification, type CommonInboxNotification, - type CommonNotificationType, type DocNotifyContext, type InboxNotification, type MentionInboxNotification, @@ -79,7 +78,6 @@ import { type NotificationProviderDefaults, type NotificationProviderSetting, type NotificationTemplate, - type NotificationType, type NotificationTypeSetting, type PushSubscription, type PushSubscriptionKeys @@ -116,26 +114,19 @@ export class TPushSubscription extends TDoc implements PushSubscription { keys!: PushSubscriptionKeys } -@Model(notification.class.BaseNotificationType, core.class.Doc, DOMAIN_MODEL) -export class TBaseNotificationType extends TDoc implements BaseNotificationType { +@Model(notification.class.NotificationType, core.class.Doc, DOMAIN_MODEL) +export class TNotificationType extends TDoc implements NotificationType { generated!: boolean label!: IntlString group!: Ref defaultEnabled!: boolean hidden!: boolean templates?: NotificationTemplate -} - -@Model(notification.class.NotificationType, notification.class.BaseNotificationType) -export class TNotificationType extends TBaseNotificationType implements NotificationType { txClasses!: Ref>[] objectClass!: Ref> onlyOwn?: boolean } -@Model(notification.class.CommonNotificationType, notification.class.BaseNotificationType) -export class TCommonNotificationType extends TBaseNotificationType implements CommonNotificationType {} - @Model(notification.class.NotificationGroup, core.class.Doc, DOMAIN_MODEL) export class TNotificationGroup extends TDoc implements NotificationGroup { label!: IntlString @@ -154,7 +145,7 @@ export class TNotificationPreferencesGroup extends TDoc implements NotificationP @Model(notification.class.NotificationTypeSetting, preference.class.Preference) export class TNotificationTypeSetting extends TPreference implements NotificationTypeSetting { declare attachedTo: Ref - type!: Ref + type!: Ref enabled!: boolean } @@ -247,6 +238,8 @@ export class TInboxNotification extends TDoc implements InboxNotification { declare space: Ref + types?: Ref[] + title?: IntlString body?: IntlString intlParams?: Record @@ -319,9 +312,9 @@ export class TNotificationProvider extends TDoc implements NotificationProvider @Model(notification.class.NotificationProviderDefaults, core.class.Doc) export class TNotificationProviderDefaults extends TDoc implements NotificationProviderDefaults { provider!: Ref - excludeIgnore?: Ref[] - ignoredTypes!: Ref[] - enabledTypes!: Ref[] + excludeIgnore?: Ref[] + ignoredTypes!: Ref[] + enabledTypes!: Ref[] } export const notificationActionTemplates = template({ @@ -363,8 +356,7 @@ export function createModel (builder: Builder): void { TCommonInboxNotification, TNotificationContextPresenter, TActivityNotificationViewlet, - TBaseNotificationType, - TCommonNotificationType, + TNotificationType, TMentionInboxNotification, TPushSubscription, TNotificationProvider, @@ -558,15 +550,20 @@ export function createModel (builder: Builder): void { builder.mixin(notification.class.CommonInboxNotification, core.class.Class, view.mixin.ObjectPresenter, { presenter: notification.component.CommonInboxNotificationPresenter }) + builder.mixin(notification.class.MentionInboxNotification, core.class.Class, view.mixin.ObjectPresenter, { + presenter: notification.component.MentionInboxNotificationPresenter + }) builder.createDoc( - notification.class.CommonNotificationType, + notification.class.NotificationType, core.space.Model, { label: activity.string.Mentions, generated: false, hidden: false, group: notification.ids.NotificationGroup, + txClasses: [core.class.TxCreateDoc, core.class.TxUpdateDoc], + objectClass: core.class.Doc, defaultEnabled: true, templates: { textTemplate: '{sender} mentioned you in {doc}: {message}', @@ -574,9 +571,8 @@ export function createModel (builder: Builder): void { subjectTemplate: 'You were mentioned in {doc}' } }, - notification.ids.MentionCommonNotificationType + notification.ids.MentionNotificationType ) - createAction( builder, { @@ -808,7 +804,7 @@ export function generateClassNotificationTypes ( hierarchy.isDerived(_class, core.class.AttachedDoc) ? core.class.AttachedDoc : core.class.Doc ) const filtered = Array.from(attributes.values()).filter((p) => p.hidden !== true && p.readonly !== true) - const enabledInboxTypes: Ref[] = [] + const enabledInboxTypes: Ref[] = [] for (const attribute of filtered) { if (ignoreKeys.includes(attribute.name)) continue diff --git a/models/notification/src/plugin.ts b/models/notification/src/plugin.ts index 3f81a3eeab..5d0a661d19 100644 --- a/models/notification/src/plugin.ts +++ b/models/notification/src/plugin.ts @@ -47,7 +47,8 @@ export default mergeIds(notificationId, notification, { component: { NotificationSettings: '' as AnyComponent, ActivityInboxNotificationPresenter: '' as AnyComponent, - CommonInboxNotificationPresenter: '' as AnyComponent + CommonInboxNotificationPresenter: '' as AnyComponent, + MentionInboxNotificationPresenter: '' as AnyComponent }, function: { HasDocNotifyContextPinAction: '' as Resource<(doc?: Doc | Doc[]) => Promise>, diff --git a/models/server-activity/src/index.ts b/models/server-activity/src/index.ts index fa0ffedf3c..6a3d4a5fa3 100644 --- a/models/server-activity/src/index.ts +++ b/models/server-activity/src/index.ts @@ -59,7 +59,8 @@ export function createModel (builder: Builder): void { }) builder.createDoc(serverCore.class.Trigger, core.space.Model, { - trigger: serverActivity.trigger.OnDocRemoved + trigger: serverActivity.trigger.OnDocRemoved, + isAsync: true }) builder.createDoc(serverCore.class.Trigger, core.space.Model, { diff --git a/models/server-chunter/src/index.ts b/models/server-chunter/src/index.ts index 4f63c95de9..38e78de8d7 100644 --- a/models/server-chunter/src/index.ts +++ b/models/server-chunter/src/index.ts @@ -80,7 +80,8 @@ export function createModel (builder: Builder): void { txMatch: { _class: core.class.TxRemoveDoc, objectClass: chunter.class.ChatMessage - } + }, + isAsync: true }) builder.createDoc(serverCore.class.Trigger, core.space.Model, { diff --git a/models/server-notification/src/index.ts b/models/server-notification/src/index.ts index 2af54c602e..858ed164d3 100644 --- a/models/server-notification/src/index.ts +++ b/models/server-notification/src/index.ts @@ -98,4 +98,13 @@ export function createModel (builder: Builder): void { objectClass: notification.class.InboxNotification } }) + + builder.mixin( + notification.ids.MentionNotificationType, + notification.class.NotificationType, + serverNotification.mixin.TypeMatch, + { + func: serverNotification.function.MentionTypeMatch + } + ) } diff --git a/packages/core/src/storage.ts b/packages/core/src/storage.ts index a7eb9ba51f..a1959df782 100644 --- a/packages/core/src/storage.ts +++ b/packages/core/src/storage.ts @@ -244,6 +244,8 @@ export interface SearchResultDoc { shortTitleComponent?: SearchComponentWithProps title?: string titleComponent?: SearchComponentWithProps + description?: string + emojiIcon?: string score?: number doc: Pick } diff --git a/packages/presentation/package.json b/packages/presentation/package.json index 63866c6a0a..d602818786 100644 --- a/packages/presentation/package.json +++ b/packages/presentation/package.json @@ -42,6 +42,7 @@ "dependencies": { "@hcengineering/analytics": "^0.6.0", "@hcengineering/client": "^0.6.18", + "@hcengineering/contact": "^0.6.24", "@hcengineering/collaborator-client": "^0.6.4", "@hcengineering/communication-client-query": "0.1.180", "@hcengineering/communication-sdk-types": "0.1.180", diff --git a/packages/presentation/src/components/SearchResult.svelte b/packages/presentation/src/components/SearchResult.svelte index 87b790682f..e70f2e9c6f 100644 --- a/packages/presentation/src/components/SearchResult.svelte +++ b/packages/presentation/src/components/SearchResult.svelte @@ -14,9 +14,9 @@ // limitations under the License. --> + +{#if message} + +{:else} + +{/if} diff --git a/plugins/notification-resources/src/components/settings/NotificationGroupSetting.svelte b/plugins/notification-resources/src/components/settings/NotificationGroupSetting.svelte index 1051dc2848..58394ffcab 100644 --- a/plugins/notification-resources/src/components/settings/NotificationGroupSetting.svelte +++ b/plugins/notification-resources/src/components/settings/NotificationGroupSetting.svelte @@ -15,10 +15,9 @@