// // Copyright © 2020, 2021 Anticrm Platform Contributors. // Copyright © 2021, 2022 Hardcore Engineering Inc. // // Licensed under the Eclipse Public License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. You may // obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // // See the License for the specific language governing permissions and // limitations under the License. // import type { Account, AttachedDoc, Class, Doc, Ref, Space, Timestamp, TxCUD } from '@anticrm/core' import type { Asset, IntlString, Plugin, Resource } from '@anticrm/platform' import { plugin } from '@anticrm/platform' import { AnyComponent } from '@anticrm/ui' /** * @public */ export interface LastView extends AttachedDoc { lastView: Timestamp user: Ref } /** * @public */ export interface Notification extends AttachedDoc { tx: Ref> status: NotificationStatus } /** * @public */ export interface EmailNotification extends Doc { sender: string receivers: string[] subject: string text: string html?: string status: 'new' | 'sent' } /** * @public */ export enum NotificationStatus { New, Read } /** * @public */ export interface NotificationType extends Doc { label: IntlString } /** * @public */ export interface NotificationProvider extends Doc { label: IntlString default: boolean } /** * @public */ export interface NotificationSetting extends Doc { type: Ref provider: Ref enabled: boolean } /** * @public */ export const notificationId = 'notification' as Plugin /** * @public */ export interface NotificationClient { updateLastView: (_id: Ref, _class: Ref>, time?: Timestamp, force?: boolean) => Promise } /** * @public */ export type NotificationClientFactoy = () => NotificationClient /** * @public */ const notification = plugin(notificationId, { class: { LastView: '' as Ref>, Notification: '' as Ref>, EmailNotification: '' as Ref>, NotificationType: '' as Ref>, NotificationProvider: '' as Ref>, NotificationSetting: '' as Ref> }, ids: { MentionNotification: '' as Ref, PlatformNotification: '' as Ref, EmailNotification: '' as Ref, NotificationSettings: '' as Ref }, component: { NotificationsPopup: '' as AnyComponent, NotificationPresenter: '' as AnyComponent, LastViewEditor: '' as AnyComponent }, icon: { Notifications: '' as Asset, Track: '' as Asset, DontTrack: '' as Asset }, space: { Notifications: '' as Ref }, string: { Notification: '' as IntlString, Notifications: '' as IntlString }, function: { GetNotificationClient: '' as Resource } }) export default notification