@amityco/ts-sdk 7.33.2-74d47a9.0 → 7.33.2-a1958171.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/domains/follow.d.ts +7 -0
- package/dist/@types/domains/follow.d.ts.map +1 -1
- package/dist/index.cjs.js +70 -6
- package/dist/index.esm.js +70 -6
- package/dist/index.umd.js +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowers/FollowerLiveCollectionController.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowers/FollowerPaginationController.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowers.d.ts +14 -1
- package/dist/userRepository/relationship/follow/observers/getFollowers.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowings/FollowingLiveCollectionController.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowings/FollowingPaginationController.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowings.d.ts +14 -1
- package/dist/userRepository/relationship/follow/observers/getFollowings.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/tests/getFollowsByUserIds.test.d.ts +2 -0
- package/dist/userRepository/relationship/follow/observers/tests/getFollowsByUserIds.test.d.ts.map +1 -0
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -38,6 +38,13 @@ declare global {
|
|
|
38
38
|
type QueryFollowers = {
|
|
39
39
|
userId: Amity.InternalUser['userId'];
|
|
40
40
|
status?: Exclude<Amity.FollowStatusType, 'none'>;
|
|
41
|
+
/**
|
|
42
|
+
* Only return the follows with these users (up to 100 ids), in one page.
|
|
43
|
+
* A user missing from the result has no relationship with the signed-in user.
|
|
44
|
+
* Only works on the signed-in user's own followers and followings lists.
|
|
45
|
+
* An empty array returns an empty list without a server call.
|
|
46
|
+
*/
|
|
47
|
+
userIds?: Amity.InternalUser['userId'][];
|
|
41
48
|
page?: Amity.PageRaw;
|
|
42
49
|
};
|
|
43
50
|
type FollowerLiveCollection = Amity.LiveCollectionParams<Omit<QueryFollowers, 'page'>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"follow.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/follow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,WAAW,oBAAoB;YAC7B,WAAW,gBAAgB;YAC3B,UAAU,eAAe;YACzB,UAAU,eAAe;YACzB,UAAU,eAAe;YACzB,UAAU,eAAe;YACzB,YAAY,iBAAiB;YAC7B,SAAS,cAAc;SACxB;QAED,KAAK,gBAAgB,GAAG,GAAG,oBAAoB,EAAE,CAAC;QAElD,WAAW,oBAAoB;YAC7B,GAAG,QAAQ;YACX,OAAO,YAAY;YACnB,QAAQ,aAAa;YACrB,OAAO,YAAY;YACnB,IAAI,SAAS;SACd;QAED,KAAK,gBAAgB,GAAG,GAAG,oBAAoB,EAAE,CAAC;QAElD,KAAK,eAAe,GAAG;YACrB,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;YACnC,EAAE,EAAE,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;YACjC,MAAM,EAAE,OAAO,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;SAC1C,GAAG,KAAK,CAAC,SAAS,GACjB,KAAK,CAAC,SAAS,CAAC;QAElB,KAAK,oBAAoB,GAAG,KAAK,CAAC,eAAe,CAAC;QAClD,KAAK,YAAY,GAAG,oBAAoB,CAAC;QAEzC,KAAK,WAAW,GAAG;YACjB,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;YACrC,aAAa,EAAE,MAAM,CAAC;YACtB,cAAc,EAAE,MAAM,CAAC;YACvB,YAAY,EAAE,MAAM,CAAC;SACtB,CAAC;QAEF,KAAK,UAA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F,KAAK,eAAe,GAAG,cAAc,CAAC;QAEtC,KAAK,uBAAuB,GAAG,sBAAsB,CAAC;QAEtD,KAAK,4BAA4B,GAAG,2BAA2B,CAAC;KACjE;CACF"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -395,6 +395,8 @@ const API_ENDPOINTS = {
|
|
|
395
395
|
// The review-queue route defaults to 10, not the SDK-wide page size, and caps at 100
|
|
396
396
|
const COMMENT_REVIEW_QUEUE_DEFAULT_PAGINATION_SIZE = 10;
|
|
397
397
|
const COMMENT_REVIEW_QUEUE_MAX_PAGINATION_SIZE = 100;
|
|
398
|
+
// The me/followers and me/following `userIds` filter takes up to 100 ids, answered in one page
|
|
399
|
+
const FOLLOW_USER_IDS_PAGINATION_LIMIT = 100;
|
|
398
400
|
|
|
399
401
|
// cache constants
|
|
400
402
|
const CACHE_KEY_GET = 'get';
|
|
@@ -11736,9 +11738,22 @@ class PaginationController {
|
|
|
11736
11738
|
|
|
11737
11739
|
class FollowerPaginationController extends PaginationController {
|
|
11738
11740
|
async getRequest(queryParams, token) {
|
|
11739
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, userId } = queryParams, params = __rest(queryParams, ["limit", "userId"]);
|
|
11740
|
-
const options = token ? { token } : { limit };
|
|
11741
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, userId, userIds } = queryParams, params = __rest(queryParams, ["limit", "userId", "userIds"]);
|
|
11741
11742
|
const client = getActiveClient();
|
|
11743
|
+
if (userIds) {
|
|
11744
|
+
// An empty filter matches nobody; sending no ids would return the whole list instead
|
|
11745
|
+
if (userIds.length === 0)
|
|
11746
|
+
return { follows: [], users: [], files: [], paging: {} };
|
|
11747
|
+
if (client.userId !== userId) {
|
|
11748
|
+
throw new ASCInvalidParameterError("userIds can only be used on the signed-in user's own followers list");
|
|
11749
|
+
}
|
|
11750
|
+
// core reads `limit` and `token` only as top-level params, never inside `options`
|
|
11751
|
+
const { data: queryResponse } = await this.http.get(`/api/v4/me/followers`, {
|
|
11752
|
+
params: Object.assign(Object.assign(Object.assign(Object.assign({}, params), { userIds, limit: FOLLOW_USER_IDS_PAGINATION_LIMIT }), (token && { token })), { isDeleted: false }),
|
|
11753
|
+
});
|
|
11754
|
+
return queryResponse;
|
|
11755
|
+
}
|
|
11756
|
+
const options = token ? { token } : { limit };
|
|
11742
11757
|
const path = client.userId === userId ? `/api/v4/me/followers` : `/api/v4/users/${userId}/followers`;
|
|
11743
11758
|
const { data: queryResponse } = await this.http.get(path, {
|
|
11744
11759
|
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
@@ -12022,6 +12037,11 @@ class FollowerLiveCollectionController extends LiveCollectionController {
|
|
|
12022
12037
|
const fromUser = (_a = pullFromCache(['user', 'get', follower.from])) === null || _a === void 0 ? void 0 : _a.data;
|
|
12023
12038
|
return (fromUser === null || fromUser === void 0 ? void 0 : fromUser.isDeleted) == null || (fromUser === null || fromUser === void 0 ? void 0 : fromUser.isDeleted) === false;
|
|
12024
12039
|
});
|
|
12040
|
+
// With a userIds filter, keep realtime follows with other users out of the list
|
|
12041
|
+
if (this.query.userIds) {
|
|
12042
|
+
const userIds = new Set(this.query.userIds);
|
|
12043
|
+
followers = followers.filter(follower => userIds.has(follower.from));
|
|
12044
|
+
}
|
|
12025
12045
|
return followers;
|
|
12026
12046
|
}
|
|
12027
12047
|
}
|
|
@@ -12041,7 +12061,20 @@ class FollowerLiveCollectionController extends LiveCollectionController {
|
|
|
12041
12061
|
*
|
|
12042
12062
|
* Observe all mutations on a list of {@link Amity.FollowStatus} followers for a given userId
|
|
12043
12063
|
*
|
|
12044
|
-
*
|
|
12064
|
+
* To check the relationship with specific users (e.g. the users on screen), pass the signed-in
|
|
12065
|
+
* user's `userId` and up to 100 `userIds`. The result only holds those users, in one page:
|
|
12066
|
+
*
|
|
12067
|
+
* ```js
|
|
12068
|
+
* getFollowers({ userId: client.userId, userIds: ['a', 'b', 'c'] }, ({ data }) => {
|
|
12069
|
+
* // users missing from `data` have no relationship
|
|
12070
|
+
* })
|
|
12071
|
+
* ```
|
|
12072
|
+
*
|
|
12073
|
+
* @param params.userId the user
|
|
12074
|
+
* @param params.status filter by follow status, defaults to all
|
|
12075
|
+
* @param params.userIds only return the followers with these users (up to 100 ids, in one page).
|
|
12076
|
+
* A user missing from the result has no relationship. Only allowed when `userId` is the
|
|
12077
|
+
* signed-in user, otherwise the callback gets an {@link ASCInvalidParameterError}.
|
|
12045
12078
|
* @param callback the function to call when new data are available
|
|
12046
12079
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
12047
12080
|
*
|
|
@@ -12067,9 +12100,22 @@ const getFollowers = (params, callback, config) => {
|
|
|
12067
12100
|
|
|
12068
12101
|
class FollowingPaginationController extends PaginationController {
|
|
12069
12102
|
async getRequest(queryParams, token) {
|
|
12070
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, userId } = queryParams, params = __rest(queryParams, ["limit", "userId"]);
|
|
12071
|
-
const options = token ? { token } : { limit };
|
|
12103
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, userId, userIds } = queryParams, params = __rest(queryParams, ["limit", "userId", "userIds"]);
|
|
12072
12104
|
const client = getActiveClient();
|
|
12105
|
+
if (userIds) {
|
|
12106
|
+
// An empty filter matches nobody; sending no ids would return the whole list instead
|
|
12107
|
+
if (userIds.length === 0)
|
|
12108
|
+
return { follows: [], users: [], files: [], paging: {} };
|
|
12109
|
+
if (client.userId !== userId) {
|
|
12110
|
+
throw new ASCInvalidParameterError("userIds can only be used on the signed-in user's own following list");
|
|
12111
|
+
}
|
|
12112
|
+
// core reads `limit` and `token` only as top-level params, never inside `options`
|
|
12113
|
+
const { data: queryResponse } = await this.http.get(`/api/v4/me/following`, {
|
|
12114
|
+
params: Object.assign(Object.assign(Object.assign(Object.assign({}, params), { userIds, limit: FOLLOW_USER_IDS_PAGINATION_LIMIT }), (token && { token })), { isDeleted: false }),
|
|
12115
|
+
});
|
|
12116
|
+
return queryResponse;
|
|
12117
|
+
}
|
|
12118
|
+
const options = token ? { token } : { limit };
|
|
12073
12119
|
const path = client.userId === userId ? `/api/v4/me/following` : `/api/v4/users/${userId}/following`;
|
|
12074
12120
|
const { data: queryResponse } = await this.http.get(path, {
|
|
12075
12121
|
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
@@ -12229,6 +12275,11 @@ class FollowingLiveCollectionController extends LiveCollectionController {
|
|
|
12229
12275
|
const toUser = (_a = pullFromCache(['user', 'get', following.to])) === null || _a === void 0 ? void 0 : _a.data;
|
|
12230
12276
|
return (toUser === null || toUser === void 0 ? void 0 : toUser.isDeleted) == null || (toUser === null || toUser === void 0 ? void 0 : toUser.isDeleted) === false;
|
|
12231
12277
|
});
|
|
12278
|
+
// With a userIds filter, keep realtime follows with other users out of the list
|
|
12279
|
+
if (this.query.userIds) {
|
|
12280
|
+
const userIds = new Set(this.query.userIds);
|
|
12281
|
+
followings = followings.filter(following => userIds.has(following.to));
|
|
12282
|
+
}
|
|
12232
12283
|
return followings;
|
|
12233
12284
|
}
|
|
12234
12285
|
}
|
|
@@ -12248,7 +12299,20 @@ class FollowingLiveCollectionController extends LiveCollectionController {
|
|
|
12248
12299
|
*
|
|
12249
12300
|
* Observe all mutations on a list of {@link Amity.FollowStatus} followings for a given userId
|
|
12250
12301
|
*
|
|
12251
|
-
*
|
|
12302
|
+
* To check the relationship with specific users (e.g. the users on screen), pass the signed-in
|
|
12303
|
+
* user's `userId` and up to 100 `userIds`. The result only holds those users, in one page:
|
|
12304
|
+
*
|
|
12305
|
+
* ```js
|
|
12306
|
+
* getFollowings({ userId: client.userId, userIds: ['a', 'b', 'c'] }, ({ data }) => {
|
|
12307
|
+
* // users missing from `data` have no relationship
|
|
12308
|
+
* })
|
|
12309
|
+
* ```
|
|
12310
|
+
*
|
|
12311
|
+
* @param params.userId the user
|
|
12312
|
+
* @param params.status filter by follow status, defaults to all
|
|
12313
|
+
* @param params.userIds only return the followings with these users (up to 100 ids, in one page).
|
|
12314
|
+
* A user missing from the result has no relationship. Only allowed when `userId` is the
|
|
12315
|
+
* signed-in user, otherwise the callback gets an {@link ASCInvalidParameterError}.
|
|
12252
12316
|
* @param callback the function to call when new data are available
|
|
12253
12317
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
12254
12318
|
*
|
package/dist/index.esm.js
CHANGED
|
@@ -379,6 +379,8 @@ const API_ENDPOINTS = {
|
|
|
379
379
|
// The review-queue route defaults to 10, not the SDK-wide page size, and caps at 100
|
|
380
380
|
const COMMENT_REVIEW_QUEUE_DEFAULT_PAGINATION_SIZE = 10;
|
|
381
381
|
const COMMENT_REVIEW_QUEUE_MAX_PAGINATION_SIZE = 100;
|
|
382
|
+
// The me/followers and me/following `userIds` filter takes up to 100 ids, answered in one page
|
|
383
|
+
const FOLLOW_USER_IDS_PAGINATION_LIMIT = 100;
|
|
382
384
|
|
|
383
385
|
// cache constants
|
|
384
386
|
const CACHE_KEY_GET = 'get';
|
|
@@ -11736,9 +11738,22 @@ class PaginationController {
|
|
|
11736
11738
|
|
|
11737
11739
|
class FollowerPaginationController extends PaginationController {
|
|
11738
11740
|
async getRequest(queryParams, token) {
|
|
11739
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, userId } = queryParams, params = __rest(queryParams, ["limit", "userId"]);
|
|
11740
|
-
const options = token ? { token } : { limit };
|
|
11741
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, userId, userIds } = queryParams, params = __rest(queryParams, ["limit", "userId", "userIds"]);
|
|
11741
11742
|
const client = getActiveClient();
|
|
11743
|
+
if (userIds) {
|
|
11744
|
+
// An empty filter matches nobody; sending no ids would return the whole list instead
|
|
11745
|
+
if (userIds.length === 0)
|
|
11746
|
+
return { follows: [], users: [], files: [], paging: {} };
|
|
11747
|
+
if (client.userId !== userId) {
|
|
11748
|
+
throw new ASCInvalidParameterError("userIds can only be used on the signed-in user's own followers list");
|
|
11749
|
+
}
|
|
11750
|
+
// core reads `limit` and `token` only as top-level params, never inside `options`
|
|
11751
|
+
const { data: queryResponse } = await this.http.get(`/api/v4/me/followers`, {
|
|
11752
|
+
params: Object.assign(Object.assign(Object.assign(Object.assign({}, params), { userIds, limit: FOLLOW_USER_IDS_PAGINATION_LIMIT }), (token && { token })), { isDeleted: false }),
|
|
11753
|
+
});
|
|
11754
|
+
return queryResponse;
|
|
11755
|
+
}
|
|
11756
|
+
const options = token ? { token } : { limit };
|
|
11742
11757
|
const path = client.userId === userId ? `/api/v4/me/followers` : `/api/v4/users/${userId}/followers`;
|
|
11743
11758
|
const { data: queryResponse } = await this.http.get(path, {
|
|
11744
11759
|
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
@@ -12022,6 +12037,11 @@ class FollowerLiveCollectionController extends LiveCollectionController {
|
|
|
12022
12037
|
const fromUser = (_a = pullFromCache(['user', 'get', follower.from])) === null || _a === void 0 ? void 0 : _a.data;
|
|
12023
12038
|
return (fromUser === null || fromUser === void 0 ? void 0 : fromUser.isDeleted) == null || (fromUser === null || fromUser === void 0 ? void 0 : fromUser.isDeleted) === false;
|
|
12024
12039
|
});
|
|
12040
|
+
// With a userIds filter, keep realtime follows with other users out of the list
|
|
12041
|
+
if (this.query.userIds) {
|
|
12042
|
+
const userIds = new Set(this.query.userIds);
|
|
12043
|
+
followers = followers.filter(follower => userIds.has(follower.from));
|
|
12044
|
+
}
|
|
12025
12045
|
return followers;
|
|
12026
12046
|
}
|
|
12027
12047
|
}
|
|
@@ -12041,7 +12061,20 @@ class FollowerLiveCollectionController extends LiveCollectionController {
|
|
|
12041
12061
|
*
|
|
12042
12062
|
* Observe all mutations on a list of {@link Amity.FollowStatus} followers for a given userId
|
|
12043
12063
|
*
|
|
12044
|
-
*
|
|
12064
|
+
* To check the relationship with specific users (e.g. the users on screen), pass the signed-in
|
|
12065
|
+
* user's `userId` and up to 100 `userIds`. The result only holds those users, in one page:
|
|
12066
|
+
*
|
|
12067
|
+
* ```js
|
|
12068
|
+
* getFollowers({ userId: client.userId, userIds: ['a', 'b', 'c'] }, ({ data }) => {
|
|
12069
|
+
* // users missing from `data` have no relationship
|
|
12070
|
+
* })
|
|
12071
|
+
* ```
|
|
12072
|
+
*
|
|
12073
|
+
* @param params.userId the user
|
|
12074
|
+
* @param params.status filter by follow status, defaults to all
|
|
12075
|
+
* @param params.userIds only return the followers with these users (up to 100 ids, in one page).
|
|
12076
|
+
* A user missing from the result has no relationship. Only allowed when `userId` is the
|
|
12077
|
+
* signed-in user, otherwise the callback gets an {@link ASCInvalidParameterError}.
|
|
12045
12078
|
* @param callback the function to call when new data are available
|
|
12046
12079
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
12047
12080
|
*
|
|
@@ -12067,9 +12100,22 @@ const getFollowers = (params, callback, config) => {
|
|
|
12067
12100
|
|
|
12068
12101
|
class FollowingPaginationController extends PaginationController {
|
|
12069
12102
|
async getRequest(queryParams, token) {
|
|
12070
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, userId } = queryParams, params = __rest(queryParams, ["limit", "userId"]);
|
|
12071
|
-
const options = token ? { token } : { limit };
|
|
12103
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, userId, userIds } = queryParams, params = __rest(queryParams, ["limit", "userId", "userIds"]);
|
|
12072
12104
|
const client = getActiveClient();
|
|
12105
|
+
if (userIds) {
|
|
12106
|
+
// An empty filter matches nobody; sending no ids would return the whole list instead
|
|
12107
|
+
if (userIds.length === 0)
|
|
12108
|
+
return { follows: [], users: [], files: [], paging: {} };
|
|
12109
|
+
if (client.userId !== userId) {
|
|
12110
|
+
throw new ASCInvalidParameterError("userIds can only be used on the signed-in user's own following list");
|
|
12111
|
+
}
|
|
12112
|
+
// core reads `limit` and `token` only as top-level params, never inside `options`
|
|
12113
|
+
const { data: queryResponse } = await this.http.get(`/api/v4/me/following`, {
|
|
12114
|
+
params: Object.assign(Object.assign(Object.assign(Object.assign({}, params), { userIds, limit: FOLLOW_USER_IDS_PAGINATION_LIMIT }), (token && { token })), { isDeleted: false }),
|
|
12115
|
+
});
|
|
12116
|
+
return queryResponse;
|
|
12117
|
+
}
|
|
12118
|
+
const options = token ? { token } : { limit };
|
|
12073
12119
|
const path = client.userId === userId ? `/api/v4/me/following` : `/api/v4/users/${userId}/following`;
|
|
12074
12120
|
const { data: queryResponse } = await this.http.get(path, {
|
|
12075
12121
|
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
@@ -12229,6 +12275,11 @@ class FollowingLiveCollectionController extends LiveCollectionController {
|
|
|
12229
12275
|
const toUser = (_a = pullFromCache(['user', 'get', following.to])) === null || _a === void 0 ? void 0 : _a.data;
|
|
12230
12276
|
return (toUser === null || toUser === void 0 ? void 0 : toUser.isDeleted) == null || (toUser === null || toUser === void 0 ? void 0 : toUser.isDeleted) === false;
|
|
12231
12277
|
});
|
|
12278
|
+
// With a userIds filter, keep realtime follows with other users out of the list
|
|
12279
|
+
if (this.query.userIds) {
|
|
12280
|
+
const userIds = new Set(this.query.userIds);
|
|
12281
|
+
followings = followings.filter(following => userIds.has(following.to));
|
|
12282
|
+
}
|
|
12232
12283
|
return followings;
|
|
12233
12284
|
}
|
|
12234
12285
|
}
|
|
@@ -12248,7 +12299,20 @@ class FollowingLiveCollectionController extends LiveCollectionController {
|
|
|
12248
12299
|
*
|
|
12249
12300
|
* Observe all mutations on a list of {@link Amity.FollowStatus} followings for a given userId
|
|
12250
12301
|
*
|
|
12251
|
-
*
|
|
12302
|
+
* To check the relationship with specific users (e.g. the users on screen), pass the signed-in
|
|
12303
|
+
* user's `userId` and up to 100 `userIds`. The result only holds those users, in one page:
|
|
12304
|
+
*
|
|
12305
|
+
* ```js
|
|
12306
|
+
* getFollowings({ userId: client.userId, userIds: ['a', 'b', 'c'] }, ({ data }) => {
|
|
12307
|
+
* // users missing from `data` have no relationship
|
|
12308
|
+
* })
|
|
12309
|
+
* ```
|
|
12310
|
+
*
|
|
12311
|
+
* @param params.userId the user
|
|
12312
|
+
* @param params.status filter by follow status, defaults to all
|
|
12313
|
+
* @param params.userIds only return the followings with these users (up to 100 ids, in one page).
|
|
12314
|
+
* A user missing from the result has no relationship. Only allowed when `userId` is the
|
|
12315
|
+
* signed-in user, otherwise the callback gets an {@link ASCInvalidParameterError}.
|
|
12252
12316
|
* @param callback the function to call when new data are available
|
|
12253
12317
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
12254
12318
|
*
|