Communities
This page will guide you through the steps you need to take to integrate community chat groups into your applications for Web

Community Description

Name
Data Type
Description
Attributes
communityId
String
ID of the community
channelId
String
ID of the channel
userId
String
ID of the user who created the comment
displayName
String
Community name for displaying
avatarFileId
String
ID of the avatar file
description
String
Description of the community
isOfficial
Boolean
Is this community official?
isPublic
Boolean
Is this community public?
onlyAdminCanPost
Boolean
Can post by admin only?
tags
Array.<String>
List of tags used for searching
metadata
Object
Additional properties to support custom fields
postsCount
Integer
Number of posts in community
membersCount
Integer
Number of members in community
isJoined
Boolean
Is this community joined?
categoryIds
Array.<String>
ID of categories
isDeleted
Boolean
Is this community deleted?
Default: false
createdAt
String($date-time)
Date/time when the community was created
updatedAt
String($date-time)
Date/time when a community is updated or deleted
hasFlaggedComment
Boolean
Flag for checking internally if comment inside post is reported or not
Default: false

Create Community

When creating a new community, first, instantiate the CommunityRepository, a class that contains all community-related methods. Then, call createCommunity() to obtain the LiveObject and observe it in order to obtain the final community model.
If you want to set the community avatar, you need to upload the avatar image first. The avatarFileId is the fileId from the model you will receive from the live object used to upload file via FileRepository. To upload files and images, refer to File Handling.
Note that the event listener was registered using once(). Unlike on(), once() will automatically unregister the event listener once the first event is emitted. This is useful if you just need to use the model once but do not need to listen to further events.

Get Community

In the case where you only want to fetch communities data without joining, you can use the communityForId() method:

Join Community

Leave Community

Update Community

If you want to update a community, you can call the following:
By default, only the communities original creator or administrators can update the community.

Delete Community

You can delete a community by calling the closeCommunity method. It accepts the community ID as the parameter.
1
const success = await CommunityRepository.closeCommunity('abc');
Copied!

Community Query

There are methods to obtain communities that only match specific criteria:
  • the search parameter let you filter communities based on the community displayName
  • the isJoined parameter let you filter communities based on the logged-in user membership status
  • the tags parameters let you filter communities based on the tags set (or not set) in each community
  • the categories parameters let you filter communities based on community categories
  • the sortBy parameters let you filter communities based on the order that the communities were created or based on alphabetical order

Trending and Recommended Communities

Community Repository provides a way to fetch trending and recommended communities.
  • Trending communities
    This is a list of communities with the highest number of members. It can be a combination of communities where the user may or may not be part of.
  • Recommended communities
    This is a list of communities with the highest member count. The communities in the list are those that the user is not part of.

Community Membership

You can get a list of community members by calling the getCommunityMembers method. It accepts the following parameters:

Required parameter

  • communityId - the ID of the community to query

Optional parameters

  • memberships - filter for membership type. The possible values are: (see CommunityUserMembership)
    • 'none' - not a member of the community
    • 'member' - member of the community
    • 'banned' - member banned from the community
    • 'muted' - member muted from the community
  • roles - filter members by specific role
  • sortBy - sorting method to arrange the returned collection. The possible values are: (see CommunitySortingMethod)
    • 'firstCreated'
    • 'lastCreated'
    • 'displayName'
  • search - query string
Below is the sample code to get a list of community members.
This method will return a LiveCollection instance.

Community Moderation

CommunityRepository class provides a way to moderate the community by banning or unbanning users. banUsers and unbanUsersmethods accept an array of user ids to ban and unban respectively.

Ban users

Unban users

You can also add or remove roles using addRoles or removeRoles functions respectively. These functions accept an array of strings as an argument that contains the roles that you want to add or remove from a specific user.

Add roles

Remove roles

You can add or remove default roles as well as custom roles.

Community Categories

The CommunityRepository will also be able to manage community categories. When communities are put into categories, you will be able to sort and filter each of the community by categories.
Currently, categories can only be created and updated from the admin panel.

Get Category

You can fetch a particular category by calling the categoryForId() method:
You can also fetch a list of categories:

Category Query

This method provides the ability to obtain all the categories.

Post Review

There is a possibility to create another layer of moderation for communities to allow owners, moderators to decide whether the post should be reflected on the feed. You can turn it on by setting needApprovalOnPostCreation to true :

Feeds

The community has 3 feeds where posts are stored:
If post review is turned on, the new post will be added in Feed.Reviewing. Once approved, it will be moved to FeedType.Published. If it is declined, it will be moved toFeedType.Declined. If the post review is turned off, the new post will be added immediately in FeedType.Published.
The post review is skipped for posts which are created by community owners or moderators. They will be added in FeedType.Published, bypassing FeedType.Reviewing.
You can access each feed data using the community data:
1
const liveCommunity = CommunityRepository.communityForId('abc');
2
3
liveCommunity.once('dataUpdated', data => {
4
data.publishedFeed;
5
data.reviewingFeed;
6
data.declinedFeed;
7
});
Copied!

Feed Post Count

To get the current number of posts in the feed you need to check postCount:
Last modified 2mo ago