Options
All
  • Public
  • Public/Protected
  • All
Menu

Module for managing user-related features including subscriptions, user profiles, and friend operations. Access via NCEngine.userModule.

example
// Get user profiles
const result = await NCEngine.userModule.getUserProfiles(['user-1', 'user-2']);

// Add a friend
await NCEngine.userModule.addFriend({ userId: 'user-123' });

Hierarchy

  • UserModule

Index

Methods

  • Gets the online status of subscribed users.

    example
    const result = await NCEngine.userModule.getSubscribeUsersOnlineStatus(['user-1']);
    

    Parameters

    • userIds: string[]

      The user IDs to query

    Returns Promise<NCResult<SubscribeUserOnlineStatus[]>>

    A promise resolving to the online status list

  • Subscribes to user events (e.g. online status).

    example
    const result = await NCEngine.userModule.subscribeEvent({
    subscribeType: SubscribeType.ONLINE_STATUS,
    userIds: ['user-1', 'user-2'],
    expiry: 3600,
    });

    Parameters

    Returns Promise<NCResult<string[]>>

    A promise resolving to the list of successfully subscribed user IDs

  • Unsubscribes from user events.

    example
    await NCEngine.userModule.unsubscribeEvent({
    subscribeType: SubscribeType.ONLINE_STATUS,
    userIds: ['user-1'],
    });

    Parameters

    Returns Promise<NCResult<string[]>>

    A promise resolving to the list of successfully unsubscribed user IDs

  • Gets the current subscription event status for specified users.

    example
    const r = await NCEngine.userModule.getSubscribeEvent({
    subscribeType: SubscribeType.ONLINE_STATUS,
    userIds: ['user-1'],
    });

    Parameters

    Returns Promise<NCResult<SubscriptionStatusInfo[]>>

    A promise resolving to the subscription status list

  • Creates a paginated query for listing subscribed users.

    example
    const query = NCEngine.userModule.createSubscribeQuery({
    subscribeType: SubscribeType.ONLINE_STATUS,
    });
    const result = await query.loadNextPage();

    Parameters

    Returns SubscribeQuery

    A SubscribeQuery instance

  • Updates the current user's profile.

    example
    await NCEngine.userModule.updateMyUserProfile({
    name: 'Alice',
    portraitUri: 'https://example.com/avatar.png',
    });

    Parameters

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Gets user profiles for the specified user IDs.

    example
    const result = await NCEngine.userModule.getUserProfiles(['user-1', 'user-2']);
    if (result.isOk) {
    result.data.forEach(profile => console.log(profile.name));
    }

    Parameters

    • userIds: string[]

      The user IDs to query

    Returns Promise<NCResult<UserProfile[]>>

    A promise resolving to the user profiles

  • Gets the current user's own profile.

    example
    const result = await NCEngine.userModule.getMyUserProfile();
    if (result.isOk) {
    console.log('My name:', result.data.name);
    }

    Returns Promise<NCResult<UserProfile>>

    A promise resolving to the current user's profile

  • Updates the visibility of the current user's profile.

    example
    await NCEngine.userModule.updateMyUserProfileVisibility(UserProfileVisibility.EVERYONE);
    

    Parameters

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Gets the current user's profile visibility setting.

    example
    const r = await NCEngine.userModule.getMyUserProfileVisibility();
    

    Returns Promise<NCResult<UserProfileVisibility>>

    A promise resolving to the visibility level

  • Sets the permission level for receiving friend requests.

    example
    await NCEngine.userModule.setFriendAddPermission(FriendAddPermission.NEED_VERIFY);
    

    Parameters

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Gets the current friend add permission setting.

    example
    const r = await NCEngine.userModule.getFriendAddPermission();
    

    Returns Promise<NCResult<FriendAddPermission>>

    A promise resolving to the current permission level

  • Sends a friend request to a user.

    example
    await NCEngine.userModule.addFriend({ userId: 'user-123', extra: 'Hi!' });
    

    Parameters

    Returns Promise<NCResult<ProcessCode>>

    A promise resolving to the process code

  • deleteFriends(userIds: string[]): Promise<NCResult<void>>
  • Deletes friends by user IDs.

    example
    await NCEngine.userModule.deleteFriends(['user-123', 'user-456']);
    

    Parameters

    • userIds: string[]

      The user IDs to unfriend

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • acceptFriendApplication(userId: string): Promise<NCResult<void>>
  • Accepts a friend application from a user.

    example
    await NCEngine.userModule.acceptFriendApplication('applicant-id');
    

    Parameters

    • userId: string

      The applicant's user ID

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • refuseFriendApplication(userId: string): Promise<NCResult<void>>
  • Refuses a friend application from a user.

    example
    await NCEngine.userModule.refuseFriendApplication('applicant-id');
    

    Parameters

    • userId: string

      The applicant's user ID

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Sets remark or extra profile info for a friend.

    example
    await NCEngine.userModule.setFriendInfo({
    userId: 'friend-id',
    remark: 'Work',
    });

    Parameters

    Returns Promise<NCResult<IErrorKeys>>

    A promise resolving to error keys if any fields failed

  • checkFriends(userIds: string[]): Promise<NCResult<IFriendRelationInfo[]>>
  • Checks the friendship status with the specified users.

    example
    const r = await NCEngine.userModule.checkFriends(['user-1', 'user-2']);
    

    Parameters

    • userIds: string[]

      The user IDs to check

    Returns Promise<NCResult<IFriendRelationInfo[]>>

    A promise resolving to the friend relation info

  • Creates a paginated query for listing friends.

    example
    const query = NCEngine.userModule.createFriendsQuery({ pageSize: 20 });
    const result = await query.loadNextPage();

    Parameters

    Returns FriendsQuery

    A FriendsQuery instance

  • Gets detailed friend information for the specified user IDs.

    example
    const result = await NCEngine.userModule.getFriendsInfo(['user-1', 'user-2']);
    if (result.isOk) {
    result.data.forEach(info => console.log(info.remark));
    }

    Parameters

    • userIds: string[]

      The friend user IDs to query

    Returns Promise<NCResult<FriendInfo[]>>

    A promise resolving to the friend info list