feat(server): notification system (#10053)

closes CLOUD-52
This commit is contained in:
fengmk2
2025-03-06 15:25:05 +00:00
parent 81694a1144
commit 7302c4f954
20 changed files with 2356 additions and 14 deletions

View File

@@ -330,7 +330,7 @@ type EditorType {
name: String!
}
union ErrorDataUnion = AlreadyInSpaceDataType | BlobNotFoundDataType | CopilotContextFileNotSupportedDataType | CopilotDocNotFoundDataType | CopilotFailedToMatchContextDataType | CopilotFailedToModifyContextDataType | CopilotInvalidContextDataType | CopilotMessageNotFoundDataType | CopilotPromptNotFoundDataType | CopilotProviderSideErrorDataType | DocActionDeniedDataType | DocHistoryNotFoundDataType | DocNotFoundDataType | DocUpdateBlockedDataType | ExpectToGrantDocUserRolesDataType | ExpectToRevokeDocUserRolesDataType | ExpectToUpdateDocUserRoleDataType | GraphqlBadRequestDataType | InvalidEmailDataType | InvalidHistoryTimestampDataType | InvalidLicenseUpdateParamsDataType | InvalidOauthCallbackCodeDataType | InvalidPasswordLengthDataType | InvalidRuntimeConfigTypeDataType | MemberNotFoundInSpaceDataType | MissingOauthQueryParameterDataType | NotInSpaceDataType | QueryTooLongDataType | RuntimeConfigNotFoundDataType | SameSubscriptionRecurringDataType | SpaceAccessDeniedDataType | SpaceNotFoundDataType | SpaceOwnerNotFoundDataType | SpaceShouldHaveOnlyOneOwnerDataType | SubscriptionAlreadyExistsDataType | SubscriptionNotExistsDataType | SubscriptionPlanNotFoundDataType | UnknownOauthProviderDataType | UnsupportedClientVersionDataType | UnsupportedSubscriptionPlanDataType | ValidationErrorDataType | VersionRejectedDataType | WorkspaceMembersExceedLimitToDowngradeDataType | WorkspacePermissionNotFoundDataType | WrongSignInCredentialsDataType
union ErrorDataUnion = AlreadyInSpaceDataType | BlobNotFoundDataType | CopilotContextFileNotSupportedDataType | CopilotDocNotFoundDataType | CopilotFailedToMatchContextDataType | CopilotFailedToModifyContextDataType | CopilotInvalidContextDataType | CopilotMessageNotFoundDataType | CopilotPromptNotFoundDataType | CopilotProviderSideErrorDataType | DocActionDeniedDataType | DocHistoryNotFoundDataType | DocNotFoundDataType | DocUpdateBlockedDataType | ExpectToGrantDocUserRolesDataType | ExpectToRevokeDocUserRolesDataType | ExpectToUpdateDocUserRoleDataType | GraphqlBadRequestDataType | InvalidEmailDataType | InvalidHistoryTimestampDataType | InvalidLicenseUpdateParamsDataType | InvalidOauthCallbackCodeDataType | InvalidPasswordLengthDataType | InvalidRuntimeConfigTypeDataType | MemberNotFoundInSpaceDataType | MentionUserDocAccessDeniedDataType | MissingOauthQueryParameterDataType | NotInSpaceDataType | QueryTooLongDataType | RuntimeConfigNotFoundDataType | SameSubscriptionRecurringDataType | SpaceAccessDeniedDataType | SpaceNotFoundDataType | SpaceOwnerNotFoundDataType | SpaceShouldHaveOnlyOneOwnerDataType | SubscriptionAlreadyExistsDataType | SubscriptionNotExistsDataType | SubscriptionPlanNotFoundDataType | UnknownOauthProviderDataType | UnsupportedClientVersionDataType | UnsupportedSubscriptionPlanDataType | ValidationErrorDataType | VersionRejectedDataType | WorkspaceMembersExceedLimitToDowngradeDataType | WorkspacePermissionNotFoundDataType | WrongSignInCredentialsDataType
enum ErrorNames {
ACCESS_DENIED
@@ -401,8 +401,11 @@ enum ErrorNames {
MAILER_SERVICE_IS_NOT_CONFIGURED
MEMBER_NOT_FOUND_IN_SPACE
MEMBER_QUOTA_EXCEEDED
MENTION_USER_DOC_ACCESS_DENIED
MENTION_USER_ONESELF_DENIED
MISSING_OAUTH_QUERY_PARAMETER
NETWORK_ERROR
NOTIFICATION_NOT_FOUND
NOT_FOUND
NOT_IN_SPACE
NO_COPILOT_PROVIDER_AVAILABLE
@@ -531,6 +534,42 @@ type InvalidRuntimeConfigTypeDataType {
want: String!
}
type InvitationAcceptedNotificationBodyType {
"""
The user who created the notification, maybe null when user is deleted or sent by system
"""
createdByUser: PublicUserType
inviteId: String!
"""The type of the notification"""
type: NotificationType!
workspace: NotificationWorkspaceType
}
type InvitationBlockedNotificationBodyType {
"""
The user who created the notification, maybe null when user is deleted or sent by system
"""
createdByUser: PublicUserType
inviteId: String!
"""The type of the notification"""
type: NotificationType!
workspace: NotificationWorkspaceType
}
type InvitationNotificationBodyType {
"""
The user who created the notification, maybe null when user is deleted or sent by system
"""
createdByUser: PublicUserType
inviteId: ID!
"""The type of the notification"""
type: NotificationType!
workspace: NotificationWorkspaceType
}
type InvitationType {
"""Invitee information"""
invitee: UserType!
@@ -677,6 +716,45 @@ type MemberNotFoundInSpaceDataType {
spaceId: String!
}
input MentionDocInput {
"""The block id in the doc"""
blockId: String
"""The element id in the doc"""
elementId: String
id: String!
title: String!
}
type MentionDocType {
blockId: String
elementId: String
id: String!
title: String!
}
input MentionInput {
doc: MentionDocInput!
userId: String!
workspaceId: String!
}
type MentionNotificationBodyType {
"""
The user who created the notification, maybe null when user is deleted or sent by system
"""
createdByUser: PublicUserType
doc: MentionDocType!
"""The type of the notification"""
type: NotificationType!
workspace: NotificationWorkspaceType
}
type MentionUserDocAccessDeniedDataType {
docId: String!
}
type MissingOauthQueryParameterDataType {
name: String!
}
@@ -740,8 +818,14 @@ type Mutation {
invite(email: String!, permission: Permission @deprecated(reason: "never used"), sendInviteMail: Boolean, workspaceId: String!): String!
inviteBatch(emails: [String!]!, sendInviteMail: Boolean, workspaceId: String!): [InviteResult!]!
leaveWorkspace(sendLeaveMail: Boolean, workspaceId: String!, workspaceName: String @deprecated(reason: "no longer used")): Boolean!
"""mention user in a doc"""
mentionUser(input: MentionInput!): ID!
publishDoc(docId: String!, mode: PublicDocMode = Page, workspaceId: String!): DocType!
publishPage(mode: PublicDocMode = Page, pageId: String!, workspaceId: String!): DocType! @deprecated(reason: "use publishDoc instead")
"""mark notification as read"""
readNotification(id: String!): Boolean!
recoverDoc(guid: String!, timestamp: DateTime!, workspaceId: String!): DateTime!
releaseDeletedBlobs(workspaceId: String!): Boolean!
@@ -798,6 +882,64 @@ type NotInSpaceDataType {
spaceId: String!
}
"""Notification level"""
enum NotificationLevel {
Default
High
Low
Min
None
}
type NotificationObjectType {
"""Just a placeholder to export UnionNotificationBodyType, don't use it"""
_placeholderForUnionNotificationBodyType: UnionNotificationBodyType!
"""
The body of the notification, different types have different fields, see UnionNotificationBodyType
"""
body: JSONObject!
"""The created at time of the notification"""
createdAt: DateTime!
id: ID!
"""The level of the notification"""
level: NotificationLevel!
"""Whether the notification has been read"""
read: Boolean!
"""The type of the notification"""
type: NotificationType!
"""The updated at time of the notification"""
updatedAt: DateTime!
}
type NotificationObjectTypeEdge {
cursor: String!
node: NotificationObjectType!
}
"""Notification type"""
enum NotificationType {
Invitation
InvitationAccepted
InvitationBlocked
InvitationRejected
Mention
}
type NotificationWorkspaceType {
"""Workspace avatar url"""
avatarUrl: String
id: ID!
"""Workspace name"""
name: String!
}
enum OAuthProviderType {
GitHub
Google
@@ -817,6 +959,12 @@ type PaginatedGrantedDocUserType {
totalCount: Int!
}
type PaginatedNotificationObjectType {
edges: [NotificationObjectTypeEdge!]!
pageInfo: PageInfo!
totalCount: Int!
}
input PaginationInput {
"""returns the elements in the list that come after the specified cursor."""
after: String
@@ -1120,6 +1268,8 @@ enum SubscriptionVariant {
Onetime
}
union UnionNotificationBodyType = InvitationAcceptedNotificationBodyType | InvitationBlockedNotificationBodyType | InvitationNotificationBodyType | MentionNotificationBodyType
type UnknownOauthProviderDataType {
name: String!
}
@@ -1226,6 +1376,12 @@ type UserType {
"""User name"""
name: String!
"""Get user notification count"""
notificationCount: Int!
"""Get current user notifications"""
notifications(pagination: PaginationInput!): PaginatedNotificationObjectType!
quota: UserQuotaType!
quotaUsage: UserQuotaUsageType!
subscriptions: [SubscriptionType!]!