Constructors

Databases

Methods

Properties

Constructors

Databases

  • Get count of messages that have occurred since an id. (This assumes ids are generated in order). This is normally used to get an unread message count.

    Parameters

    • topicId: string

      id of topic to get message count for

    • Optional sinceMessageId: null | string

      id of message to get count since. If null, will get total message count.

    Returns Promise<number>

    number of messages that have occurred since the given id

Methods

  • Create a private chat topic and return the id

    Parameters

    • userId: string

      one of the user in the chat

    • anotherUserId: string

      one of the user in the chat

    Returns Promise<{
        id: string;
    }>

    object with id, indicate the private topic Id

  • Get message data and then normalize

    Parameters

    • messageId: string

      id of topic

    • Optional appendReadStatus: {
          organizationId?: string;
          userId?: string;
      }

      optional userId or organization used for appending read status to messages

      • Optional organizationId?: string
      • Optional userId?: string
    • Optional expand: Expand

      list of fields to expand on the message (from parsed query)

    Returns Promise<null | defaultChat.MessageResponse>

    message data

  • Get topic data and then normalize

    Parameters

    • topicId: string

      id of topic

    • Optional appendUnreadCount: {
          organizationId?: string;
          userId?: string;
      }

      optional userId or organization used for appending unread count to topics

      • Optional organizationId?: string
      • Optional userId?: string
    • Optional expand: Expand

      list of fields to expand on the topic (from parsed query)

    Returns Promise<null | defaultChat.TopicResponse>

    topic data

  • Search database if there is a private chat topic for userId, and receiptId, if yes, return directly if no, create one and return

    Parameters

    • senderId: string
    • receiptId: string

    Returns Promise<{
        id: string;
    }>

    object with id, indicate the private topic Id

  • Get topics organization is subscribed to with pagination

    Parameters

    • organizationId: string

      organizationId that want to get the topics with

    • filter: undefined | Expression
    • orderParams: OrderParam<string>[]
    • paginationOptions: PaginationOptions
    • Optional appendUnreadCount: {
          organizationId?: string;
          userId?: string;
      }

      optional userId or organization used for appending unread count to topics

      • Optional organizationId?: string
      • Optional userId?: string

    Returns Promise<PaginatedFindResult<TopicSubscriptionEntity>>

    paginated TopicModel list

  • Get topic message with pagination

    Parameters

    • topicId: string

      topicId that want to get the message with

    • filter: undefined | Expression
    • orderParams: OrderParam<string>[]
    • paginationOptions: PaginationOptions
    • Optional appendReadStatus: {
          organizationId?: string;
          userId?: string;
      }

      optional userId or organization used for appending read status to messages

      • Optional organizationId?: string
      • Optional userId?: string

    Returns Promise<PaginatedFindResult<defaultChat.MessageEntity>>

    paginated MessageModel list

  • Get topic list by filter

    Parameters

    • filter: undefined | Expression
    • orderParams: OrderParam<string>[]
    • paginationOptions: PaginationOptions
    • Optional appendUnreadCount: {
          organizationId?: string;
          userId?: string;
      }

      optional userId or organization used for appending unread count to topics

      • Optional organizationId?: string
      • Optional userId?: string

    Returns Promise<PaginatedFindResult<defaultChat.TopicEntity>>

    paginated topic list

  • Get topics user/org is one of the owner ids of with pagination

    Parameters

    • ownerId: string

      ownerId that want to get the topic with

    • ownerType: string

      user or organization

    • filter: undefined | Expression
    • orderParams: OrderParam<string>[]
    • paginationOptions: PaginationOptions
    • Optional appendUnreadCount: {
          organizationId?: string;
          userId?: string;
      }

      optional userId or organization used for appending unread count to topics

      • Optional organizationId?: string
      • Optional userId?: string

    Returns Promise<PaginatedFindResult<TopicSubscriptionEntity>>

    paginated TopicModel list

  • Get topics user is subscribed to with pagination

    Parameters

    • userId: string

      userId that want to get the topic with

    • filter: undefined | Expression
    • orderParams: OrderParam<string>[]
    • paginationOptions: PaginationOptions
    • Optional appendUnreadCount: {
          organizationId?: string;
          userId?: string;
      }

      optional userId or organization used for appending unread count to topics

      • Optional organizationId?: string
      • Optional userId?: string

    Returns Promise<PaginatedFindResult<TopicSubscriptionEntity>>

    paginated TopicModel list

  • Mark a single message as being read by a user/organization

    Parameters

    • __namedParameters: {
          messageId: string;
          organizationId?: string;
          userId?: string;
      }
      • messageId: string
      • Optional organizationId?: string
      • Optional userId?: string

    Returns Promise<void>

Properties

COLLECTION_MESSAGE: string = 'chat_messages'
COLLECTION_MESSAGE_TEMPLATE: string = 'message_templates'
COLLECTION_SUBSCRIPTION: string = 'chat_subscriptions'
COLLECTION_TOPIC: string = 'chat_topics'
COLLECTION_USER_TOPIC_CURSOR: string = 'chat_user_topic_cursors'
attachmentService: AttachmentService
db: Db
expandOrganizationAPI: Pick<OrganizationDefaultAdapterAPI, "getOrganizations">
expandUserAPI: Pick<UserDefaultAdapterAPI, "getUserById" | "getUsers">
logger?: Logger
messageRepository: MongoRepository<defaultChat.MessageEntity>
messageTemplateRepository: MongoRepository<defaultChat.MessageTemplateEntity>
subscriptionRepository: MongoRepository<defaultChat.SubscriptionEntity>
topicRepository: MongoRepository<defaultChat.TopicEntity>
userTopicCursorRepository: MongoRepository<UserTopicCursorEntity>

Generated using TypeDoc