@amityco/ts-sdk 7.8.0 → 7.8.1-1d9a9fe7.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/.env +26 -26
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/feed.d.ts +32 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/feed.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/feed.js +22 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/feed.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.d.ts +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.js +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.d.ts +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.js +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts +14 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.js +129 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts +5 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.js +15 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts +15 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.js +78 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.d.ts +23 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.js +46 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.d.ts +2 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.js +2 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/tsconfig.tsbuildinfo +1 -1
- package/dist/@types/domains/feed.d.ts +32 -0
- package/dist/@types/domains/feed.d.ts.map +1 -1
- package/dist/@types/index.d.ts +1 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/feedRepository/index.d.ts +1 -0
- package/dist/feedRepository/index.d.ts.map +1 -1
- package/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts +14 -0
- package/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts +5 -0
- package/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts +15 -0
- package/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getUserFeed.d.ts +23 -0
- package/dist/feedRepository/observers/getUserFeed.d.ts.map +1 -0
- package/dist/feedRepository/observers/index.d.ts +2 -0
- package/dist/feedRepository/observers/index.d.ts.map +1 -0
- package/dist/index.cjs.js +1217 -957
- package/dist/index.esm.js +1359 -1099
- package/dist/index.umd.js +4 -4
- package/package.json +1 -1
- package/src/@types/domains/feed.ts +44 -0
- package/src/@types/index.ts +1 -0
- package/src/feedRepository/index.ts +1 -0
- package/src/feedRepository/observers/getUserFeed/LiveCollectionController.ts +192 -0
- package/src/feedRepository/observers/getUserFeed/PaginationController.ts +37 -0
- package/src/feedRepository/observers/getUserFeed/QueryStreamController.ts +119 -0
- package/src/feedRepository/observers/getUserFeed.ts +56 -0
- package/src/feedRepository/observers/index.ts +1 -0
- package/tsconfig.tsbuildinfo +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -137,6 +137,29 @@ var JoinResultStatusEnum;
|
|
|
137
137
|
JoinResultStatusEnum["Pending"] = "pending";
|
|
138
138
|
})(JoinResultStatusEnum || (JoinResultStatusEnum = {}));
|
|
139
139
|
|
|
140
|
+
var FeedDataTypeEnum;
|
|
141
|
+
(function (FeedDataTypeEnum) {
|
|
142
|
+
FeedDataTypeEnum["Text"] = "text";
|
|
143
|
+
FeedDataTypeEnum["Video"] = "video";
|
|
144
|
+
FeedDataTypeEnum["Image"] = "image";
|
|
145
|
+
FeedDataTypeEnum["File"] = "file";
|
|
146
|
+
FeedDataTypeEnum["LiveStream"] = "liveStream";
|
|
147
|
+
FeedDataTypeEnum["Clip"] = "clip";
|
|
148
|
+
FeedDataTypeEnum["Poll"] = "poll";
|
|
149
|
+
})(FeedDataTypeEnum || (FeedDataTypeEnum = {}));
|
|
150
|
+
var FeedSortByEnum;
|
|
151
|
+
(function (FeedSortByEnum) {
|
|
152
|
+
FeedSortByEnum["LastCreated"] = "lastCreated";
|
|
153
|
+
FeedSortByEnum["FirstCreated"] = "firstCreated";
|
|
154
|
+
FeedSortByEnum["LastUpdated"] = "lastUpdated";
|
|
155
|
+
FeedSortByEnum["FirstUpdated"] = "firstUpdated";
|
|
156
|
+
})(FeedSortByEnum || (FeedSortByEnum = {}));
|
|
157
|
+
var FeedSourceEnum;
|
|
158
|
+
(function (FeedSourceEnum) {
|
|
159
|
+
FeedSourceEnum["Community"] = "community";
|
|
160
|
+
FeedSourceEnum["User"] = "user";
|
|
161
|
+
})(FeedSourceEnum || (FeedSourceEnum = {}));
|
|
162
|
+
|
|
140
163
|
function getVersion() {
|
|
141
164
|
try {
|
|
142
165
|
// the string ''v7.8.0-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
@@ -39267,1010 +39290,1035 @@ getCustomRankingGlobalFeed.locally = (query) => {
|
|
|
39267
39290
|
: undefined;
|
|
39268
39291
|
};
|
|
39269
39292
|
|
|
39270
|
-
|
|
39271
|
-
|
|
39272
|
-
|
|
39273
|
-
|
|
39274
|
-
}
|
|
39293
|
+
class UserFeedPaginationController extends PaginationController {
|
|
39294
|
+
async getRequest(queryParams, token) {
|
|
39295
|
+
const { userId, feedSources, dataTypes, includeDeleted, matchingOnlyParentPost, limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["userId", "feedSources", "dataTypes", "includeDeleted", "matchingOnlyParentPost", "limit"]);
|
|
39296
|
+
const options = token ? { token } : { limit };
|
|
39297
|
+
const { data: queryResponse } = await this.http.get(`/api/v4/user-feeds/${userId}`, {
|
|
39298
|
+
params: Object.assign(Object.assign({}, params), { options, dataTypes: (dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.length) ? dataTypes : undefined, includePostedFeed: feedSources, isDeleted: inferIsDeleted(includeDeleted), matchingOnlyParentPost: matchingOnlyParentPost !== null && matchingOnlyParentPost !== void 0 ? matchingOnlyParentPost : !(dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.length) }),
|
|
39299
|
+
});
|
|
39300
|
+
return queryResponse;
|
|
39301
|
+
}
|
|
39302
|
+
}
|
|
39303
|
+
|
|
39304
|
+
var EnumPostActions;
|
|
39305
|
+
(function (EnumPostActions) {
|
|
39306
|
+
EnumPostActions["OnPostCreated"] = "onPostCreated";
|
|
39307
|
+
EnumPostActions["OnPostUpdated"] = "onPostUpdated";
|
|
39308
|
+
EnumPostActions["OnPostDeleted"] = "onPostDeleted";
|
|
39309
|
+
EnumPostActions["OnPostFlagged"] = "onPostFlagged";
|
|
39310
|
+
EnumPostActions["OnPostUnflagged"] = "onPostUnflagged";
|
|
39311
|
+
EnumPostActions["OnPostReactionAdded"] = "onPostReactionAdded";
|
|
39312
|
+
EnumPostActions["OnPostReactionRemoved"] = "onPostReactionRemoved";
|
|
39313
|
+
EnumPostActions["OnPostApproved"] = "onPostApproved";
|
|
39314
|
+
EnumPostActions["OnPostDeclined"] = "onPostDeclined";
|
|
39315
|
+
})(EnumPostActions || (EnumPostActions = {}));
|
|
39316
|
+
|
|
39317
|
+
class UserFeedQueryStreamController extends QueryStreamController {
|
|
39318
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
39319
|
+
super(query, cacheKey);
|
|
39320
|
+
this.notifyChange = notifyChange;
|
|
39321
|
+
this.preparePayload = preparePayload;
|
|
39322
|
+
}
|
|
39323
|
+
async saveToMainDB(response) {
|
|
39324
|
+
const processedPayload = await this.preparePayload(response);
|
|
39325
|
+
const client = getActiveClient();
|
|
39326
|
+
const cachedAt = client.cache && Date.now();
|
|
39327
|
+
if (client.cache) {
|
|
39328
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
39329
|
+
}
|
|
39330
|
+
}
|
|
39331
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
39332
|
+
var _a, _b;
|
|
39333
|
+
if (refresh) {
|
|
39334
|
+
pushToCache(this.cacheKey, {
|
|
39335
|
+
data: response.posts.map(getResolver('post')),
|
|
39336
|
+
});
|
|
39337
|
+
}
|
|
39338
|
+
else {
|
|
39339
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
39340
|
+
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
39341
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
|
|
39342
|
+
}
|
|
39343
|
+
}
|
|
39344
|
+
reactor(action) {
|
|
39345
|
+
return (post) => {
|
|
39346
|
+
var _a, _b;
|
|
39347
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
39348
|
+
if (!collection)
|
|
39349
|
+
return;
|
|
39350
|
+
// if the collection is parent post collection and
|
|
39351
|
+
// post is not included in the collection or post is child post
|
|
39352
|
+
if ((!this.query.dataTypes || this.query.dataTypes.length === 0) &&
|
|
39353
|
+
!collection.data.includes(post.parentPostId ? post.parentPostId : post.postId))
|
|
39354
|
+
return;
|
|
39355
|
+
if (action === EnumPostActions.OnPostDeleted) {
|
|
39356
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
39357
|
+
}
|
|
39358
|
+
if (post.parentPostId && post.isDeleted) {
|
|
39359
|
+
const parentPost = (_b = pullFromCache([
|
|
39360
|
+
'post',
|
|
39361
|
+
'get',
|
|
39362
|
+
post.parentPostId,
|
|
39363
|
+
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
39364
|
+
if (!parentPost)
|
|
39365
|
+
return;
|
|
39366
|
+
parentPost.children = parentPost.children.filter(childId => childId !== post.postId);
|
|
39367
|
+
pushToCache(['post', 'get', parentPost.postId], parentPost);
|
|
39368
|
+
}
|
|
39369
|
+
if (action === EnumPostActions.OnPostDeclined) {
|
|
39370
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
39371
|
+
}
|
|
39372
|
+
if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
|
|
39373
|
+
if (this.query.dataTypes &&
|
|
39374
|
+
this.query.dataTypes.length > 0 &&
|
|
39375
|
+
!this.query.dataTypes.includes(post.dataType)) {
|
|
39376
|
+
return;
|
|
39377
|
+
}
|
|
39378
|
+
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
39379
|
+
}
|
|
39380
|
+
pushToCache(this.cacheKey, collection);
|
|
39381
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
39382
|
+
};
|
|
39383
|
+
}
|
|
39384
|
+
subscribeRTE(createSubscriber) {
|
|
39385
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
39386
|
+
}
|
|
39387
|
+
}
|
|
39275
39388
|
|
|
39276
39389
|
/* begin_public_function
|
|
39277
|
-
id:
|
|
39390
|
+
id: comment.get_by_ids
|
|
39278
39391
|
*/
|
|
39279
39392
|
/**
|
|
39280
39393
|
* ```js
|
|
39281
|
-
* import {
|
|
39282
|
-
* const
|
|
39394
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
39395
|
+
* const comments = await CommentRepository.getCommentByIds(['foo', 'bar'])
|
|
39283
39396
|
* ```
|
|
39284
39397
|
*
|
|
39285
|
-
* Fetches a collection of {@link Amity.
|
|
39398
|
+
* Fetches a collection of {@link Amity.Comment} objects
|
|
39286
39399
|
*
|
|
39287
|
-
* @param
|
|
39288
|
-
* @returns the associated collection of {@link Amity.
|
|
39400
|
+
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
39401
|
+
* @returns the associated collection of {@link Amity.Comment} objects
|
|
39289
39402
|
*
|
|
39290
|
-
* @category
|
|
39403
|
+
* @category Comment API
|
|
39291
39404
|
* @async
|
|
39292
39405
|
*/
|
|
39293
|
-
const
|
|
39406
|
+
const getCommentByIds = async (commentIds) => {
|
|
39294
39407
|
const client = getActiveClient();
|
|
39295
|
-
client.log('
|
|
39296
|
-
const
|
|
39297
|
-
let
|
|
39408
|
+
client.log('comment/getCommentByIds', commentIds);
|
|
39409
|
+
const encodedCommentIds = commentIds.map(commentId => encodeURIComponent(commentId));
|
|
39410
|
+
let data;
|
|
39298
39411
|
try {
|
|
39299
39412
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
39300
|
-
const response = await client.http.get(`/api/v3/
|
|
39301
|
-
params: {
|
|
39413
|
+
const response = await client.http.get(`/api/v3/comments/list`, {
|
|
39414
|
+
params: { commentIds: encodedCommentIds },
|
|
39302
39415
|
});
|
|
39303
|
-
|
|
39416
|
+
data = response.data;
|
|
39304
39417
|
}
|
|
39305
39418
|
catch (error) {
|
|
39306
|
-
|
|
39419
|
+
commentIds.forEach(commentId => {
|
|
39307
39420
|
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
39308
|
-
pushToTombstone('
|
|
39421
|
+
pushToTombstone('comment', commentId);
|
|
39309
39422
|
}
|
|
39310
39423
|
});
|
|
39311
39424
|
throw error;
|
|
39312
39425
|
}
|
|
39313
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
39314
39426
|
const cachedAt = client.cache && Date.now();
|
|
39315
39427
|
if (client.cache)
|
|
39316
39428
|
ingestInCache(data, { cachedAt });
|
|
39317
39429
|
return {
|
|
39318
|
-
data: data.
|
|
39430
|
+
data: data.comments.map(comment => LinkedObject.comment(comment)),
|
|
39319
39431
|
cachedAt,
|
|
39320
39432
|
};
|
|
39321
39433
|
};
|
|
39322
39434
|
/* end_public_function */
|
|
39323
39435
|
/**
|
|
39324
39436
|
* ```js
|
|
39325
|
-
* import {
|
|
39326
|
-
* const
|
|
39437
|
+
* import { getCommentByIds } from '@amityco/ts-sdk'
|
|
39438
|
+
* const comments = getCommentByIds.locally(['foo', 'bar'])
|
|
39327
39439
|
* ```
|
|
39328
39440
|
*
|
|
39329
|
-
* Fetches a collection of {@link Amity.
|
|
39441
|
+
* Fetches a collection of {@link Amity.Comment} objects from cache
|
|
39330
39442
|
*
|
|
39331
|
-
* @param
|
|
39332
|
-
* @returns the associated collection of {@link Amity.
|
|
39443
|
+
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
39444
|
+
* @returns the associated collection of {@link Amity.Comment} objects
|
|
39333
39445
|
*
|
|
39334
|
-
* @category
|
|
39446
|
+
* @category Comment API
|
|
39335
39447
|
*/
|
|
39336
|
-
|
|
39448
|
+
getCommentByIds.locally = (commentIds) => {
|
|
39337
39449
|
var _a;
|
|
39338
39450
|
const client = getActiveClient();
|
|
39339
|
-
client.log('
|
|
39451
|
+
client.log('comment/getCommentByIds.locally', commentIds);
|
|
39340
39452
|
if (!client.cache)
|
|
39341
39453
|
return;
|
|
39342
|
-
const cached =
|
|
39343
|
-
.map(
|
|
39454
|
+
const cached = commentIds
|
|
39455
|
+
.map(commentId => pullFromCache(['comment', 'get', commentId]))
|
|
39344
39456
|
.filter(Boolean);
|
|
39345
|
-
const
|
|
39457
|
+
const comments = cached.map(({ data }) => data);
|
|
39346
39458
|
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
39347
|
-
if ((cached === null || cached === void 0 ? void 0 : cached.length) <
|
|
39459
|
+
if ((cached === null || cached === void 0 ? void 0 : cached.length) < commentIds.length)
|
|
39348
39460
|
return;
|
|
39349
39461
|
return {
|
|
39350
|
-
data:
|
|
39462
|
+
data: comments.map(comment => LinkedObject.comment(comment)),
|
|
39351
39463
|
cachedAt: oldest.cachedAt,
|
|
39352
39464
|
};
|
|
39353
39465
|
};
|
|
39354
39466
|
|
|
39355
39467
|
/* begin_public_function
|
|
39356
|
-
id:
|
|
39468
|
+
id: comment.create
|
|
39357
39469
|
*/
|
|
39358
39470
|
/**
|
|
39359
39471
|
* ```js
|
|
39360
|
-
* import {
|
|
39361
|
-
* const
|
|
39362
|
-
* targetType: 'user',
|
|
39363
|
-
* targetId: 'foobar',
|
|
39364
|
-
* data: { text: 'hello world' }
|
|
39365
|
-
* }))
|
|
39472
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
39473
|
+
* const newComment = await CommentRepository.createComment(bundle)
|
|
39366
39474
|
* ```
|
|
39367
39475
|
*
|
|
39368
|
-
* Creates an {@link Amity.
|
|
39476
|
+
* Creates an {@link Amity.Comment}
|
|
39369
39477
|
*
|
|
39370
|
-
* @param bundle The data necessary to create a new {@link Amity.
|
|
39371
|
-
* @returns The newly created {@link Amity.
|
|
39478
|
+
* @param bundle The data necessary to create a new {@link Amity.Comment}
|
|
39479
|
+
* @returns The newly created {@link Amity.Comment}
|
|
39372
39480
|
*
|
|
39373
|
-
* @category
|
|
39481
|
+
* @category Comment API
|
|
39374
39482
|
* @async
|
|
39375
39483
|
*/
|
|
39376
|
-
const
|
|
39484
|
+
const createComment = async (bundle) => {
|
|
39485
|
+
var _a;
|
|
39377
39486
|
const client = getActiveClient();
|
|
39378
|
-
client.log('
|
|
39379
|
-
|
|
39380
|
-
|
|
39381
|
-
|
|
39382
|
-
|
|
39383
|
-
|
|
39384
|
-
fireEvent('post.created', payload);
|
|
39385
|
-
const data = preparePostPayload(payload);
|
|
39487
|
+
client.log('comment/createComment', bundle);
|
|
39488
|
+
const { data } = await client.http.post('/api/v3/comments', bundle);
|
|
39489
|
+
const { comments } = data;
|
|
39490
|
+
// BE always returns an array of comments If it got record 0 from BE it might have a problem on creation logic
|
|
39491
|
+
if (comments.length === 0)
|
|
39492
|
+
throw new Error('Comment not created');
|
|
39386
39493
|
const cachedAt = client.cache && Date.now();
|
|
39387
39494
|
if (client.cache)
|
|
39388
39495
|
ingestInCache(data, { cachedAt });
|
|
39389
|
-
|
|
39496
|
+
if (['post', 'content'].includes(bundle.referenceType)) {
|
|
39497
|
+
const post = (_a = pullFromCache(['post', 'get', bundle.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
39498
|
+
if (post) {
|
|
39499
|
+
post.commentsCount += 1;
|
|
39500
|
+
fireEvent('local.post.updated', {
|
|
39501
|
+
posts: [post],
|
|
39502
|
+
categories: [],
|
|
39503
|
+
comments: [],
|
|
39504
|
+
communities: [],
|
|
39505
|
+
communityUsers: data.communityUsers,
|
|
39506
|
+
feeds: [],
|
|
39507
|
+
files: data.files,
|
|
39508
|
+
postChildren: [],
|
|
39509
|
+
users: data.users,
|
|
39510
|
+
videoStreamings: [],
|
|
39511
|
+
});
|
|
39512
|
+
}
|
|
39513
|
+
}
|
|
39514
|
+
else if (bundle.referenceType === 'story') {
|
|
39515
|
+
const storyIndex = pullFromCache([
|
|
39516
|
+
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
39517
|
+
bundle.referenceId,
|
|
39518
|
+
]);
|
|
39519
|
+
if (storyIndex === null || storyIndex === void 0 ? void 0 : storyIndex.data) {
|
|
39520
|
+
const cacheStory = pullFromCache([
|
|
39521
|
+
"story" /* STORY_KEY_CACHE.STORY */,
|
|
39522
|
+
'get',
|
|
39523
|
+
storyIndex.data,
|
|
39524
|
+
]);
|
|
39525
|
+
if (cacheStory === null || cacheStory === void 0 ? void 0 : cacheStory.data) {
|
|
39526
|
+
fireEvent('story.updated', {
|
|
39527
|
+
stories: [
|
|
39528
|
+
Object.assign(Object.assign({}, cacheStory.data), { commentsCount: cacheStory.data.commentsCount + 1, comments: [...new Set([...cacheStory.data.comments, comments[0].commentId])] }),
|
|
39529
|
+
],
|
|
39530
|
+
categories: [],
|
|
39531
|
+
comments,
|
|
39532
|
+
communities: [],
|
|
39533
|
+
communityUsers: data.communityUsers,
|
|
39534
|
+
files: data.files,
|
|
39535
|
+
users: data.users,
|
|
39536
|
+
});
|
|
39537
|
+
}
|
|
39538
|
+
}
|
|
39539
|
+
}
|
|
39540
|
+
fireEvent('local.comment.created', data);
|
|
39390
39541
|
return {
|
|
39391
|
-
data: LinkedObject.
|
|
39542
|
+
data: LinkedObject.comment(comments[0]),
|
|
39392
39543
|
cachedAt,
|
|
39393
39544
|
};
|
|
39394
39545
|
};
|
|
39395
39546
|
/* end_public_function */
|
|
39396
39547
|
|
|
39397
39548
|
/* begin_public_function
|
|
39398
|
-
id:
|
|
39549
|
+
id: comment.update_comment
|
|
39399
39550
|
*/
|
|
39400
39551
|
/**
|
|
39401
39552
|
* ```js
|
|
39402
|
-
* import {
|
|
39403
|
-
* const updated = await
|
|
39553
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
39554
|
+
* const updated = await CommentRepository.updateComment(commentId, {
|
|
39404
39555
|
* data: { text: 'hello world' }
|
|
39405
39556
|
* })
|
|
39406
39557
|
* ```
|
|
39407
39558
|
*
|
|
39408
|
-
* Updates an {@link Amity.
|
|
39559
|
+
* Updates an {@link Amity.Comment}
|
|
39409
39560
|
*
|
|
39410
|
-
* @param
|
|
39561
|
+
* @param commentId The ID of the {@link Amity.Comment} to edit
|
|
39411
39562
|
* @param patch The patch data to apply
|
|
39412
|
-
* @returns the updated {@link Amity.
|
|
39563
|
+
* @returns the updated {@link Amity.Comment} object
|
|
39413
39564
|
*
|
|
39414
|
-
* @category
|
|
39565
|
+
* @category Comment API
|
|
39415
39566
|
* @async
|
|
39416
39567
|
*/
|
|
39417
|
-
const
|
|
39568
|
+
const updateComment = async (commentId, patch) => {
|
|
39418
39569
|
const client = getActiveClient();
|
|
39419
|
-
client.log('user/
|
|
39420
|
-
const { data
|
|
39421
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
39570
|
+
client.log('user/updateComment', patch);
|
|
39571
|
+
const { data } = await client.http.put(`/api/v3/comments/${encodeURIComponent(commentId)}`, patch);
|
|
39422
39572
|
const cachedAt = client.cache && Date.now();
|
|
39423
39573
|
if (client.cache)
|
|
39424
39574
|
ingestInCache(data, { cachedAt });
|
|
39425
|
-
fireEvent('
|
|
39426
|
-
const {
|
|
39575
|
+
fireEvent('comment.updated', data);
|
|
39576
|
+
const { comments } = data;
|
|
39427
39577
|
return {
|
|
39428
|
-
data: LinkedObject.
|
|
39578
|
+
data: LinkedObject.comment(comments.find(comment => comment.commentId === commentId)),
|
|
39429
39579
|
cachedAt,
|
|
39430
39580
|
};
|
|
39431
39581
|
};
|
|
39432
39582
|
/* end_public_function */
|
|
39433
39583
|
|
|
39584
|
+
// Due to we have optimistic logic, we will use referenceId as a id in SDK instead of storyId
|
|
39585
|
+
const applyMissingField = (rawData, isCreated = false) => {
|
|
39586
|
+
const { storyId, referenceId } = rawData;
|
|
39587
|
+
if (!isCreated) {
|
|
39588
|
+
if (referenceId)
|
|
39589
|
+
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */ });
|
|
39590
|
+
}
|
|
39591
|
+
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */, referenceId: storyId });
|
|
39592
|
+
};
|
|
39593
|
+
const convertRawStoryToInternal = (data, isCreated = false) => {
|
|
39594
|
+
const { stories } = data;
|
|
39595
|
+
const storiesData = stories.map(story => applyMissingField(story, isCreated));
|
|
39596
|
+
return Object.assign(Object.assign({}, data), { stories: storiesData });
|
|
39597
|
+
};
|
|
39598
|
+
|
|
39599
|
+
const getStoryByStoryId$1 = async (storyId) => {
|
|
39600
|
+
const client = getActiveClient();
|
|
39601
|
+
client.log('story/getStoryByStoryId', storyId);
|
|
39602
|
+
// Get story referenceId from cache
|
|
39603
|
+
const cacheReferenceId = pullFromCache([
|
|
39604
|
+
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
39605
|
+
storyId,
|
|
39606
|
+
]);
|
|
39607
|
+
if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
|
|
39608
|
+
const { data: referenceId } = cacheReferenceId;
|
|
39609
|
+
isInTombstone('story', referenceId);
|
|
39610
|
+
}
|
|
39611
|
+
let data;
|
|
39612
|
+
try {
|
|
39613
|
+
const response = await client.http.get(`/api/v4/stories/${storyId}`);
|
|
39614
|
+
data = convertRawStoryToInternal(response.data);
|
|
39615
|
+
}
|
|
39616
|
+
catch (error) {
|
|
39617
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
39618
|
+
pushToTombstone('story', storyId);
|
|
39619
|
+
}
|
|
39620
|
+
throw error;
|
|
39621
|
+
}
|
|
39622
|
+
const cachedAt = client.cache && Date.now();
|
|
39623
|
+
if (client.cache) {
|
|
39624
|
+
ingestInCache(data, { cachedAt });
|
|
39625
|
+
}
|
|
39626
|
+
return {
|
|
39627
|
+
data: data.stories[0],
|
|
39628
|
+
cachedAt,
|
|
39629
|
+
};
|
|
39630
|
+
};
|
|
39631
|
+
getStoryByStoryId$1.locally = (storyId) => {
|
|
39632
|
+
const client = getActiveClient();
|
|
39633
|
+
client.log('story/getStorybyStoryId', storyId);
|
|
39634
|
+
// Get story referenceId from cache
|
|
39635
|
+
const cacheReferenceId = pullFromCache([
|
|
39636
|
+
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
39637
|
+
storyId,
|
|
39638
|
+
]);
|
|
39639
|
+
if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
|
|
39640
|
+
const { data: referenceId } = cacheReferenceId;
|
|
39641
|
+
isInTombstone('story', referenceId);
|
|
39642
|
+
}
|
|
39643
|
+
const cachedAt = client.cache && Date.now();
|
|
39644
|
+
const storyCache = pullFromCache(['story', 'get', storyId]);
|
|
39645
|
+
if (!storyCache)
|
|
39646
|
+
return;
|
|
39647
|
+
return {
|
|
39648
|
+
data: storyCache.data,
|
|
39649
|
+
cachedAt,
|
|
39650
|
+
};
|
|
39651
|
+
};
|
|
39652
|
+
|
|
39653
|
+
/* begin_public_function
|
|
39654
|
+
id: comment.soft_delete, comment.hard_delete
|
|
39655
|
+
*/
|
|
39434
39656
|
/**
|
|
39435
39657
|
* ```js
|
|
39436
|
-
* import {
|
|
39437
|
-
* const success = await
|
|
39658
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
39659
|
+
* const success = await CommentRepository.deleteComment('foobar')
|
|
39438
39660
|
* ```
|
|
39439
39661
|
*
|
|
39440
|
-
* Deletes a {@link Amity.
|
|
39662
|
+
* Deletes a {@link Amity.Comment}
|
|
39441
39663
|
*
|
|
39442
|
-
* @param
|
|
39443
|
-
* @return A success boolean if the {@link Amity.
|
|
39664
|
+
* @param commentId The {@link Amity.Comment} ID to delete
|
|
39665
|
+
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
39444
39666
|
*
|
|
39445
|
-
* @
|
|
39667
|
+
* @category Comment API
|
|
39446
39668
|
* @async
|
|
39447
39669
|
*/
|
|
39448
|
-
const
|
|
39670
|
+
const deleteComment = async (commentId, permanent = false) => {
|
|
39449
39671
|
var _a;
|
|
39450
39672
|
const client = getActiveClient();
|
|
39451
|
-
const
|
|
39452
|
-
|
|
39673
|
+
const comment = await getComment$2(commentId);
|
|
39674
|
+
// API-FIX: This endpoint has not been implemented yet.
|
|
39675
|
+
await client.http.delete(`/api/v4/comments/${encodeURIComponent(commentId)}`, {
|
|
39453
39676
|
params: {
|
|
39454
|
-
|
|
39677
|
+
commentId,
|
|
39455
39678
|
permanent,
|
|
39456
39679
|
},
|
|
39457
39680
|
});
|
|
39458
|
-
//
|
|
39459
|
-
|
|
39460
|
-
|
|
39461
|
-
|
|
39462
|
-
|
|
39463
|
-
|
|
39464
|
-
const communityUsersCache = (_a = queryCache(['communityUsers', 'get'])) !== null && _a !== void 0 ? _a : [];
|
|
39465
|
-
const communityUsers = communityUsersCache
|
|
39466
|
-
.filter(({ key }) => {
|
|
39467
|
-
// cache key is ['communityUsers', 'get', `${communityId}#`${userId}`}]
|
|
39468
|
-
if (key[0] !== 'communityUsers')
|
|
39469
|
-
return false;
|
|
39470
|
-
if (key[1] !== 'get')
|
|
39471
|
-
return false;
|
|
39472
|
-
if (typeof key[2] === 'string')
|
|
39473
|
-
return key[2].includes(community.data.communityId);
|
|
39474
|
-
return false;
|
|
39475
|
-
})
|
|
39476
|
-
.map(({ data }) => data);
|
|
39477
|
-
fireEvent('community.updated', {
|
|
39478
|
-
communities: [community.data],
|
|
39681
|
+
// to support hard deletion
|
|
39682
|
+
const deleted = Object.assign(Object.assign({}, comment.data), { isDeleted: true });
|
|
39683
|
+
if (comment.data.referenceType === 'story') {
|
|
39684
|
+
const story = await getStoryByStoryId$1(comment.data.referenceId);
|
|
39685
|
+
fireEvent('local.story.updated', {
|
|
39686
|
+
stories: [story.data],
|
|
39479
39687
|
categories: [],
|
|
39480
|
-
|
|
39481
|
-
|
|
39688
|
+
comments: [],
|
|
39689
|
+
communities: [],
|
|
39690
|
+
communityUsers: [],
|
|
39482
39691
|
files: [],
|
|
39483
39692
|
users: [],
|
|
39484
39693
|
});
|
|
39485
39694
|
}
|
|
39486
|
-
// to support hard deletion
|
|
39487
|
-
const deleted = Object.assign(Object.assign({}, post.data), { isDeleted: true });
|
|
39488
|
-
if (permanent) {
|
|
39489
|
-
setTimeout(() => {
|
|
39490
|
-
pushToTombstone('post', postId);
|
|
39491
|
-
}, 0);
|
|
39492
|
-
}
|
|
39493
39695
|
else {
|
|
39494
|
-
|
|
39696
|
+
const post = (_a = pullFromCache(['post', 'get', comment.data.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
39697
|
+
if (post) {
|
|
39698
|
+
let removeCount;
|
|
39699
|
+
if (!deleted.parentId) {
|
|
39700
|
+
// NOTE: delete the parent comment will remove all children comments
|
|
39701
|
+
removeCount = deleted.childrenNumber + 1;
|
|
39702
|
+
}
|
|
39703
|
+
else
|
|
39704
|
+
removeCount = 1;
|
|
39705
|
+
post.commentsCount -= removeCount;
|
|
39706
|
+
fireEvent('local.post.updated', {
|
|
39707
|
+
posts: [post],
|
|
39708
|
+
categories: [],
|
|
39709
|
+
comments: [],
|
|
39710
|
+
communities: [],
|
|
39711
|
+
communityUsers: [],
|
|
39712
|
+
feeds: [],
|
|
39713
|
+
files: [],
|
|
39714
|
+
postChildren: [],
|
|
39715
|
+
users: [],
|
|
39716
|
+
videoStreamings: [],
|
|
39717
|
+
});
|
|
39718
|
+
}
|
|
39495
39719
|
}
|
|
39496
|
-
fireEvent('local.
|
|
39497
|
-
|
|
39498
|
-
|
|
39499
|
-
comments: [],
|
|
39500
|
-
communities: [],
|
|
39501
|
-
communityUsers: [],
|
|
39502
|
-
feeds: [],
|
|
39720
|
+
fireEvent('local.comment.deleted', {
|
|
39721
|
+
comments: [deleted],
|
|
39722
|
+
commentChildren: [],
|
|
39503
39723
|
files: [],
|
|
39504
|
-
postChildren: [],
|
|
39505
39724
|
users: [],
|
|
39506
|
-
|
|
39725
|
+
communityUsers: [],
|
|
39507
39726
|
});
|
|
39508
|
-
|
|
39727
|
+
if (permanent) {
|
|
39728
|
+
scheduleTask(() => pushToTombstone('comment', commentId));
|
|
39729
|
+
}
|
|
39730
|
+
else {
|
|
39731
|
+
upsertInCache(['comment', 'get', commentId], { isDeleted: true });
|
|
39732
|
+
}
|
|
39733
|
+
return deleted;
|
|
39509
39734
|
};
|
|
39735
|
+
/* end_public_function */
|
|
39510
39736
|
|
|
39511
39737
|
/* begin_public_function
|
|
39512
|
-
id:
|
|
39738
|
+
id: comment.soft_delete
|
|
39513
39739
|
*/
|
|
39514
39740
|
/**
|
|
39515
39741
|
* ```js
|
|
39516
|
-
* import {
|
|
39517
|
-
* const success = await
|
|
39742
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
39743
|
+
* const success = await CommentRepository.softDeleteComment('foobar')
|
|
39518
39744
|
* ```
|
|
39519
39745
|
*
|
|
39520
|
-
*
|
|
39746
|
+
* Deletes a {@link Amity.Comment}
|
|
39521
39747
|
*
|
|
39522
|
-
* @param
|
|
39523
|
-
* @return A success boolean if the {@link Amity.
|
|
39748
|
+
* @param commentId The {@link Amity.Comment} ID to delete
|
|
39749
|
+
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
39524
39750
|
*
|
|
39525
|
-
* @category
|
|
39751
|
+
* @category Comment API
|
|
39526
39752
|
* @async
|
|
39527
39753
|
*/
|
|
39528
|
-
const
|
|
39754
|
+
const softDeleteComment = async (commentId) => {
|
|
39529
39755
|
const client = getActiveClient();
|
|
39530
|
-
client.log('
|
|
39531
|
-
const softDeleted =
|
|
39532
|
-
return
|
|
39756
|
+
client.log('comment/softDeleteComment', commentId);
|
|
39757
|
+
const softDeleted = deleteComment(commentId);
|
|
39758
|
+
return softDeleted;
|
|
39533
39759
|
};
|
|
39534
39760
|
/* end_public_function */
|
|
39535
39761
|
|
|
39536
39762
|
/* begin_public_function
|
|
39537
|
-
id:
|
|
39763
|
+
id: comment.hard_delete
|
|
39538
39764
|
*/
|
|
39539
39765
|
/**
|
|
39540
39766
|
* ```js
|
|
39541
|
-
* import {
|
|
39542
|
-
* const success = await
|
|
39767
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
39768
|
+
* const success = await CommentRepository.hardDeleteComment('foobar')
|
|
39543
39769
|
* ```
|
|
39544
39770
|
*
|
|
39545
|
-
*
|
|
39771
|
+
* Deletes a {@link Amity.Comment}
|
|
39546
39772
|
*
|
|
39547
|
-
* @param
|
|
39548
|
-
* @return A success boolean if the {@link Amity.
|
|
39773
|
+
* @param commentId The {@link Amity.Comment} ID to delete
|
|
39774
|
+
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
39549
39775
|
*
|
|
39550
|
-
* @category
|
|
39776
|
+
* @category Comment API
|
|
39551
39777
|
* @async
|
|
39552
39778
|
*/
|
|
39553
|
-
const
|
|
39779
|
+
const hardDeleteComment = async (commentId) => {
|
|
39554
39780
|
const client = getActiveClient();
|
|
39555
|
-
client.log('
|
|
39556
|
-
const hardDeleted =
|
|
39557
|
-
return
|
|
39781
|
+
client.log('comment/hardDeleteComment', commentId);
|
|
39782
|
+
const hardDeleted = deleteComment(commentId, true);
|
|
39783
|
+
return hardDeleted;
|
|
39558
39784
|
};
|
|
39559
39785
|
/* end_public_function */
|
|
39560
39786
|
|
|
39561
39787
|
/* begin_public_function
|
|
39562
|
-
id:
|
|
39788
|
+
id: comment.flag
|
|
39563
39789
|
*/
|
|
39564
39790
|
/**
|
|
39565
39791
|
* ```js
|
|
39566
|
-
* import {
|
|
39567
|
-
*
|
|
39568
|
-
* const { data: post } = await approvePost('postId')
|
|
39792
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
39793
|
+
* const flagged = await CommentRepository.flagComment(commentId, reason)
|
|
39569
39794
|
* ```
|
|
39570
39795
|
*
|
|
39571
|
-
*
|
|
39572
|
-
*
|
|
39573
|
-
* @
|
|
39574
|
-
* @return A {@link Amity.Post} that was approved
|
|
39796
|
+
* @param commentId The ID of the comment to flag
|
|
39797
|
+
* @param reason the reason to flag the comment
|
|
39798
|
+
* @returns the created report result
|
|
39575
39799
|
*
|
|
39576
|
-
* @category
|
|
39800
|
+
* @category Comment API
|
|
39577
39801
|
* @async
|
|
39578
|
-
*/
|
|
39579
|
-
const
|
|
39802
|
+
* */
|
|
39803
|
+
const flagComment = async (commentId, reason) => {
|
|
39580
39804
|
const client = getActiveClient();
|
|
39581
|
-
client.log('
|
|
39582
|
-
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/approve`);
|
|
39583
|
-
fireEvent('post.approved', payload);
|
|
39584
|
-
// fire virtual event for community update
|
|
39585
|
-
if (payload.posts[0].targetType === 'community') {
|
|
39586
|
-
fireEvent('community.updated', payload);
|
|
39587
|
-
}
|
|
39588
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
39589
|
-
const cachedAt = client.cache && Date.now();
|
|
39590
|
-
if (client.cache)
|
|
39591
|
-
ingestInCache(data, { cachedAt });
|
|
39592
|
-
return {
|
|
39593
|
-
data: LinkedObject.post(data.posts.find(post => post.postId === postId)),
|
|
39594
|
-
cachedAt,
|
|
39595
|
-
};
|
|
39596
|
-
};
|
|
39597
|
-
/* end_public_function */
|
|
39598
|
-
|
|
39599
|
-
/* begin_public_function
|
|
39600
|
-
id: post.decline
|
|
39601
|
-
*/
|
|
39602
|
-
/**
|
|
39603
|
-
* ```js
|
|
39604
|
-
* import { declinePost } from '@amityco/ts-sdk'
|
|
39605
|
-
*
|
|
39606
|
-
* const {data: post} = await declinePost('postId')
|
|
39607
|
-
* ```
|
|
39608
|
-
*
|
|
39609
|
-
* Declines a {@link Amity.Post}
|
|
39610
|
-
*
|
|
39611
|
-
* @param postId The {@link Amity.Post} ID to be declined
|
|
39612
|
-
* @return A {@link Amity.Post} that was declined
|
|
39613
|
-
*
|
|
39614
|
-
* @category Post API
|
|
39615
|
-
* @async
|
|
39616
|
-
*/
|
|
39617
|
-
const declinePost = async (postId) => {
|
|
39618
|
-
const client = getActiveClient();
|
|
39619
|
-
client.log('post/declinePost', postId);
|
|
39620
|
-
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/decline`);
|
|
39621
|
-
// fire virtual event
|
|
39622
|
-
if (payload.posts[0].targetType === 'community') {
|
|
39623
|
-
fireEvent('community.updated', payload);
|
|
39624
|
-
}
|
|
39625
|
-
fireEvent('post.declined', payload);
|
|
39626
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
39627
|
-
const cachedAt = client.cache && Date.now();
|
|
39628
|
-
if (client.cache)
|
|
39629
|
-
ingestInCache(data, { cachedAt });
|
|
39630
|
-
return {
|
|
39631
|
-
data: LinkedObject.post(payload.posts.find(post => post.postId === postId)),
|
|
39632
|
-
cachedAt,
|
|
39633
|
-
};
|
|
39634
|
-
};
|
|
39635
|
-
/* end_public_function */
|
|
39636
|
-
|
|
39637
|
-
/* begin_public_function
|
|
39638
|
-
id: post.flag
|
|
39639
|
-
*/
|
|
39640
|
-
/**
|
|
39641
|
-
* ```js
|
|
39642
|
-
* import { PostRepository } from '@amityco/ts-sdk'
|
|
39643
|
-
* const flagged = await PostRepository.flagPost(postId, reason)
|
|
39644
|
-
* ```
|
|
39645
|
-
*
|
|
39646
|
-
* @param postId of the post to flag
|
|
39647
|
-
* @param reason the reason to flag the post
|
|
39648
|
-
* @returns a boolean
|
|
39649
|
-
*
|
|
39650
|
-
* @category Post API
|
|
39651
|
-
* @async
|
|
39652
|
-
* */
|
|
39653
|
-
const flagPost = async (postId, reason) => {
|
|
39654
|
-
const client = getActiveClient();
|
|
39655
|
-
client.log('post/flagPost', postId);
|
|
39805
|
+
client.log('comment/flagComment', commentId);
|
|
39656
39806
|
const isPredefinedReason = reason &&
|
|
39657
39807
|
Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
|
|
39658
39808
|
const body = {
|
|
39659
39809
|
reason: reason && isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
|
|
39660
39810
|
detail: reason && !isPredefinedReason ? reason : '',
|
|
39661
39811
|
};
|
|
39662
|
-
const { data: payload } = await client.http.post(`/api/v3/
|
|
39812
|
+
const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
|
|
39663
39813
|
if (client.cache) {
|
|
39664
|
-
ingestInCache(
|
|
39814
|
+
ingestInCache(payload);
|
|
39665
39815
|
}
|
|
39666
|
-
fireEvent('
|
|
39816
|
+
fireEvent('comment.flagged', payload);
|
|
39667
39817
|
return !!payload;
|
|
39668
39818
|
};
|
|
39669
39819
|
/* end_public_function */
|
|
39670
39820
|
|
|
39671
39821
|
/* begin_public_function
|
|
39672
|
-
id:
|
|
39822
|
+
id: comment.unflag
|
|
39673
39823
|
*/
|
|
39674
39824
|
/**
|
|
39675
39825
|
* ```js
|
|
39676
|
-
* import {
|
|
39677
|
-
* const unflagged = await
|
|
39826
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
39827
|
+
* const unflagged = await CommentRepository.unflagComment('commentId')
|
|
39678
39828
|
* ```
|
|
39679
39829
|
*
|
|
39680
|
-
* @param
|
|
39681
|
-
* @returns the
|
|
39830
|
+
* @param commentId The ID of comment to unflag
|
|
39831
|
+
* @returns the unflagged result
|
|
39682
39832
|
*
|
|
39683
|
-
* @category
|
|
39833
|
+
* @category Comment API
|
|
39684
39834
|
* @async
|
|
39685
39835
|
* */
|
|
39686
|
-
const
|
|
39836
|
+
const unflagComment = async (commentId) => {
|
|
39687
39837
|
const client = getActiveClient();
|
|
39688
|
-
client.log('
|
|
39689
|
-
const { data: payload } = await client.http.delete(`/api/v3/
|
|
39838
|
+
client.log('comment/unflagComment', commentId);
|
|
39839
|
+
const { data: payload } = await client.http.delete(`/api/v3/comments/${encodeURIComponent(commentId)}/unflag`);
|
|
39690
39840
|
if (client.cache) {
|
|
39691
|
-
ingestInCache(
|
|
39841
|
+
ingestInCache(payload);
|
|
39692
39842
|
}
|
|
39693
|
-
fireEvent('
|
|
39843
|
+
fireEvent('comment.unflagged', payload);
|
|
39694
39844
|
return !!payload;
|
|
39695
39845
|
};
|
|
39696
39846
|
/* end_public_function */
|
|
39697
39847
|
|
|
39698
39848
|
/* begin_public_function
|
|
39699
|
-
id:
|
|
39849
|
+
id: comment.check_flag_by_me
|
|
39700
39850
|
*/
|
|
39701
39851
|
/**
|
|
39702
39852
|
* ```js
|
|
39703
|
-
* import {
|
|
39704
|
-
* const isReported = await
|
|
39853
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
39854
|
+
* const isReported = await CommentRepository.isCommentFlaggedByMe('commentId')
|
|
39705
39855
|
* ```
|
|
39706
39856
|
*
|
|
39707
|
-
* @param
|
|
39708
|
-
* @returns `true` if the
|
|
39857
|
+
* @param commentId The ID of the comment to check if flagged by current user
|
|
39858
|
+
* @returns `true` if the comment is flagged by me, `false` if doesn't.
|
|
39709
39859
|
*
|
|
39710
|
-
* @category
|
|
39860
|
+
* @category Comment API
|
|
39711
39861
|
* @async
|
|
39712
39862
|
* */
|
|
39713
|
-
const
|
|
39863
|
+
const isCommentFlaggedByMe = async (commentId) => {
|
|
39714
39864
|
const client = getActiveClient();
|
|
39715
|
-
client.log('
|
|
39716
|
-
const { data: { result }, } = await client.http.get(`/api/v3/
|
|
39865
|
+
client.log('comment/isCommentFlaggedByMe', commentId);
|
|
39866
|
+
const { data: { result }, } = await client.http.get(`/api/v3/comments/${commentId}/isflagbyme`);
|
|
39717
39867
|
return result;
|
|
39718
39868
|
};
|
|
39719
39869
|
/* end_public_function */
|
|
39720
39870
|
|
|
39721
|
-
|
|
39722
|
-
id: post.create.clip_post
|
|
39723
|
-
*/
|
|
39724
|
-
/**
|
|
39725
|
-
* ```js
|
|
39726
|
-
* import { PostRepository } from '@amityco/ts-sdk'
|
|
39727
|
-
* const created = await PostRepository.createClipPost({
|
|
39728
|
-
* targetType: 'user',
|
|
39729
|
-
* targetId: 'foobar',
|
|
39730
|
-
* dataType: 'clip',
|
|
39731
|
-
* data: { text: 'hello world' },
|
|
39732
|
-
* attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
|
|
39733
|
-
* }))
|
|
39734
|
-
* ```
|
|
39735
|
-
*
|
|
39736
|
-
* Creates an {@link Amity.Post}
|
|
39737
|
-
*
|
|
39738
|
-
* @param bundle The data necessary to create a new {@link Amity.Post}
|
|
39739
|
-
* @returns The newly created {@link Amity.Post}
|
|
39740
|
-
*
|
|
39741
|
-
* @category Post API
|
|
39742
|
-
* @async
|
|
39743
|
-
*/
|
|
39744
|
-
const createClipPost = async (bundle) => {
|
|
39745
|
-
const client = getActiveClient();
|
|
39746
|
-
client.log('post/createPost', bundle);
|
|
39747
|
-
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
39748
|
-
fireEvent('post.created', payload);
|
|
39749
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
39750
|
-
const cachedAt = client.cache && Date.now();
|
|
39751
|
-
if (client.cache)
|
|
39752
|
-
ingestInCache(data, { cachedAt });
|
|
39753
|
-
const { posts } = data;
|
|
39754
|
-
return {
|
|
39755
|
-
data: LinkedObject.post(posts[0]),
|
|
39756
|
-
cachedAt,
|
|
39757
|
-
};
|
|
39758
|
-
};
|
|
39759
|
-
/* end_public_function */
|
|
39760
|
-
|
|
39761
|
-
/* begin_public_function
|
|
39762
|
-
id: comment.get_by_ids
|
|
39763
|
-
*/
|
|
39764
|
-
/**
|
|
39765
|
-
* ```js
|
|
39766
|
-
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
39767
|
-
* const comments = await CommentRepository.getCommentByIds(['foo', 'bar'])
|
|
39768
|
-
* ```
|
|
39769
|
-
*
|
|
39770
|
-
* Fetches a collection of {@link Amity.Comment} objects
|
|
39771
|
-
*
|
|
39772
|
-
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
39773
|
-
* @returns the associated collection of {@link Amity.Comment} objects
|
|
39774
|
-
*
|
|
39775
|
-
* @category Comment API
|
|
39776
|
-
* @async
|
|
39777
|
-
*/
|
|
39778
|
-
const getCommentByIds = async (commentIds) => {
|
|
39871
|
+
const getComment$1 = async (commentId) => {
|
|
39779
39872
|
const client = getActiveClient();
|
|
39780
|
-
client.log('comment/
|
|
39781
|
-
|
|
39873
|
+
client.log('comment/getComment', commentId);
|
|
39874
|
+
isInTombstone('comment', commentId);
|
|
39782
39875
|
let data;
|
|
39783
39876
|
try {
|
|
39784
39877
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
39785
|
-
const response = await client.http.get(`/api/v3/comments
|
|
39786
|
-
params: { commentIds: encodedCommentIds },
|
|
39787
|
-
});
|
|
39878
|
+
const response = await client.http.get(`/api/v3/comments/${encodeURIComponent(commentId)}`);
|
|
39788
39879
|
data = response.data;
|
|
39789
39880
|
}
|
|
39790
39881
|
catch (error) {
|
|
39791
|
-
|
|
39792
|
-
|
|
39793
|
-
|
|
39794
|
-
}
|
|
39795
|
-
});
|
|
39882
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
39883
|
+
pushToTombstone('comment', commentId);
|
|
39884
|
+
}
|
|
39796
39885
|
throw error;
|
|
39797
39886
|
}
|
|
39798
39887
|
const cachedAt = client.cache && Date.now();
|
|
39799
39888
|
if (client.cache)
|
|
39800
39889
|
ingestInCache(data, { cachedAt });
|
|
39890
|
+
const { comments } = data;
|
|
39801
39891
|
return {
|
|
39802
|
-
data:
|
|
39892
|
+
data: comments.find(comment => comment.commentId === commentId),
|
|
39803
39893
|
cachedAt,
|
|
39804
39894
|
};
|
|
39805
39895
|
};
|
|
39806
|
-
|
|
39807
|
-
/**
|
|
39808
|
-
* ```js
|
|
39809
|
-
* import { getCommentByIds } from '@amityco/ts-sdk'
|
|
39810
|
-
* const comments = getCommentByIds.locally(['foo', 'bar'])
|
|
39811
|
-
* ```
|
|
39812
|
-
*
|
|
39813
|
-
* Fetches a collection of {@link Amity.Comment} objects from cache
|
|
39814
|
-
*
|
|
39815
|
-
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
39816
|
-
* @returns the associated collection of {@link Amity.Comment} objects
|
|
39817
|
-
*
|
|
39818
|
-
* @category Comment API
|
|
39819
|
-
*/
|
|
39820
|
-
getCommentByIds.locally = (commentIds) => {
|
|
39821
|
-
var _a;
|
|
39896
|
+
getComment$1.locally = (commentId) => {
|
|
39822
39897
|
const client = getActiveClient();
|
|
39823
|
-
client.log('comment/
|
|
39898
|
+
client.log('comment/getComment.locally', commentId);
|
|
39824
39899
|
if (!client.cache)
|
|
39825
39900
|
return;
|
|
39826
|
-
const cached =
|
|
39827
|
-
|
|
39828
|
-
.filter(Boolean);
|
|
39829
|
-
const comments = cached.map(({ data }) => data);
|
|
39830
|
-
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
39831
|
-
if ((cached === null || cached === void 0 ? void 0 : cached.length) < commentIds.length)
|
|
39901
|
+
const cached = pullFromCache(['comment', 'get', commentId]);
|
|
39902
|
+
if (!cached)
|
|
39832
39903
|
return;
|
|
39833
39904
|
return {
|
|
39834
|
-
data:
|
|
39835
|
-
cachedAt:
|
|
39905
|
+
data: cached.data,
|
|
39906
|
+
cachedAt: cached.cachedAt,
|
|
39836
39907
|
};
|
|
39837
39908
|
};
|
|
39838
39909
|
|
|
39839
|
-
/* begin_public_function
|
|
39840
|
-
id: comment.create
|
|
39841
|
-
*/
|
|
39842
39910
|
/**
|
|
39843
39911
|
* ```js
|
|
39844
|
-
* import {
|
|
39845
|
-
* const
|
|
39912
|
+
* import { onCommentDeleteLocal } from '@amityco/ts-sdk'
|
|
39913
|
+
* const dispose = onCommentDeleteLocal(comment => {
|
|
39914
|
+
* // ...
|
|
39915
|
+
* })
|
|
39846
39916
|
* ```
|
|
39847
39917
|
*
|
|
39848
|
-
*
|
|
39918
|
+
* Fired when a {@link Amity.InternalComment} has been deleted
|
|
39849
39919
|
*
|
|
39850
|
-
* @param
|
|
39851
|
-
* @returns
|
|
39920
|
+
* @param callback The function to call when the event was fired
|
|
39921
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
39852
39922
|
*
|
|
39853
|
-
* @category Comment
|
|
39854
|
-
* @async
|
|
39923
|
+
* @category Comment Events
|
|
39855
39924
|
*/
|
|
39856
|
-
const
|
|
39857
|
-
var _a;
|
|
39858
|
-
const client = getActiveClient();
|
|
39859
|
-
client.log('comment/createComment', bundle);
|
|
39860
|
-
const { data } = await client.http.post('/api/v3/comments', bundle);
|
|
39861
|
-
const { comments } = data;
|
|
39862
|
-
// BE always returns an array of comments If it got record 0 from BE it might have a problem on creation logic
|
|
39863
|
-
if (comments.length === 0)
|
|
39864
|
-
throw new Error('Comment not created');
|
|
39865
|
-
const cachedAt = client.cache && Date.now();
|
|
39866
|
-
if (client.cache)
|
|
39867
|
-
ingestInCache(data, { cachedAt });
|
|
39868
|
-
if (['post', 'content'].includes(bundle.referenceType)) {
|
|
39869
|
-
const post = (_a = pullFromCache(['post', 'get', bundle.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
39870
|
-
if (post) {
|
|
39871
|
-
post.commentsCount += 1;
|
|
39872
|
-
fireEvent('local.post.updated', {
|
|
39873
|
-
posts: [post],
|
|
39874
|
-
categories: [],
|
|
39875
|
-
comments: [],
|
|
39876
|
-
communities: [],
|
|
39877
|
-
communityUsers: data.communityUsers,
|
|
39878
|
-
feeds: [],
|
|
39879
|
-
files: data.files,
|
|
39880
|
-
postChildren: [],
|
|
39881
|
-
users: data.users,
|
|
39882
|
-
videoStreamings: [],
|
|
39883
|
-
});
|
|
39884
|
-
}
|
|
39885
|
-
}
|
|
39886
|
-
else if (bundle.referenceType === 'story') {
|
|
39887
|
-
const storyIndex = pullFromCache([
|
|
39888
|
-
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
39889
|
-
bundle.referenceId,
|
|
39890
|
-
]);
|
|
39891
|
-
if (storyIndex === null || storyIndex === void 0 ? void 0 : storyIndex.data) {
|
|
39892
|
-
const cacheStory = pullFromCache([
|
|
39893
|
-
"story" /* STORY_KEY_CACHE.STORY */,
|
|
39894
|
-
'get',
|
|
39895
|
-
storyIndex.data,
|
|
39896
|
-
]);
|
|
39897
|
-
if (cacheStory === null || cacheStory === void 0 ? void 0 : cacheStory.data) {
|
|
39898
|
-
fireEvent('story.updated', {
|
|
39899
|
-
stories: [
|
|
39900
|
-
Object.assign(Object.assign({}, cacheStory.data), { commentsCount: cacheStory.data.commentsCount + 1, comments: [...new Set([...cacheStory.data.comments, comments[0].commentId])] }),
|
|
39901
|
-
],
|
|
39902
|
-
categories: [],
|
|
39903
|
-
comments,
|
|
39904
|
-
communities: [],
|
|
39905
|
-
communityUsers: data.communityUsers,
|
|
39906
|
-
files: data.files,
|
|
39907
|
-
users: data.users,
|
|
39908
|
-
});
|
|
39909
|
-
}
|
|
39910
|
-
}
|
|
39911
|
-
}
|
|
39912
|
-
fireEvent('local.comment.created', data);
|
|
39913
|
-
return {
|
|
39914
|
-
data: LinkedObject.comment(comments[0]),
|
|
39915
|
-
cachedAt,
|
|
39916
|
-
};
|
|
39917
|
-
};
|
|
39918
|
-
/* end_public_function */
|
|
39925
|
+
const onCommentDeleteLocal = (callback) => createLocalCommentEventSubscriber('local.comment.deleted', callback);
|
|
39919
39926
|
|
|
39920
|
-
/* begin_public_function
|
|
39921
|
-
id: comment.update_comment
|
|
39922
|
-
*/
|
|
39923
39927
|
/**
|
|
39924
39928
|
* ```js
|
|
39925
|
-
* import {
|
|
39926
|
-
* const
|
|
39927
|
-
*
|
|
39929
|
+
* import { onLocalCommentReactionAdded } from '@amityco/ts-sdk'
|
|
39930
|
+
* const dispose = onLocalCommentReactionAdded(comment => {
|
|
39931
|
+
* // ...
|
|
39928
39932
|
* })
|
|
39929
39933
|
* ```
|
|
39930
39934
|
*
|
|
39931
|
-
*
|
|
39935
|
+
* Fired when a {@link Amity.InternalComment} has been reacted
|
|
39932
39936
|
*
|
|
39933
|
-
* @param
|
|
39934
|
-
* @
|
|
39935
|
-
* @returns the updated {@link Amity.Comment} object
|
|
39937
|
+
* @param callback The function to call when the event was fired
|
|
39938
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
39936
39939
|
*
|
|
39937
|
-
* @category Comment
|
|
39938
|
-
* @async
|
|
39940
|
+
* @category Comment Events
|
|
39939
39941
|
*/
|
|
39940
|
-
const
|
|
39941
|
-
const client = getActiveClient();
|
|
39942
|
-
client.log('user/updateComment', patch);
|
|
39943
|
-
const { data } = await client.http.put(`/api/v3/comments/${encodeURIComponent(commentId)}`, patch);
|
|
39944
|
-
const cachedAt = client.cache && Date.now();
|
|
39945
|
-
if (client.cache)
|
|
39946
|
-
ingestInCache(data, { cachedAt });
|
|
39947
|
-
fireEvent('comment.updated', data);
|
|
39948
|
-
const { comments } = data;
|
|
39949
|
-
return {
|
|
39950
|
-
data: LinkedObject.comment(comments.find(comment => comment.commentId === commentId)),
|
|
39951
|
-
cachedAt,
|
|
39952
|
-
};
|
|
39953
|
-
};
|
|
39954
|
-
/* end_public_function */
|
|
39955
|
-
|
|
39956
|
-
// Due to we have optimistic logic, we will use referenceId as a id in SDK instead of storyId
|
|
39957
|
-
const applyMissingField = (rawData, isCreated = false) => {
|
|
39958
|
-
const { storyId, referenceId } = rawData;
|
|
39959
|
-
if (!isCreated) {
|
|
39960
|
-
if (referenceId)
|
|
39961
|
-
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */ });
|
|
39962
|
-
}
|
|
39963
|
-
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */, referenceId: storyId });
|
|
39964
|
-
};
|
|
39965
|
-
const convertRawStoryToInternal = (data, isCreated = false) => {
|
|
39966
|
-
const { stories } = data;
|
|
39967
|
-
const storiesData = stories.map(story => applyMissingField(story, isCreated));
|
|
39968
|
-
return Object.assign(Object.assign({}, data), { stories: storiesData });
|
|
39969
|
-
};
|
|
39970
|
-
|
|
39971
|
-
const getStoryByStoryId$1 = async (storyId) => {
|
|
39942
|
+
const onLocalCommentReactionAdded = (callback) => {
|
|
39972
39943
|
const client = getActiveClient();
|
|
39973
|
-
|
|
39974
|
-
|
|
39975
|
-
|
|
39976
|
-
|
|
39977
|
-
|
|
39978
|
-
|
|
39979
|
-
|
|
39980
|
-
const { data: referenceId } = cacheReferenceId;
|
|
39981
|
-
isInTombstone('story', referenceId);
|
|
39982
|
-
}
|
|
39983
|
-
let data;
|
|
39984
|
-
try {
|
|
39985
|
-
const response = await client.http.get(`/api/v4/stories/${storyId}`);
|
|
39986
|
-
data = convertRawStoryToInternal(response.data);
|
|
39987
|
-
}
|
|
39988
|
-
catch (error) {
|
|
39989
|
-
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
39990
|
-
pushToTombstone('story', storyId);
|
|
39944
|
+
const filter = ({ comment }) => {
|
|
39945
|
+
if (!client.cache) {
|
|
39946
|
+
callback(comment);
|
|
39947
|
+
}
|
|
39948
|
+
else {
|
|
39949
|
+
upsertInCache(['comment', 'get', comment.commentId], comment);
|
|
39950
|
+
callback(commentLinkedObject(comment));
|
|
39991
39951
|
}
|
|
39992
|
-
throw error;
|
|
39993
|
-
}
|
|
39994
|
-
const cachedAt = client.cache && Date.now();
|
|
39995
|
-
if (client.cache) {
|
|
39996
|
-
ingestInCache(data, { cachedAt });
|
|
39997
|
-
}
|
|
39998
|
-
return {
|
|
39999
|
-
data: data.stories[0],
|
|
40000
|
-
cachedAt,
|
|
40001
|
-
};
|
|
40002
|
-
};
|
|
40003
|
-
getStoryByStoryId$1.locally = (storyId) => {
|
|
40004
|
-
const client = getActiveClient();
|
|
40005
|
-
client.log('story/getStorybyStoryId', storyId);
|
|
40006
|
-
// Get story referenceId from cache
|
|
40007
|
-
const cacheReferenceId = pullFromCache([
|
|
40008
|
-
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
40009
|
-
storyId,
|
|
40010
|
-
]);
|
|
40011
|
-
if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
|
|
40012
|
-
const { data: referenceId } = cacheReferenceId;
|
|
40013
|
-
isInTombstone('story', referenceId);
|
|
40014
|
-
}
|
|
40015
|
-
const cachedAt = client.cache && Date.now();
|
|
40016
|
-
const storyCache = pullFromCache(['story', 'get', storyId]);
|
|
40017
|
-
if (!storyCache)
|
|
40018
|
-
return;
|
|
40019
|
-
return {
|
|
40020
|
-
data: storyCache.data,
|
|
40021
|
-
cachedAt,
|
|
40022
39952
|
};
|
|
39953
|
+
return createEventSubscriber(client, 'local.comment.addReaction', 'local.comment.addReaction', filter);
|
|
40023
39954
|
};
|
|
40024
39955
|
|
|
40025
|
-
/* begin_public_function
|
|
40026
|
-
id: comment.soft_delete, comment.hard_delete
|
|
40027
|
-
*/
|
|
40028
39956
|
/**
|
|
40029
39957
|
* ```js
|
|
40030
|
-
* import {
|
|
40031
|
-
* const
|
|
39958
|
+
* import { onLocalCommentReactionRemoved } from '@amityco/ts-sdk'
|
|
39959
|
+
* const dispose = onLocalCommentReactionRemoved(comment => {
|
|
39960
|
+
* // ...
|
|
39961
|
+
* })
|
|
40032
39962
|
* ```
|
|
40033
39963
|
*
|
|
40034
|
-
*
|
|
39964
|
+
* Fired when a {@link Amity.InternalComment} has been reacted
|
|
40035
39965
|
*
|
|
40036
|
-
* @param
|
|
40037
|
-
* @
|
|
39966
|
+
* @param callback The function to call when the event was fired
|
|
39967
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
40038
39968
|
*
|
|
40039
|
-
* @category Comment
|
|
40040
|
-
* @async
|
|
39969
|
+
* @category Comment Events
|
|
40041
39970
|
*/
|
|
40042
|
-
const
|
|
40043
|
-
var _a;
|
|
39971
|
+
const onLocalCommentReactionRemoved = (callback) => {
|
|
40044
39972
|
const client = getActiveClient();
|
|
40045
|
-
const
|
|
40046
|
-
|
|
40047
|
-
|
|
40048
|
-
params: {
|
|
40049
|
-
commentId,
|
|
40050
|
-
permanent,
|
|
40051
|
-
},
|
|
40052
|
-
});
|
|
40053
|
-
// to support hard deletion
|
|
40054
|
-
const deleted = Object.assign(Object.assign({}, comment.data), { isDeleted: true });
|
|
40055
|
-
if (comment.data.referenceType === 'story') {
|
|
40056
|
-
const story = await getStoryByStoryId$1(comment.data.referenceId);
|
|
40057
|
-
fireEvent('local.story.updated', {
|
|
40058
|
-
stories: [story.data],
|
|
40059
|
-
categories: [],
|
|
40060
|
-
comments: [],
|
|
40061
|
-
communities: [],
|
|
40062
|
-
communityUsers: [],
|
|
40063
|
-
files: [],
|
|
40064
|
-
users: [],
|
|
40065
|
-
});
|
|
40066
|
-
}
|
|
40067
|
-
else {
|
|
40068
|
-
const post = (_a = pullFromCache(['post', 'get', comment.data.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
40069
|
-
if (post) {
|
|
40070
|
-
let removeCount;
|
|
40071
|
-
if (!deleted.parentId) {
|
|
40072
|
-
// NOTE: delete the parent comment will remove all children comments
|
|
40073
|
-
removeCount = deleted.childrenNumber + 1;
|
|
40074
|
-
}
|
|
40075
|
-
else
|
|
40076
|
-
removeCount = 1;
|
|
40077
|
-
post.commentsCount -= removeCount;
|
|
40078
|
-
fireEvent('local.post.updated', {
|
|
40079
|
-
posts: [post],
|
|
40080
|
-
categories: [],
|
|
40081
|
-
comments: [],
|
|
40082
|
-
communities: [],
|
|
40083
|
-
communityUsers: [],
|
|
40084
|
-
feeds: [],
|
|
40085
|
-
files: [],
|
|
40086
|
-
postChildren: [],
|
|
40087
|
-
users: [],
|
|
40088
|
-
videoStreamings: [],
|
|
40089
|
-
});
|
|
39973
|
+
const filter = ({ comment }) => {
|
|
39974
|
+
if (!client.cache) {
|
|
39975
|
+
callback(comment);
|
|
40090
39976
|
}
|
|
40091
|
-
|
|
40092
|
-
|
|
40093
|
-
|
|
40094
|
-
|
|
40095
|
-
|
|
40096
|
-
|
|
40097
|
-
communityUsers: [],
|
|
40098
|
-
});
|
|
40099
|
-
if (permanent) {
|
|
40100
|
-
scheduleTask(() => pushToTombstone('comment', commentId));
|
|
40101
|
-
}
|
|
40102
|
-
else {
|
|
40103
|
-
upsertInCache(['comment', 'get', commentId], { isDeleted: true });
|
|
40104
|
-
}
|
|
40105
|
-
return deleted;
|
|
39977
|
+
else {
|
|
39978
|
+
upsertInCache(['comment', 'get', comment.commentId], comment);
|
|
39979
|
+
callback(commentLinkedObject(comment));
|
|
39980
|
+
}
|
|
39981
|
+
};
|
|
39982
|
+
return createEventSubscriber(client, 'local.comment.removeReaction', 'local.comment.removeReaction', filter);
|
|
40106
39983
|
};
|
|
40107
|
-
/* end_public_function */
|
|
40108
39984
|
|
|
40109
39985
|
/* begin_public_function
|
|
40110
|
-
id: comment.
|
|
39986
|
+
id: comment.get
|
|
40111
39987
|
*/
|
|
40112
39988
|
/**
|
|
40113
39989
|
* ```js
|
|
40114
|
-
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
40115
|
-
* const success = await CommentRepository.softDeleteComment('foobar')
|
|
40116
|
-
* ```
|
|
40117
|
-
*
|
|
40118
|
-
* Deletes a {@link Amity.Comment}
|
|
39990
|
+
* import { CommentRepository } from '@amityco/ts-sdk';
|
|
40119
39991
|
*
|
|
40120
|
-
*
|
|
40121
|
-
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
39992
|
+
* let comment;
|
|
40122
39993
|
*
|
|
40123
|
-
*
|
|
40124
|
-
*
|
|
40125
|
-
|
|
40126
|
-
const softDeleteComment = async (commentId) => {
|
|
40127
|
-
const client = getActiveClient();
|
|
40128
|
-
client.log('comment/softDeleteComment', commentId);
|
|
40129
|
-
const softDeleted = deleteComment(commentId);
|
|
40130
|
-
return softDeleted;
|
|
40131
|
-
};
|
|
40132
|
-
/* end_public_function */
|
|
40133
|
-
|
|
40134
|
-
/* begin_public_function
|
|
40135
|
-
id: comment.hard_delete
|
|
40136
|
-
*/
|
|
40137
|
-
/**
|
|
40138
|
-
* ```js
|
|
40139
|
-
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
40140
|
-
* const success = await CommentRepository.hardDeleteComment('foobar')
|
|
39994
|
+
* const unsub = CommentRepository.getComment(commentId, response => {
|
|
39995
|
+
* comment = response.data;
|
|
39996
|
+
* });
|
|
40141
39997
|
* ```
|
|
40142
39998
|
*
|
|
40143
|
-
*
|
|
39999
|
+
* Observe all mutation on a given {@link Amity.Comment}
|
|
40144
40000
|
*
|
|
40145
|
-
* @param commentId
|
|
40146
|
-
* @
|
|
40001
|
+
* @param commentId the ID of the comment to observe
|
|
40002
|
+
* @param callback the function to call when new data are available
|
|
40003
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
|
|
40147
40004
|
*
|
|
40148
|
-
* @category Comment
|
|
40149
|
-
* @async
|
|
40005
|
+
* @category Comment Live Object
|
|
40150
40006
|
*/
|
|
40151
|
-
const
|
|
40152
|
-
|
|
40153
|
-
|
|
40154
|
-
|
|
40155
|
-
|
|
40007
|
+
const getComment = (commentId, callback) => {
|
|
40008
|
+
return liveObject(commentId, callback, 'commentId', getComment$1, [
|
|
40009
|
+
onCommentDeleteLocal,
|
|
40010
|
+
onCommentDeleted,
|
|
40011
|
+
onCommentFlagged,
|
|
40012
|
+
onCommentReactionAdded,
|
|
40013
|
+
onCommentReactionRemoved,
|
|
40014
|
+
onCommentUnflagged,
|
|
40015
|
+
onCommentUpdated,
|
|
40016
|
+
onLocalCommentReactionAdded,
|
|
40017
|
+
onLocalCommentReactionRemoved,
|
|
40018
|
+
]);
|
|
40156
40019
|
};
|
|
40157
40020
|
/* end_public_function */
|
|
40158
40021
|
|
|
40159
|
-
|
|
40160
|
-
|
|
40161
|
-
|
|
40162
|
-
|
|
40163
|
-
|
|
40164
|
-
|
|
40165
|
-
|
|
40166
|
-
|
|
40167
|
-
|
|
40168
|
-
|
|
40169
|
-
|
|
40170
|
-
* @returns the created report result
|
|
40171
|
-
*
|
|
40172
|
-
* @category Comment API
|
|
40173
|
-
* @async
|
|
40174
|
-
* */
|
|
40175
|
-
const flagComment = async (commentId, reason) => {
|
|
40176
|
-
const client = getActiveClient();
|
|
40177
|
-
client.log('comment/flagComment', commentId);
|
|
40178
|
-
const isPredefinedReason = reason &&
|
|
40179
|
-
Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
|
|
40180
|
-
const body = {
|
|
40181
|
-
reason: reason && isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
|
|
40182
|
-
detail: reason && !isPredefinedReason ? reason : '',
|
|
40183
|
-
};
|
|
40184
|
-
const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
|
|
40185
|
-
if (client.cache) {
|
|
40186
|
-
ingestInCache(payload);
|
|
40022
|
+
class CommentPaginationController extends PaginationController {
|
|
40023
|
+
async getRequest(queryParams, token) {
|
|
40024
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
|
|
40025
|
+
const baseOptions = {
|
|
40026
|
+
type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
|
|
40027
|
+
};
|
|
40028
|
+
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
40029
|
+
const { data: queryResponse } = await this.http.get(`/api/v3/comments`, {
|
|
40030
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
|
|
40031
|
+
});
|
|
40032
|
+
return queryResponse;
|
|
40187
40033
|
}
|
|
40188
|
-
|
|
40189
|
-
|
|
40190
|
-
|
|
40191
|
-
|
|
40034
|
+
}
|
|
40035
|
+
|
|
40036
|
+
var EnumCommentActions;
|
|
40037
|
+
(function (EnumCommentActions) {
|
|
40038
|
+
EnumCommentActions["OnCommentCreated"] = "onCommentCreated";
|
|
40039
|
+
EnumCommentActions["OnCommentUpdated"] = "onCommentUpdated";
|
|
40040
|
+
EnumCommentActions["OnCommentDeleted"] = "onCommentDeleted";
|
|
40041
|
+
EnumCommentActions["OnCommentFlagged"] = "onCommentFlagged";
|
|
40042
|
+
EnumCommentActions["OnCommentUnflagged"] = "onCommentUnflagged";
|
|
40043
|
+
EnumCommentActions["OnCommentReactionAdded"] = "onCommentReactionAdded";
|
|
40044
|
+
EnumCommentActions["OnCommentReactionRemoved"] = "onCommentReactionRemoved";
|
|
40045
|
+
})(EnumCommentActions || (EnumCommentActions = {}));
|
|
40046
|
+
|
|
40047
|
+
class CommentQueryStreamController extends QueryStreamController {
|
|
40048
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
40049
|
+
super(query, cacheKey);
|
|
40050
|
+
this.notifyChange = notifyChange;
|
|
40051
|
+
this.preparePayload = preparePayload;
|
|
40052
|
+
}
|
|
40053
|
+
async saveToMainDB(response) {
|
|
40054
|
+
const processedPayload = await this.preparePayload(response);
|
|
40055
|
+
const client = getActiveClient();
|
|
40056
|
+
const cachedAt = client.cache && Date.now();
|
|
40057
|
+
if (client.cache) {
|
|
40058
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
40059
|
+
}
|
|
40060
|
+
}
|
|
40061
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
40062
|
+
var _a, _b;
|
|
40063
|
+
if (refresh) {
|
|
40064
|
+
pushToCache(this.cacheKey, {
|
|
40065
|
+
data: response.comments.map(getResolver('comment')),
|
|
40066
|
+
});
|
|
40067
|
+
}
|
|
40068
|
+
else {
|
|
40069
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40070
|
+
const comments = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
40071
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...comments, ...response.comments.map(getResolver('comment'))])] }));
|
|
40072
|
+
}
|
|
40073
|
+
}
|
|
40074
|
+
reactor(action) {
|
|
40075
|
+
return (comment) => {
|
|
40076
|
+
var _a;
|
|
40077
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40078
|
+
if (this.query.referenceId !== comment.referenceId ||
|
|
40079
|
+
this.query.referenceType !== comment.referenceType ||
|
|
40080
|
+
!collection) {
|
|
40081
|
+
return;
|
|
40082
|
+
}
|
|
40083
|
+
if (this.query.parentId && this.query.parentId !== comment.parentId) {
|
|
40084
|
+
return;
|
|
40085
|
+
}
|
|
40086
|
+
if (!this.query.parentId && comment.parentId) {
|
|
40087
|
+
return;
|
|
40088
|
+
}
|
|
40089
|
+
if (action === EnumCommentActions.OnCommentCreated) {
|
|
40090
|
+
collection.data = [...new Set([comment.commentId, ...collection.data])];
|
|
40091
|
+
}
|
|
40092
|
+
pushToCache(this.cacheKey, collection);
|
|
40093
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
40094
|
+
};
|
|
40095
|
+
}
|
|
40096
|
+
subscribeRTE(createSubscriber) {
|
|
40097
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
40098
|
+
}
|
|
40099
|
+
}
|
|
40192
40100
|
|
|
40193
|
-
/* begin_public_function
|
|
40194
|
-
id: comment.unflag
|
|
40195
|
-
*/
|
|
40196
40101
|
/**
|
|
40197
40102
|
* ```js
|
|
40198
|
-
* import {
|
|
40199
|
-
* const
|
|
40103
|
+
* import { onCommentCreated } from '@amityco/ts-sdk'
|
|
40104
|
+
* const dispose = onCommentCreated(comment => {
|
|
40105
|
+
* // ...
|
|
40106
|
+
* })
|
|
40200
40107
|
* ```
|
|
40201
40108
|
*
|
|
40202
|
-
*
|
|
40203
|
-
* @returns the unflagged result
|
|
40109
|
+
* Fired when a {@link Amity.InternalComment} has been created
|
|
40204
40110
|
*
|
|
40205
|
-
* @
|
|
40206
|
-
* @
|
|
40207
|
-
*
|
|
40208
|
-
|
|
40209
|
-
|
|
40210
|
-
|
|
40211
|
-
|
|
40212
|
-
if (client.cache) {
|
|
40213
|
-
ingestInCache(payload);
|
|
40214
|
-
}
|
|
40215
|
-
fireEvent('comment.unflagged', payload);
|
|
40216
|
-
return !!payload;
|
|
40111
|
+
* @param callback The function to call when the event was fired
|
|
40112
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
40113
|
+
*
|
|
40114
|
+
* @category Comment Events
|
|
40115
|
+
*/
|
|
40116
|
+
const onCommentCreatedLocal = (callback) => {
|
|
40117
|
+
return createLocalCommentEventSubscriber('local.comment.created', callback);
|
|
40217
40118
|
};
|
|
40218
|
-
|
|
40119
|
+
|
|
40120
|
+
class CommentLiveCollectionController extends LiveCollectionController {
|
|
40121
|
+
constructor(query, callback) {
|
|
40122
|
+
const queryStreamId = hash(query);
|
|
40123
|
+
const cacheKey = ['comments', 'collection', queryStreamId];
|
|
40124
|
+
const paginationController = new CommentPaginationController(query);
|
|
40125
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
40126
|
+
this.query = query;
|
|
40127
|
+
this.queryStreamController = new CommentQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareCommentPayload);
|
|
40128
|
+
this.callback = callback.bind(this);
|
|
40129
|
+
this.loadPage({ initial: true });
|
|
40130
|
+
}
|
|
40131
|
+
setup() {
|
|
40132
|
+
var _a;
|
|
40133
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40134
|
+
if (!collection) {
|
|
40135
|
+
pushToCache(this.cacheKey, {
|
|
40136
|
+
data: [],
|
|
40137
|
+
params: {},
|
|
40138
|
+
});
|
|
40139
|
+
}
|
|
40140
|
+
}
|
|
40141
|
+
async persistModel(queryPayload) {
|
|
40142
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
40143
|
+
}
|
|
40144
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
40145
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
40146
|
+
}
|
|
40147
|
+
startSubscription() {
|
|
40148
|
+
return this.queryStreamController.subscribeRTE([
|
|
40149
|
+
{ fn: onCommentCreatedLocal, action: EnumCommentActions.OnCommentCreated },
|
|
40150
|
+
{ fn: onCommentDeleteLocal, action: EnumCommentActions.OnCommentDeleted },
|
|
40151
|
+
{ fn: onCommentCreated, action: EnumCommentActions.OnCommentCreated },
|
|
40152
|
+
{ fn: onCommentUpdated, action: EnumCommentActions.OnCommentUpdated },
|
|
40153
|
+
{ fn: onCommentDeleted, action: EnumCommentActions.OnCommentDeleted },
|
|
40154
|
+
{ fn: onCommentFlagged, action: EnumCommentActions.OnCommentFlagged },
|
|
40155
|
+
{ fn: onCommentUnflagged, action: EnumCommentActions.OnCommentUnflagged },
|
|
40156
|
+
{ fn: onCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
40157
|
+
{ fn: onCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
40158
|
+
{ fn: onLocalCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
40159
|
+
{ fn: onLocalCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
40160
|
+
]);
|
|
40161
|
+
}
|
|
40162
|
+
notifyChange({ origin, loading, error }) {
|
|
40163
|
+
var _a, _b;
|
|
40164
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40165
|
+
if (!collection)
|
|
40166
|
+
return;
|
|
40167
|
+
const data = this.applyFilter((_b = collection.data
|
|
40168
|
+
.map(id => pullFromCache(['comment', 'get', id]))
|
|
40169
|
+
.filter(isNonNullable)
|
|
40170
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.comment);
|
|
40171
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
40172
|
+
return;
|
|
40173
|
+
this.callback({
|
|
40174
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
40175
|
+
data,
|
|
40176
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
40177
|
+
loading,
|
|
40178
|
+
error,
|
|
40179
|
+
});
|
|
40180
|
+
}
|
|
40181
|
+
applyFilter(data) {
|
|
40182
|
+
let comments = data;
|
|
40183
|
+
if (!this.query.includeDeleted) {
|
|
40184
|
+
comments = filterByPropEquality(comments, 'isDeleted', false);
|
|
40185
|
+
}
|
|
40186
|
+
if (this.query.parentId) {
|
|
40187
|
+
comments = comments.filter(comment => comment.parentId === this.query.parentId);
|
|
40188
|
+
}
|
|
40189
|
+
if (typeof this.query.hasFlag === 'boolean') {
|
|
40190
|
+
if (this.query.hasFlag) {
|
|
40191
|
+
comments = comments.filter(comment => comment.hashFlag != null);
|
|
40192
|
+
}
|
|
40193
|
+
else {
|
|
40194
|
+
comments = comments.filter(comment => comment.hashFlag == null);
|
|
40195
|
+
}
|
|
40196
|
+
}
|
|
40197
|
+
if (this.query.dataTypes) {
|
|
40198
|
+
if (this.query.dataTypes.matchType === 'exact') {
|
|
40199
|
+
comments = comments.filter(comment => {
|
|
40200
|
+
var _a, _b;
|
|
40201
|
+
const sortedDataTypesQueryValue = ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.sort()) || [];
|
|
40202
|
+
const sortedDataTypesCommentValue = ((_b = comment.dataTypes) === null || _b === void 0 ? void 0 : _b.sort()) || [];
|
|
40203
|
+
if (sortedDataTypesCommentValue.length !== sortedDataTypesQueryValue.length) {
|
|
40204
|
+
return false;
|
|
40205
|
+
}
|
|
40206
|
+
return sortedDataTypesQueryValue.every((value, index) => value === sortedDataTypesCommentValue[index]);
|
|
40207
|
+
});
|
|
40208
|
+
}
|
|
40209
|
+
if (this.query.dataTypes.matchType === 'any') {
|
|
40210
|
+
comments = comments.filter(comment => { var _a; return (_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.some(value => { var _a; return (_a = comment.dataTypes) === null || _a === void 0 ? void 0 : _a.includes(value); }); });
|
|
40211
|
+
}
|
|
40212
|
+
}
|
|
40213
|
+
switch (this.query.sortBy) {
|
|
40214
|
+
case 'firstCreated':
|
|
40215
|
+
comments = comments.sort(sortByFirstCreated);
|
|
40216
|
+
break;
|
|
40217
|
+
case 'lastCreated':
|
|
40218
|
+
default:
|
|
40219
|
+
comments = comments.sort(sortByLastCreated);
|
|
40220
|
+
break;
|
|
40221
|
+
}
|
|
40222
|
+
return comments;
|
|
40223
|
+
}
|
|
40224
|
+
}
|
|
40219
40225
|
|
|
40220
40226
|
/* begin_public_function
|
|
40221
|
-
id: comment.
|
|
40227
|
+
id: comment.query
|
|
40222
40228
|
*/
|
|
40223
40229
|
/**
|
|
40224
40230
|
* ```js
|
|
40225
|
-
* import {
|
|
40226
|
-
*
|
|
40231
|
+
* import { getComments } from '@amityco/ts-sdk'
|
|
40232
|
+
*
|
|
40233
|
+
* let comments = []
|
|
40234
|
+
* const unsub = getComments({
|
|
40235
|
+
* referenceType: Amity.InternalComment['referenceType'];
|
|
40236
|
+
* referenceId: Amity.InternalComment['referenceId'];
|
|
40237
|
+
* }, response => merge(comments, response.data))
|
|
40227
40238
|
* ```
|
|
40228
40239
|
*
|
|
40229
|
-
*
|
|
40230
|
-
* @returns `true` if the comment is flagged by me, `false` if doesn't.
|
|
40240
|
+
* Observe all mutations on a list of {@link Amity.InternalComment} for a given target object
|
|
40231
40241
|
*
|
|
40232
|
-
* @
|
|
40233
|
-
* @
|
|
40234
|
-
*
|
|
40235
|
-
|
|
40236
|
-
|
|
40237
|
-
|
|
40238
|
-
|
|
40239
|
-
|
|
40242
|
+
* @param referenceType the type of the target
|
|
40243
|
+
* @param referenceId the ID of the target
|
|
40244
|
+
* @param callback the function to call when new data are available
|
|
40245
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
40246
|
+
*
|
|
40247
|
+
* @category Comments Live Collection
|
|
40248
|
+
*/
|
|
40249
|
+
const getComments = (params, callback, config) => {
|
|
40250
|
+
const { log, cache } = getActiveClient();
|
|
40251
|
+
if (!cache) {
|
|
40252
|
+
console.log('For using Live Collection feature you need to enable Cache!');
|
|
40253
|
+
}
|
|
40254
|
+
const timestamp = Date.now();
|
|
40255
|
+
log(`getComments(tmpid: ${timestamp}) > listen`);
|
|
40256
|
+
const commentsLiveCollection = new CommentLiveCollectionController(params, callback);
|
|
40257
|
+
const disposers = commentsLiveCollection.startSubscription();
|
|
40258
|
+
const cacheKey = commentsLiveCollection.getCacheKey();
|
|
40259
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
40260
|
+
return () => {
|
|
40261
|
+
log(`getComments(tmpid: ${timestamp}) > dispose`);
|
|
40262
|
+
disposers.forEach(fn => fn());
|
|
40263
|
+
};
|
|
40240
40264
|
};
|
|
40241
40265
|
/* end_public_function */
|
|
40242
40266
|
|
|
40243
|
-
|
|
40267
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
40268
|
+
__proto__: null,
|
|
40269
|
+
getCommentByIds: getCommentByIds,
|
|
40270
|
+
createComment: createComment,
|
|
40271
|
+
updateComment: updateComment,
|
|
40272
|
+
deleteComment: deleteComment,
|
|
40273
|
+
softDeleteComment: softDeleteComment,
|
|
40274
|
+
hardDeleteComment: hardDeleteComment,
|
|
40275
|
+
flagComment: flagComment,
|
|
40276
|
+
unflagComment: unflagComment,
|
|
40277
|
+
isCommentFlaggedByMe: isCommentFlaggedByMe,
|
|
40278
|
+
onCommentCreated: onCommentCreated,
|
|
40279
|
+
onCommentUpdated: onCommentUpdated,
|
|
40280
|
+
onCommentDeleted: onCommentDeleted,
|
|
40281
|
+
onCommentFlagged: onCommentFlagged,
|
|
40282
|
+
onCommentUnflagged: onCommentUnflagged,
|
|
40283
|
+
onCommentReactionAdded: onCommentReactionAdded,
|
|
40284
|
+
onCommentReactionRemoved: onCommentReactionRemoved,
|
|
40285
|
+
getComment: getComment,
|
|
40286
|
+
getComments: getComments
|
|
40287
|
+
});
|
|
40288
|
+
|
|
40289
|
+
const getPost$1 = async (postId) => {
|
|
40244
40290
|
const client = getActiveClient();
|
|
40245
|
-
client.log('
|
|
40246
|
-
isInTombstone('
|
|
40247
|
-
let
|
|
40291
|
+
client.log('post/getPost', postId);
|
|
40292
|
+
isInTombstone('post', postId);
|
|
40293
|
+
let payload;
|
|
40248
40294
|
try {
|
|
40249
40295
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
40250
|
-
const response = await client.http.get(`/api/v3/
|
|
40251
|
-
|
|
40296
|
+
const response = await client.http.get(`/api/v3/posts/${encodeURIComponent(postId)}`);
|
|
40297
|
+
payload = response.data;
|
|
40252
40298
|
}
|
|
40253
40299
|
catch (error) {
|
|
40254
40300
|
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
40255
|
-
pushToTombstone('
|
|
40301
|
+
pushToTombstone('post', postId);
|
|
40256
40302
|
}
|
|
40257
40303
|
throw error;
|
|
40258
40304
|
}
|
|
40305
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
40259
40306
|
const cachedAt = client.cache && Date.now();
|
|
40260
40307
|
if (client.cache)
|
|
40261
40308
|
ingestInCache(data, { cachedAt });
|
|
40262
|
-
const {
|
|
40309
|
+
const { posts } = data;
|
|
40310
|
+
const result = posts.find(post => post.postId === postId);
|
|
40263
40311
|
return {
|
|
40264
|
-
data:
|
|
40312
|
+
data: result,
|
|
40265
40313
|
cachedAt,
|
|
40266
40314
|
};
|
|
40267
40315
|
};
|
|
40268
|
-
|
|
40316
|
+
getPost$1.locally = (postId) => {
|
|
40269
40317
|
const client = getActiveClient();
|
|
40270
|
-
client.log('
|
|
40318
|
+
client.log('post/getPost.locally', postId);
|
|
40271
40319
|
if (!client.cache)
|
|
40272
40320
|
return;
|
|
40273
|
-
const cached = pullFromCache(['
|
|
40321
|
+
const cached = pullFromCache(['post', 'get', postId]);
|
|
40274
40322
|
if (!cached)
|
|
40275
40323
|
return;
|
|
40276
40324
|
return {
|
|
@@ -40281,474 +40329,740 @@ getComment$1.locally = (commentId) => {
|
|
|
40281
40329
|
|
|
40282
40330
|
/**
|
|
40283
40331
|
* ```js
|
|
40284
|
-
* import {
|
|
40285
|
-
* const dispose =
|
|
40332
|
+
* import { onPostUpdatedLocal } from '@amityco/ts-sdk'
|
|
40333
|
+
* const dispose = onPostUpdatedLocal(post => {
|
|
40286
40334
|
* // ...
|
|
40287
40335
|
* })
|
|
40288
40336
|
* ```
|
|
40289
40337
|
*
|
|
40290
|
-
* Fired when a {@link Amity.
|
|
40338
|
+
* Fired when a {@link Amity.InternalPost} has been updated
|
|
40291
40339
|
*
|
|
40292
40340
|
* @param callback The function to call when the event was fired
|
|
40293
40341
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
40294
40342
|
*
|
|
40295
|
-
* @category
|
|
40343
|
+
* @category Post Events
|
|
40296
40344
|
*/
|
|
40297
|
-
const
|
|
40345
|
+
const onPostUpdatedLocal = (callback) => createLocalPostEventSubscriber('local.post.updated', callback);
|
|
40298
40346
|
|
|
40299
40347
|
/**
|
|
40300
40348
|
* ```js
|
|
40301
|
-
* import {
|
|
40302
|
-
* const dispose =
|
|
40349
|
+
* import { onLocalPostReactionAdded } from '@amityco/ts-sdk'
|
|
40350
|
+
* const dispose = onPostReactionAdded(post => {
|
|
40303
40351
|
* // ...
|
|
40304
40352
|
* })
|
|
40305
40353
|
* ```
|
|
40306
40354
|
*
|
|
40307
|
-
* Fired when a {@link Amity.
|
|
40355
|
+
* Fired when a {@link Amity.InternalPost} has been reacted
|
|
40308
40356
|
*
|
|
40309
40357
|
* @param callback The function to call when the event was fired
|
|
40310
40358
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
40311
40359
|
*
|
|
40312
|
-
* @category
|
|
40360
|
+
* @category Post Events
|
|
40313
40361
|
*/
|
|
40314
|
-
const
|
|
40362
|
+
const onLocalPostReactionAdded = (callback) => {
|
|
40315
40363
|
const client = getActiveClient();
|
|
40316
|
-
const filter = ({
|
|
40364
|
+
const filter = ({ post }) => {
|
|
40317
40365
|
if (!client.cache) {
|
|
40318
|
-
callback(
|
|
40366
|
+
callback(post);
|
|
40319
40367
|
}
|
|
40320
40368
|
else {
|
|
40321
|
-
upsertInCache(['
|
|
40322
|
-
callback(
|
|
40369
|
+
upsertInCache(['post', 'get', post.postId], post);
|
|
40370
|
+
callback(post);
|
|
40323
40371
|
}
|
|
40324
40372
|
};
|
|
40325
|
-
return createEventSubscriber(client, 'local.
|
|
40373
|
+
return createEventSubscriber(client, 'local.post.addReaction', 'local.post.addReaction', filter);
|
|
40326
40374
|
};
|
|
40327
40375
|
|
|
40328
40376
|
/**
|
|
40329
40377
|
* ```js
|
|
40330
|
-
* import {
|
|
40331
|
-
* const dispose =
|
|
40378
|
+
* import { onLocalPostReactionRemoved } from '@amityco/ts-sdk'
|
|
40379
|
+
* const dispose = onPostReactionRemoved(post => {
|
|
40332
40380
|
* // ...
|
|
40333
40381
|
* })
|
|
40334
40382
|
* ```
|
|
40335
40383
|
*
|
|
40336
|
-
* Fired when a {@link Amity.
|
|
40384
|
+
* Fired when a {@link Amity.InternalPost} has been reacted
|
|
40337
40385
|
*
|
|
40338
40386
|
* @param callback The function to call when the event was fired
|
|
40339
40387
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
40340
40388
|
*
|
|
40341
|
-
* @category
|
|
40389
|
+
* @category Post Events
|
|
40342
40390
|
*/
|
|
40343
|
-
const
|
|
40391
|
+
const onLocalPostReactionRemoved = (callback) => {
|
|
40344
40392
|
const client = getActiveClient();
|
|
40345
|
-
const filter = ({
|
|
40393
|
+
const filter = ({ post }) => {
|
|
40346
40394
|
if (!client.cache) {
|
|
40347
|
-
callback(
|
|
40395
|
+
callback(post);
|
|
40348
40396
|
}
|
|
40349
40397
|
else {
|
|
40350
|
-
upsertInCache(['
|
|
40351
|
-
callback(
|
|
40398
|
+
upsertInCache(['post', 'get', post.postId], post);
|
|
40399
|
+
callback(post);
|
|
40352
40400
|
}
|
|
40353
40401
|
};
|
|
40354
|
-
return createEventSubscriber(client, 'local.
|
|
40402
|
+
return createEventSubscriber(client, 'local.post.removeReaction', 'local.post.removeReaction', filter);
|
|
40355
40403
|
};
|
|
40356
40404
|
|
|
40405
|
+
/**
|
|
40406
|
+
* ```js
|
|
40407
|
+
* import { onLocalPostDeleted } from '@amityco/ts-sdk'
|
|
40408
|
+
* const dispose = onLocalPostDeleted(post => {
|
|
40409
|
+
* // ...
|
|
40410
|
+
* })
|
|
40411
|
+
* ```
|
|
40412
|
+
*
|
|
40413
|
+
* Fired when a {@link Amity.InternalPost} has been deleted
|
|
40414
|
+
*
|
|
40415
|
+
* @param callback The function to call when the event was fired
|
|
40416
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
40417
|
+
*
|
|
40418
|
+
* @category Post Events
|
|
40419
|
+
*/
|
|
40420
|
+
const onLocalPostDeleted = (callback) => createLocalPostEventSubscriber('local.post.deleted', callback);
|
|
40421
|
+
|
|
40422
|
+
class UserFeedLiveCollectionController extends LiveCollectionController {
|
|
40423
|
+
constructor(query, callback) {
|
|
40424
|
+
const queryStreamId = hash(query);
|
|
40425
|
+
const cacheKey = ['userFeed', 'collection', queryStreamId];
|
|
40426
|
+
const paginationController = new UserFeedPaginationController(query);
|
|
40427
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
40428
|
+
this.query = query;
|
|
40429
|
+
this.queryStreamController = new UserFeedQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
40430
|
+
this.callback = callback.bind(this);
|
|
40431
|
+
this.loadPage({ initial: true });
|
|
40432
|
+
}
|
|
40433
|
+
setup() {
|
|
40434
|
+
var _a;
|
|
40435
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40436
|
+
if (!collection) {
|
|
40437
|
+
pushToCache(this.cacheKey, {
|
|
40438
|
+
data: [],
|
|
40439
|
+
params: {},
|
|
40440
|
+
});
|
|
40441
|
+
}
|
|
40442
|
+
}
|
|
40443
|
+
async persistModel(queryPayload) {
|
|
40444
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
40445
|
+
}
|
|
40446
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
40447
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
40448
|
+
}
|
|
40449
|
+
startSubscription() {
|
|
40450
|
+
return this.queryStreamController.subscribeRTE([
|
|
40451
|
+
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
40452
|
+
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
40453
|
+
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
40454
|
+
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
40455
|
+
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
40456
|
+
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
40457
|
+
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
40458
|
+
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
40459
|
+
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
40460
|
+
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
40461
|
+
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
40462
|
+
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
40463
|
+
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
40464
|
+
{
|
|
40465
|
+
fn: convertEventPayload((callback) => {
|
|
40466
|
+
return onCommentCreated(async (comment) => {
|
|
40467
|
+
var _a;
|
|
40468
|
+
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40469
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
40470
|
+
return;
|
|
40471
|
+
await getPost$1(comment.referenceId);
|
|
40472
|
+
callback(comment);
|
|
40473
|
+
});
|
|
40474
|
+
}, 'referenceId', 'post'),
|
|
40475
|
+
action: EnumPostActions.OnPostUpdated,
|
|
40476
|
+
},
|
|
40477
|
+
{
|
|
40478
|
+
fn: convertEventPayload((callback) => {
|
|
40479
|
+
return onCommentDeleted(async (comment) => {
|
|
40480
|
+
var _a;
|
|
40481
|
+
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40482
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
40483
|
+
return;
|
|
40484
|
+
await getPost$1(comment.referenceId);
|
|
40485
|
+
callback(comment);
|
|
40486
|
+
});
|
|
40487
|
+
}, 'referenceId', 'post'),
|
|
40488
|
+
action: EnumPostActions.OnPostUpdated,
|
|
40489
|
+
},
|
|
40490
|
+
]);
|
|
40491
|
+
}
|
|
40492
|
+
notifyChange({ origin, loading, error }) {
|
|
40493
|
+
var _a, _b;
|
|
40494
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40495
|
+
if (!collection)
|
|
40496
|
+
return;
|
|
40497
|
+
const data = this.applyFilter((_b = collection.data
|
|
40498
|
+
.map(id => pullFromCache(['post', 'get', id]))
|
|
40499
|
+
.filter(isNonNullable)
|
|
40500
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
40501
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
40502
|
+
return;
|
|
40503
|
+
this.callback({
|
|
40504
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
40505
|
+
data,
|
|
40506
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
40507
|
+
loading,
|
|
40508
|
+
error,
|
|
40509
|
+
});
|
|
40510
|
+
}
|
|
40511
|
+
applyFilter(data) {
|
|
40512
|
+
var _a;
|
|
40513
|
+
let posts = data;
|
|
40514
|
+
if (!this.query.includeDeleted) {
|
|
40515
|
+
posts = filterByPropEquality(posts, 'isDeleted', false);
|
|
40516
|
+
}
|
|
40517
|
+
if ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.length) {
|
|
40518
|
+
posts = filterByPostDataTypes(posts, this.query.dataTypes);
|
|
40519
|
+
}
|
|
40520
|
+
switch (this.query.sortBy) {
|
|
40521
|
+
case 'firstCreated':
|
|
40522
|
+
posts = posts.sort(sortByFirstCreated);
|
|
40523
|
+
break;
|
|
40524
|
+
case 'lastCreated':
|
|
40525
|
+
default:
|
|
40526
|
+
posts = posts.sort(sortByLastCreated);
|
|
40527
|
+
break;
|
|
40528
|
+
}
|
|
40529
|
+
return posts;
|
|
40530
|
+
}
|
|
40531
|
+
}
|
|
40532
|
+
|
|
40357
40533
|
/* begin_public_function
|
|
40358
|
-
id:
|
|
40534
|
+
id: feed.query.user_feed
|
|
40359
40535
|
*/
|
|
40360
40536
|
/**
|
|
40361
40537
|
* ```js
|
|
40362
|
-
* import {
|
|
40363
|
-
*
|
|
40364
|
-
* let comment;
|
|
40538
|
+
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
40365
40539
|
*
|
|
40366
|
-
*
|
|
40367
|
-
*
|
|
40368
|
-
*
|
|
40540
|
+
* let posts = []
|
|
40541
|
+
* const unsubscribe = FeedRepository.getUserFeed({
|
|
40542
|
+
* userId: string,
|
|
40543
|
+
* feedSources: ['user', 'community'],
|
|
40544
|
+
* }, response => response => processResponse(response))
|
|
40369
40545
|
* ```
|
|
40370
40546
|
*
|
|
40371
|
-
* Observe all
|
|
40547
|
+
* Observe all mutations on a list of {@link Amity.Post} for a given user and feedSources
|
|
40372
40548
|
*
|
|
40373
|
-
* @param
|
|
40549
|
+
* @param params.userId the ID of the user
|
|
40550
|
+
* @param params.feedSources the sources of the feed
|
|
40374
40551
|
* @param callback the function to call when new data are available
|
|
40375
|
-
* @
|
|
40552
|
+
* @param config
|
|
40553
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
40376
40554
|
*
|
|
40377
|
-
* @category
|
|
40555
|
+
* @category Posts Live Collection
|
|
40378
40556
|
*/
|
|
40379
|
-
const
|
|
40380
|
-
|
|
40381
|
-
|
|
40382
|
-
|
|
40383
|
-
|
|
40384
|
-
|
|
40385
|
-
|
|
40386
|
-
|
|
40387
|
-
|
|
40388
|
-
|
|
40389
|
-
|
|
40390
|
-
|
|
40557
|
+
const getUserFeed = (params, callback, config) => {
|
|
40558
|
+
const { log, cache } = getActiveClient();
|
|
40559
|
+
if (!cache) {
|
|
40560
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
40561
|
+
}
|
|
40562
|
+
const timestamp = Date.now();
|
|
40563
|
+
log(`getUserFeed(tmpid: ${timestamp}) > listen`);
|
|
40564
|
+
const userFeedLiveCollection = new UserFeedLiveCollectionController(params, callback);
|
|
40565
|
+
const disposers = userFeedLiveCollection.startSubscription();
|
|
40566
|
+
const cacheKey = userFeedLiveCollection.getCacheKey();
|
|
40567
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
40568
|
+
return () => {
|
|
40569
|
+
log(`getUserFeed(tmpid: ${timestamp}) > dispose`);
|
|
40570
|
+
disposers.forEach(fn => fn());
|
|
40571
|
+
};
|
|
40391
40572
|
};
|
|
40392
40573
|
/* end_public_function */
|
|
40393
40574
|
|
|
40394
|
-
|
|
40395
|
-
|
|
40396
|
-
|
|
40397
|
-
|
|
40398
|
-
|
|
40399
|
-
|
|
40400
|
-
|
|
40401
|
-
|
|
40402
|
-
|
|
40575
|
+
var index$9 = /*#__PURE__*/Object.freeze({
|
|
40576
|
+
__proto__: null,
|
|
40577
|
+
queryGlobalFeed: queryGlobalFeed,
|
|
40578
|
+
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
|
|
40579
|
+
getUserFeed: getUserFeed
|
|
40580
|
+
});
|
|
40581
|
+
|
|
40582
|
+
/* begin_public_function
|
|
40583
|
+
id: post.get_by_ids
|
|
40584
|
+
*/
|
|
40585
|
+
/**
|
|
40586
|
+
* ```js
|
|
40587
|
+
* import { getPostByIds } from '@amityco/ts-sdk'
|
|
40588
|
+
* const { data: posts } = await getPostByIds(['foo', 'bar'])
|
|
40589
|
+
* ```
|
|
40590
|
+
*
|
|
40591
|
+
* Fetches a collection of {@link Amity.Post} objects
|
|
40592
|
+
*
|
|
40593
|
+
* @param postIds the IDs of the {@link Amity.Post} to fetch
|
|
40594
|
+
* @returns the associated collection of {@link Amity.Post} objects
|
|
40595
|
+
*
|
|
40596
|
+
* @category Post API
|
|
40597
|
+
* @async
|
|
40598
|
+
*/
|
|
40599
|
+
const getPostByIds = async (postIds) => {
|
|
40600
|
+
const client = getActiveClient();
|
|
40601
|
+
client.log('post/getPostByIds', postIds);
|
|
40602
|
+
const encodedPostIds = postIds.map(postId => encodeURIComponent(postId));
|
|
40603
|
+
let payload;
|
|
40604
|
+
try {
|
|
40605
|
+
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
40606
|
+
const response = await client.http.get(`/api/v3/posts/list`, {
|
|
40607
|
+
params: { postIds: encodedPostIds },
|
|
40403
40608
|
});
|
|
40404
|
-
|
|
40609
|
+
payload = response.data;
|
|
40405
40610
|
}
|
|
40406
|
-
|
|
40407
|
-
|
|
40408
|
-
|
|
40409
|
-
(
|
|
40410
|
-
|
|
40411
|
-
|
|
40412
|
-
|
|
40413
|
-
EnumCommentActions["OnCommentFlagged"] = "onCommentFlagged";
|
|
40414
|
-
EnumCommentActions["OnCommentUnflagged"] = "onCommentUnflagged";
|
|
40415
|
-
EnumCommentActions["OnCommentReactionAdded"] = "onCommentReactionAdded";
|
|
40416
|
-
EnumCommentActions["OnCommentReactionRemoved"] = "onCommentReactionRemoved";
|
|
40417
|
-
})(EnumCommentActions || (EnumCommentActions = {}));
|
|
40418
|
-
|
|
40419
|
-
class CommentQueryStreamController extends QueryStreamController {
|
|
40420
|
-
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
40421
|
-
super(query, cacheKey);
|
|
40422
|
-
this.notifyChange = notifyChange;
|
|
40423
|
-
this.preparePayload = preparePayload;
|
|
40611
|
+
catch (error) {
|
|
40612
|
+
postIds.forEach(postId => {
|
|
40613
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
40614
|
+
pushToTombstone('post', postId);
|
|
40615
|
+
}
|
|
40616
|
+
});
|
|
40617
|
+
throw error;
|
|
40424
40618
|
}
|
|
40425
|
-
|
|
40426
|
-
|
|
40427
|
-
|
|
40428
|
-
|
|
40429
|
-
|
|
40430
|
-
|
|
40431
|
-
|
|
40619
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
40620
|
+
const cachedAt = client.cache && Date.now();
|
|
40621
|
+
if (client.cache)
|
|
40622
|
+
ingestInCache(data, { cachedAt });
|
|
40623
|
+
return {
|
|
40624
|
+
data: data.posts.map(LinkedObject.post),
|
|
40625
|
+
cachedAt,
|
|
40626
|
+
};
|
|
40627
|
+
};
|
|
40628
|
+
/* end_public_function */
|
|
40629
|
+
/**
|
|
40630
|
+
* ```js
|
|
40631
|
+
* import { getPostByIds } from '@amityco/ts-sdk'
|
|
40632
|
+
* const { data: posts } = getPostByIds.locally(['foo', 'bar'])
|
|
40633
|
+
* ```
|
|
40634
|
+
*
|
|
40635
|
+
* Fetches a collection of {@link Amity.Post} objects from cache
|
|
40636
|
+
*
|
|
40637
|
+
* @param postIds the IDs of the {@link Amity.Post} to fetch
|
|
40638
|
+
* @returns the associated collection of {@link Amity.Post} objects
|
|
40639
|
+
*
|
|
40640
|
+
* @category Post API
|
|
40641
|
+
*/
|
|
40642
|
+
getPostByIds.locally = (postIds) => {
|
|
40643
|
+
var _a;
|
|
40644
|
+
const client = getActiveClient();
|
|
40645
|
+
client.log('post/getPostByIds.locally', postIds);
|
|
40646
|
+
if (!client.cache)
|
|
40647
|
+
return;
|
|
40648
|
+
const cached = postIds
|
|
40649
|
+
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
40650
|
+
.filter(Boolean);
|
|
40651
|
+
const posts = cached.map(({ data }) => data);
|
|
40652
|
+
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
40653
|
+
if ((cached === null || cached === void 0 ? void 0 : cached.length) < postIds.length)
|
|
40654
|
+
return;
|
|
40655
|
+
return {
|
|
40656
|
+
data: posts.map(LinkedObject.post),
|
|
40657
|
+
cachedAt: oldest.cachedAt,
|
|
40658
|
+
};
|
|
40659
|
+
};
|
|
40660
|
+
|
|
40661
|
+
/* begin_public_function
|
|
40662
|
+
id: post.create.text_post, post.create.image_post, post.create.file_post, post.create.video_post, post.create.poll_post, post.create.livestream_post, post.create.custom_post
|
|
40663
|
+
*/
|
|
40664
|
+
/**
|
|
40665
|
+
* ```js
|
|
40666
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
40667
|
+
* const created = await PostRepository.createPost({
|
|
40668
|
+
* targetType: 'user',
|
|
40669
|
+
* targetId: 'foobar',
|
|
40670
|
+
* data: { text: 'hello world' }
|
|
40671
|
+
* }))
|
|
40672
|
+
* ```
|
|
40673
|
+
*
|
|
40674
|
+
* Creates an {@link Amity.Post}
|
|
40675
|
+
*
|
|
40676
|
+
* @param bundle The data necessary to create a new {@link Amity.Post}
|
|
40677
|
+
* @returns The newly created {@link Amity.Post}
|
|
40678
|
+
*
|
|
40679
|
+
* @category Post API
|
|
40680
|
+
* @async
|
|
40681
|
+
*/
|
|
40682
|
+
const createPost = async (bundle) => {
|
|
40683
|
+
const client = getActiveClient();
|
|
40684
|
+
client.log('post/createPost', bundle);
|
|
40685
|
+
if (!bundle.dataType || ['text', 'image', 'file', 'video'].includes(bundle.dataType)) {
|
|
40686
|
+
// eslint-disable-next-line no-param-reassign
|
|
40687
|
+
delete bundle.dataType;
|
|
40432
40688
|
}
|
|
40433
|
-
|
|
40434
|
-
|
|
40435
|
-
|
|
40436
|
-
|
|
40437
|
-
|
|
40438
|
-
|
|
40439
|
-
|
|
40440
|
-
|
|
40441
|
-
|
|
40442
|
-
|
|
40443
|
-
|
|
40444
|
-
|
|
40689
|
+
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
40690
|
+
fireEvent('post.created', payload);
|
|
40691
|
+
const data = preparePostPayload(payload);
|
|
40692
|
+
const cachedAt = client.cache && Date.now();
|
|
40693
|
+
if (client.cache)
|
|
40694
|
+
ingestInCache(data, { cachedAt });
|
|
40695
|
+
const { posts } = data;
|
|
40696
|
+
return {
|
|
40697
|
+
data: LinkedObject.post(posts[0]),
|
|
40698
|
+
cachedAt,
|
|
40699
|
+
};
|
|
40700
|
+
};
|
|
40701
|
+
/* end_public_function */
|
|
40702
|
+
|
|
40703
|
+
/* begin_public_function
|
|
40704
|
+
id: post.edit, post.edit.custom_post
|
|
40705
|
+
*/
|
|
40706
|
+
/**
|
|
40707
|
+
* ```js
|
|
40708
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
40709
|
+
* const updated = await PostRepository.editPost(postId, {
|
|
40710
|
+
* data: { text: 'hello world' }
|
|
40711
|
+
* })
|
|
40712
|
+
* ```
|
|
40713
|
+
*
|
|
40714
|
+
* Updates an {@link Amity.Post}
|
|
40715
|
+
*
|
|
40716
|
+
* @param postId The ID of the {@link Amity.Post} to edit
|
|
40717
|
+
* @param patch The patch data to apply
|
|
40718
|
+
* @returns the updated {@link Amity.Post} object
|
|
40719
|
+
*
|
|
40720
|
+
* @category Post API
|
|
40721
|
+
* @async
|
|
40722
|
+
*/
|
|
40723
|
+
const editPost = async (postId, patch) => {
|
|
40724
|
+
const client = getActiveClient();
|
|
40725
|
+
client.log('user/editPost', patch);
|
|
40726
|
+
const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
|
|
40727
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
40728
|
+
const cachedAt = client.cache && Date.now();
|
|
40729
|
+
if (client.cache)
|
|
40730
|
+
ingestInCache(data, { cachedAt });
|
|
40731
|
+
fireEvent('local.post.updated', data);
|
|
40732
|
+
const { posts } = data;
|
|
40733
|
+
return {
|
|
40734
|
+
data: LinkedObject.post(posts.find(post => post.postId === postId)),
|
|
40735
|
+
cachedAt,
|
|
40736
|
+
};
|
|
40737
|
+
};
|
|
40738
|
+
/* end_public_function */
|
|
40739
|
+
|
|
40740
|
+
/**
|
|
40741
|
+
* ```js
|
|
40742
|
+
* import { deletePost } from '@amityco/ts-sdk'
|
|
40743
|
+
* const success = await deletePost('foobar')
|
|
40744
|
+
* ```
|
|
40745
|
+
*
|
|
40746
|
+
* Deletes a {@link Amity.Post}
|
|
40747
|
+
*
|
|
40748
|
+
* @param postId The {@link Amity.Post} ID to delete
|
|
40749
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
40750
|
+
*
|
|
40751
|
+
* @private
|
|
40752
|
+
* @async
|
|
40753
|
+
*/
|
|
40754
|
+
const deletePost = async (postId, permanent = false) => {
|
|
40755
|
+
var _a;
|
|
40756
|
+
const client = getActiveClient();
|
|
40757
|
+
const post = await getPost$2(postId);
|
|
40758
|
+
await client.http.delete(`/api/v4/posts/${encodeURIComponent(postId)}`, {
|
|
40759
|
+
params: {
|
|
40760
|
+
postId,
|
|
40761
|
+
permanent,
|
|
40762
|
+
},
|
|
40763
|
+
});
|
|
40764
|
+
// there is currently a limitation which doesn't allow us to fire event to tell that community
|
|
40765
|
+
// has been updated. reason is that, when the object is deleted, we don't have its `communityId`
|
|
40766
|
+
// and so we cannot refetch the community or advertise on events. hopefully this should be solved
|
|
40767
|
+
// later when realtime events covers that for us.
|
|
40768
|
+
if (post.data.targetType === 'community') {
|
|
40769
|
+
const community = await getCommunity$1(post.data.targetId);
|
|
40770
|
+
const communityUsersCache = (_a = queryCache(['communityUsers', 'get'])) !== null && _a !== void 0 ? _a : [];
|
|
40771
|
+
const communityUsers = communityUsersCache
|
|
40772
|
+
.filter(({ key }) => {
|
|
40773
|
+
// cache key is ['communityUsers', 'get', `${communityId}#`${userId}`}]
|
|
40774
|
+
if (key[0] !== 'communityUsers')
|
|
40775
|
+
return false;
|
|
40776
|
+
if (key[1] !== 'get')
|
|
40777
|
+
return false;
|
|
40778
|
+
if (typeof key[2] === 'string')
|
|
40779
|
+
return key[2].includes(community.data.communityId);
|
|
40780
|
+
return false;
|
|
40781
|
+
})
|
|
40782
|
+
.map(({ data }) => data);
|
|
40783
|
+
fireEvent('community.updated', {
|
|
40784
|
+
communities: [community.data],
|
|
40785
|
+
categories: [],
|
|
40786
|
+
communityUsers,
|
|
40787
|
+
feeds: [],
|
|
40788
|
+
files: [],
|
|
40789
|
+
users: [],
|
|
40790
|
+
});
|
|
40445
40791
|
}
|
|
40446
|
-
|
|
40447
|
-
|
|
40448
|
-
|
|
40449
|
-
|
|
40450
|
-
|
|
40451
|
-
|
|
40452
|
-
!collection) {
|
|
40453
|
-
return;
|
|
40454
|
-
}
|
|
40455
|
-
if (this.query.parentId && this.query.parentId !== comment.parentId) {
|
|
40456
|
-
return;
|
|
40457
|
-
}
|
|
40458
|
-
if (!this.query.parentId && comment.parentId) {
|
|
40459
|
-
return;
|
|
40460
|
-
}
|
|
40461
|
-
if (action === EnumCommentActions.OnCommentCreated) {
|
|
40462
|
-
collection.data = [...new Set([comment.commentId, ...collection.data])];
|
|
40463
|
-
}
|
|
40464
|
-
pushToCache(this.cacheKey, collection);
|
|
40465
|
-
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
40466
|
-
};
|
|
40792
|
+
// to support hard deletion
|
|
40793
|
+
const deleted = Object.assign(Object.assign({}, post.data), { isDeleted: true });
|
|
40794
|
+
if (permanent) {
|
|
40795
|
+
setTimeout(() => {
|
|
40796
|
+
pushToTombstone('post', postId);
|
|
40797
|
+
}, 0);
|
|
40467
40798
|
}
|
|
40468
|
-
|
|
40469
|
-
|
|
40799
|
+
else {
|
|
40800
|
+
upsertInCache(['post', 'get', postId], { isDeleted: true });
|
|
40470
40801
|
}
|
|
40471
|
-
|
|
40802
|
+
fireEvent('local.post.deleted', {
|
|
40803
|
+
posts: [deleted],
|
|
40804
|
+
categories: [],
|
|
40805
|
+
comments: [],
|
|
40806
|
+
communities: [],
|
|
40807
|
+
communityUsers: [],
|
|
40808
|
+
feeds: [],
|
|
40809
|
+
files: [],
|
|
40810
|
+
postChildren: [],
|
|
40811
|
+
users: [],
|
|
40812
|
+
videoStreamings: [],
|
|
40813
|
+
});
|
|
40814
|
+
return LinkedObject.post(deleted);
|
|
40815
|
+
};
|
|
40472
40816
|
|
|
40817
|
+
/* begin_public_function
|
|
40818
|
+
id: post.soft_delete
|
|
40819
|
+
*/
|
|
40473
40820
|
/**
|
|
40474
40821
|
* ```js
|
|
40475
|
-
* import {
|
|
40476
|
-
* const
|
|
40477
|
-
* // ...
|
|
40478
|
-
* })
|
|
40822
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
40823
|
+
* const success = await PostRepository.softDeletePost('foobar')
|
|
40479
40824
|
* ```
|
|
40480
40825
|
*
|
|
40481
|
-
*
|
|
40826
|
+
* Soft deletes a {@link Amity.Post}
|
|
40482
40827
|
*
|
|
40483
|
-
* @param
|
|
40484
|
-
* @
|
|
40828
|
+
* @param postId The {@link Amity.Post} ID to soft delete
|
|
40829
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
40485
40830
|
*
|
|
40486
|
-
* @category
|
|
40831
|
+
* @category Post API
|
|
40832
|
+
* @async
|
|
40487
40833
|
*/
|
|
40488
|
-
const
|
|
40489
|
-
|
|
40834
|
+
const softDeletePost = async (postId) => {
|
|
40835
|
+
const client = getActiveClient();
|
|
40836
|
+
client.log('post/softDeletePost', postId);
|
|
40837
|
+
const softDeleted = await deletePost(postId, false);
|
|
40838
|
+
return LinkedObject.post(softDeleted);
|
|
40490
40839
|
};
|
|
40840
|
+
/* end_public_function */
|
|
40491
40841
|
|
|
40492
|
-
|
|
40493
|
-
|
|
40494
|
-
|
|
40495
|
-
|
|
40496
|
-
|
|
40497
|
-
|
|
40498
|
-
|
|
40499
|
-
|
|
40500
|
-
|
|
40501
|
-
|
|
40502
|
-
|
|
40503
|
-
|
|
40504
|
-
|
|
40505
|
-
|
|
40506
|
-
|
|
40507
|
-
|
|
40508
|
-
|
|
40509
|
-
|
|
40510
|
-
|
|
40511
|
-
|
|
40512
|
-
|
|
40513
|
-
|
|
40514
|
-
|
|
40515
|
-
|
|
40516
|
-
persistQueryStream({ response, direction, refresh, }) {
|
|
40517
|
-
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
40518
|
-
}
|
|
40519
|
-
startSubscription() {
|
|
40520
|
-
return this.queryStreamController.subscribeRTE([
|
|
40521
|
-
{ fn: onCommentCreatedLocal, action: EnumCommentActions.OnCommentCreated },
|
|
40522
|
-
{ fn: onCommentDeleteLocal, action: EnumCommentActions.OnCommentDeleted },
|
|
40523
|
-
{ fn: onCommentCreated, action: EnumCommentActions.OnCommentCreated },
|
|
40524
|
-
{ fn: onCommentUpdated, action: EnumCommentActions.OnCommentUpdated },
|
|
40525
|
-
{ fn: onCommentDeleted, action: EnumCommentActions.OnCommentDeleted },
|
|
40526
|
-
{ fn: onCommentFlagged, action: EnumCommentActions.OnCommentFlagged },
|
|
40527
|
-
{ fn: onCommentUnflagged, action: EnumCommentActions.OnCommentUnflagged },
|
|
40528
|
-
{ fn: onCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
40529
|
-
{ fn: onCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
40530
|
-
{ fn: onLocalCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
40531
|
-
{ fn: onLocalCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
40532
|
-
]);
|
|
40533
|
-
}
|
|
40534
|
-
notifyChange({ origin, loading, error }) {
|
|
40535
|
-
var _a, _b;
|
|
40536
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40537
|
-
if (!collection)
|
|
40538
|
-
return;
|
|
40539
|
-
const data = this.applyFilter((_b = collection.data
|
|
40540
|
-
.map(id => pullFromCache(['comment', 'get', id]))
|
|
40541
|
-
.filter(isNonNullable)
|
|
40542
|
-
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.comment);
|
|
40543
|
-
if (!this.shouldNotify(data) && origin === 'event')
|
|
40544
|
-
return;
|
|
40545
|
-
this.callback({
|
|
40546
|
-
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
40547
|
-
data,
|
|
40548
|
-
hasNextPage: !!this.paginationController.getNextToken(),
|
|
40549
|
-
loading,
|
|
40550
|
-
error,
|
|
40551
|
-
});
|
|
40552
|
-
}
|
|
40553
|
-
applyFilter(data) {
|
|
40554
|
-
let comments = data;
|
|
40555
|
-
if (!this.query.includeDeleted) {
|
|
40556
|
-
comments = filterByPropEquality(comments, 'isDeleted', false);
|
|
40557
|
-
}
|
|
40558
|
-
if (this.query.parentId) {
|
|
40559
|
-
comments = comments.filter(comment => comment.parentId === this.query.parentId);
|
|
40560
|
-
}
|
|
40561
|
-
if (typeof this.query.hasFlag === 'boolean') {
|
|
40562
|
-
if (this.query.hasFlag) {
|
|
40563
|
-
comments = comments.filter(comment => comment.hashFlag != null);
|
|
40564
|
-
}
|
|
40565
|
-
else {
|
|
40566
|
-
comments = comments.filter(comment => comment.hashFlag == null);
|
|
40567
|
-
}
|
|
40568
|
-
}
|
|
40569
|
-
if (this.query.dataTypes) {
|
|
40570
|
-
if (this.query.dataTypes.matchType === 'exact') {
|
|
40571
|
-
comments = comments.filter(comment => {
|
|
40572
|
-
var _a, _b;
|
|
40573
|
-
const sortedDataTypesQueryValue = ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.sort()) || [];
|
|
40574
|
-
const sortedDataTypesCommentValue = ((_b = comment.dataTypes) === null || _b === void 0 ? void 0 : _b.sort()) || [];
|
|
40575
|
-
if (sortedDataTypesCommentValue.length !== sortedDataTypesQueryValue.length) {
|
|
40576
|
-
return false;
|
|
40577
|
-
}
|
|
40578
|
-
return sortedDataTypesQueryValue.every((value, index) => value === sortedDataTypesCommentValue[index]);
|
|
40579
|
-
});
|
|
40580
|
-
}
|
|
40581
|
-
if (this.query.dataTypes.matchType === 'any') {
|
|
40582
|
-
comments = comments.filter(comment => { var _a; return (_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.some(value => { var _a; return (_a = comment.dataTypes) === null || _a === void 0 ? void 0 : _a.includes(value); }); });
|
|
40583
|
-
}
|
|
40584
|
-
}
|
|
40585
|
-
switch (this.query.sortBy) {
|
|
40586
|
-
case 'firstCreated':
|
|
40587
|
-
comments = comments.sort(sortByFirstCreated);
|
|
40588
|
-
break;
|
|
40589
|
-
case 'lastCreated':
|
|
40590
|
-
default:
|
|
40591
|
-
comments = comments.sort(sortByLastCreated);
|
|
40592
|
-
break;
|
|
40593
|
-
}
|
|
40594
|
-
return comments;
|
|
40595
|
-
}
|
|
40596
|
-
}
|
|
40842
|
+
/* begin_public_function
|
|
40843
|
+
id: post.hard_delete
|
|
40844
|
+
*/
|
|
40845
|
+
/**
|
|
40846
|
+
* ```js
|
|
40847
|
+
* import { hardDeletePost } from '@amityco/ts-sdk'
|
|
40848
|
+
* const success = await hardDeletePost('foobar')
|
|
40849
|
+
* ```
|
|
40850
|
+
*
|
|
40851
|
+
* Hard deletes a {@link Amity.Post}
|
|
40852
|
+
*
|
|
40853
|
+
* @param postId The {@link Amity.Post} ID to be hard delete
|
|
40854
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
40855
|
+
*
|
|
40856
|
+
* @category Post API
|
|
40857
|
+
* @async
|
|
40858
|
+
*/
|
|
40859
|
+
const hardDeletePost = async (postId) => {
|
|
40860
|
+
const client = getActiveClient();
|
|
40861
|
+
client.log('post/hardDeletePost', postId);
|
|
40862
|
+
const hardDeleted = await deletePost(postId, true);
|
|
40863
|
+
return LinkedObject.post(hardDeleted);
|
|
40864
|
+
};
|
|
40865
|
+
/* end_public_function */
|
|
40597
40866
|
|
|
40598
40867
|
/* begin_public_function
|
|
40599
|
-
id:
|
|
40868
|
+
id: post.approve
|
|
40600
40869
|
*/
|
|
40601
40870
|
/**
|
|
40602
40871
|
* ```js
|
|
40603
|
-
* import {
|
|
40872
|
+
* import { approvePost } from '@amityco/ts-sdk'
|
|
40604
40873
|
*
|
|
40605
|
-
*
|
|
40606
|
-
* const unsub = getComments({
|
|
40607
|
-
* referenceType: Amity.InternalComment['referenceType'];
|
|
40608
|
-
* referenceId: Amity.InternalComment['referenceId'];
|
|
40609
|
-
* }, response => merge(comments, response.data))
|
|
40874
|
+
* const { data: post } = await approvePost('postId')
|
|
40610
40875
|
* ```
|
|
40611
40876
|
*
|
|
40612
|
-
*
|
|
40877
|
+
* Approves a {@link Amity.Post}
|
|
40613
40878
|
*
|
|
40614
|
-
* @param
|
|
40615
|
-
* @
|
|
40616
|
-
* @param callback the function to call when new data are available
|
|
40617
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
40879
|
+
* @param postId The {@link Amity.Post} ID to be approved
|
|
40880
|
+
* @return A {@link Amity.Post} that was approved
|
|
40618
40881
|
*
|
|
40619
|
-
* @category
|
|
40882
|
+
* @category Post API
|
|
40883
|
+
* @async
|
|
40620
40884
|
*/
|
|
40621
|
-
const
|
|
40622
|
-
const
|
|
40623
|
-
|
|
40624
|
-
|
|
40885
|
+
const approvePost = async (postId) => {
|
|
40886
|
+
const client = getActiveClient();
|
|
40887
|
+
client.log('post/approvePost', postId);
|
|
40888
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/approve`);
|
|
40889
|
+
fireEvent('post.approved', payload);
|
|
40890
|
+
// fire virtual event for community update
|
|
40891
|
+
if (payload.posts[0].targetType === 'community') {
|
|
40892
|
+
fireEvent('community.updated', payload);
|
|
40625
40893
|
}
|
|
40626
|
-
const
|
|
40627
|
-
|
|
40628
|
-
|
|
40629
|
-
|
|
40630
|
-
|
|
40631
|
-
|
|
40632
|
-
|
|
40633
|
-
log(`getComments(tmpid: ${timestamp}) > dispose`);
|
|
40634
|
-
disposers.forEach(fn => fn());
|
|
40894
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
40895
|
+
const cachedAt = client.cache && Date.now();
|
|
40896
|
+
if (client.cache)
|
|
40897
|
+
ingestInCache(data, { cachedAt });
|
|
40898
|
+
return {
|
|
40899
|
+
data: LinkedObject.post(data.posts.find(post => post.postId === postId)),
|
|
40900
|
+
cachedAt,
|
|
40635
40901
|
};
|
|
40636
40902
|
};
|
|
40637
40903
|
/* end_public_function */
|
|
40638
40904
|
|
|
40639
|
-
|
|
40640
|
-
|
|
40641
|
-
|
|
40642
|
-
createComment: createComment,
|
|
40643
|
-
updateComment: updateComment,
|
|
40644
|
-
deleteComment: deleteComment,
|
|
40645
|
-
softDeleteComment: softDeleteComment,
|
|
40646
|
-
hardDeleteComment: hardDeleteComment,
|
|
40647
|
-
flagComment: flagComment,
|
|
40648
|
-
unflagComment: unflagComment,
|
|
40649
|
-
isCommentFlaggedByMe: isCommentFlaggedByMe,
|
|
40650
|
-
onCommentCreated: onCommentCreated,
|
|
40651
|
-
onCommentUpdated: onCommentUpdated,
|
|
40652
|
-
onCommentDeleted: onCommentDeleted,
|
|
40653
|
-
onCommentFlagged: onCommentFlagged,
|
|
40654
|
-
onCommentUnflagged: onCommentUnflagged,
|
|
40655
|
-
onCommentReactionAdded: onCommentReactionAdded,
|
|
40656
|
-
onCommentReactionRemoved: onCommentReactionRemoved,
|
|
40657
|
-
getComment: getComment,
|
|
40658
|
-
getComments: getComments
|
|
40659
|
-
});
|
|
40660
|
-
|
|
40905
|
+
/* begin_public_function
|
|
40906
|
+
id: post.decline
|
|
40907
|
+
*/
|
|
40661
40908
|
/**
|
|
40662
40909
|
* ```js
|
|
40663
|
-
* import {
|
|
40664
|
-
*
|
|
40665
|
-
*
|
|
40666
|
-
* })
|
|
40910
|
+
* import { declinePost } from '@amityco/ts-sdk'
|
|
40911
|
+
*
|
|
40912
|
+
* const {data: post} = await declinePost('postId')
|
|
40667
40913
|
* ```
|
|
40668
40914
|
*
|
|
40669
|
-
*
|
|
40915
|
+
* Declines a {@link Amity.Post}
|
|
40670
40916
|
*
|
|
40671
|
-
* @param
|
|
40672
|
-
* @
|
|
40917
|
+
* @param postId The {@link Amity.Post} ID to be declined
|
|
40918
|
+
* @return A {@link Amity.Post} that was declined
|
|
40673
40919
|
*
|
|
40674
|
-
* @category Post
|
|
40920
|
+
* @category Post API
|
|
40921
|
+
* @async
|
|
40675
40922
|
*/
|
|
40676
|
-
const
|
|
40923
|
+
const declinePost = async (postId) => {
|
|
40924
|
+
const client = getActiveClient();
|
|
40925
|
+
client.log('post/declinePost', postId);
|
|
40926
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/decline`);
|
|
40927
|
+
// fire virtual event
|
|
40928
|
+
if (payload.posts[0].targetType === 'community') {
|
|
40929
|
+
fireEvent('community.updated', payload);
|
|
40930
|
+
}
|
|
40931
|
+
fireEvent('post.declined', payload);
|
|
40932
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
40933
|
+
const cachedAt = client.cache && Date.now();
|
|
40934
|
+
if (client.cache)
|
|
40935
|
+
ingestInCache(data, { cachedAt });
|
|
40936
|
+
return {
|
|
40937
|
+
data: LinkedObject.post(payload.posts.find(post => post.postId === postId)),
|
|
40938
|
+
cachedAt,
|
|
40939
|
+
};
|
|
40940
|
+
};
|
|
40941
|
+
/* end_public_function */
|
|
40677
40942
|
|
|
40943
|
+
/* begin_public_function
|
|
40944
|
+
id: post.flag
|
|
40945
|
+
*/
|
|
40678
40946
|
/**
|
|
40679
40947
|
* ```js
|
|
40680
|
-
* import {
|
|
40681
|
-
* const
|
|
40682
|
-
* // ...
|
|
40683
|
-
* })
|
|
40948
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
40949
|
+
* const flagged = await PostRepository.flagPost(postId, reason)
|
|
40684
40950
|
* ```
|
|
40685
40951
|
*
|
|
40686
|
-
*
|
|
40687
|
-
*
|
|
40688
|
-
* @
|
|
40689
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
40952
|
+
* @param postId of the post to flag
|
|
40953
|
+
* @param reason the reason to flag the post
|
|
40954
|
+
* @returns a boolean
|
|
40690
40955
|
*
|
|
40691
|
-
* @category Post
|
|
40692
|
-
|
|
40693
|
-
|
|
40956
|
+
* @category Post API
|
|
40957
|
+
* @async
|
|
40958
|
+
* */
|
|
40959
|
+
const flagPost = async (postId, reason) => {
|
|
40694
40960
|
const client = getActiveClient();
|
|
40695
|
-
|
|
40696
|
-
|
|
40697
|
-
|
|
40698
|
-
|
|
40699
|
-
|
|
40700
|
-
|
|
40701
|
-
callback(post);
|
|
40702
|
-
}
|
|
40961
|
+
client.log('post/flagPost', postId);
|
|
40962
|
+
const isPredefinedReason = reason &&
|
|
40963
|
+
Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
|
|
40964
|
+
const body = {
|
|
40965
|
+
reason: reason && isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
|
|
40966
|
+
detail: reason && !isPredefinedReason ? reason : '',
|
|
40703
40967
|
};
|
|
40704
|
-
|
|
40968
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
|
|
40969
|
+
if (client.cache) {
|
|
40970
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
40971
|
+
}
|
|
40972
|
+
fireEvent('post.flagged', payload);
|
|
40973
|
+
return !!payload;
|
|
40705
40974
|
};
|
|
40975
|
+
/* end_public_function */
|
|
40706
40976
|
|
|
40977
|
+
/* begin_public_function
|
|
40978
|
+
id: post.unflag
|
|
40979
|
+
*/
|
|
40707
40980
|
/**
|
|
40708
40981
|
* ```js
|
|
40709
|
-
* import {
|
|
40710
|
-
* const
|
|
40711
|
-
* // ...
|
|
40712
|
-
* })
|
|
40982
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
40983
|
+
* const unflagged = await PostRepository.unflagPost(postId)
|
|
40713
40984
|
* ```
|
|
40714
40985
|
*
|
|
40715
|
-
*
|
|
40986
|
+
* @param postId of the post to unflag
|
|
40987
|
+
* @returns the unflag post result
|
|
40716
40988
|
*
|
|
40717
|
-
* @
|
|
40718
|
-
* @
|
|
40989
|
+
* @category Post API
|
|
40990
|
+
* @async
|
|
40991
|
+
* */
|
|
40992
|
+
const unflagPost = async (postId) => {
|
|
40993
|
+
const client = getActiveClient();
|
|
40994
|
+
client.log('post/unflagPost', postId);
|
|
40995
|
+
const { data: payload } = await client.http.delete(`/api/v3/posts/${encodeURIComponent(postId)}/unflag`);
|
|
40996
|
+
if (client.cache) {
|
|
40997
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
40998
|
+
}
|
|
40999
|
+
fireEvent('post.unflagged', payload);
|
|
41000
|
+
return !!payload;
|
|
41001
|
+
};
|
|
41002
|
+
/* end_public_function */
|
|
41003
|
+
|
|
41004
|
+
/* begin_public_function
|
|
41005
|
+
id: post.check_flag_by_me
|
|
41006
|
+
*/
|
|
41007
|
+
/**
|
|
41008
|
+
* ```js
|
|
41009
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
41010
|
+
* const isReported = await PostRepository.isPostFlaggedByMe('post', postId)
|
|
41011
|
+
* ```
|
|
40719
41012
|
*
|
|
40720
|
-
* @
|
|
40721
|
-
|
|
40722
|
-
|
|
41013
|
+
* @param postId of the post to check if flagged by current user
|
|
41014
|
+
* @returns `true` if the post is flagged by me, `false` if doesn't.
|
|
41015
|
+
*
|
|
41016
|
+
* @category Post API
|
|
41017
|
+
* @async
|
|
41018
|
+
* */
|
|
41019
|
+
const isPostFlaggedByMe = async (postId) => {
|
|
40723
41020
|
const client = getActiveClient();
|
|
40724
|
-
|
|
40725
|
-
|
|
40726
|
-
|
|
40727
|
-
}
|
|
40728
|
-
else {
|
|
40729
|
-
upsertInCache(['post', 'get', post.postId], post);
|
|
40730
|
-
callback(post);
|
|
40731
|
-
}
|
|
40732
|
-
};
|
|
40733
|
-
return createEventSubscriber(client, 'local.post.removeReaction', 'local.post.removeReaction', filter);
|
|
41021
|
+
client.log('post/isPostFlaggedByMe', postId);
|
|
41022
|
+
const { data: { result }, } = await client.http.get(`/api/v3/posts/${postId}/isflagbyme`);
|
|
41023
|
+
return result;
|
|
40734
41024
|
};
|
|
41025
|
+
/* end_public_function */
|
|
40735
41026
|
|
|
41027
|
+
/* begin_public_function
|
|
41028
|
+
id: post.create.clip_post
|
|
41029
|
+
*/
|
|
40736
41030
|
/**
|
|
40737
41031
|
* ```js
|
|
40738
|
-
* import {
|
|
40739
|
-
* const
|
|
40740
|
-
*
|
|
40741
|
-
*
|
|
41032
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
41033
|
+
* const created = await PostRepository.createClipPost({
|
|
41034
|
+
* targetType: 'user',
|
|
41035
|
+
* targetId: 'foobar',
|
|
41036
|
+
* dataType: 'clip',
|
|
41037
|
+
* data: { text: 'hello world' },
|
|
41038
|
+
* attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
|
|
41039
|
+
* }))
|
|
40742
41040
|
* ```
|
|
40743
41041
|
*
|
|
40744
|
-
*
|
|
41042
|
+
* Creates an {@link Amity.Post}
|
|
40745
41043
|
*
|
|
40746
|
-
* @param
|
|
40747
|
-
* @returns
|
|
41044
|
+
* @param bundle The data necessary to create a new {@link Amity.Post}
|
|
41045
|
+
* @returns The newly created {@link Amity.Post}
|
|
40748
41046
|
*
|
|
40749
|
-
* @category Post
|
|
41047
|
+
* @category Post API
|
|
41048
|
+
* @async
|
|
40750
41049
|
*/
|
|
40751
|
-
const
|
|
41050
|
+
const createClipPost = async (bundle) => {
|
|
41051
|
+
const client = getActiveClient();
|
|
41052
|
+
client.log('post/createPost', bundle);
|
|
41053
|
+
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
41054
|
+
fireEvent('post.created', payload);
|
|
41055
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
41056
|
+
const cachedAt = client.cache && Date.now();
|
|
41057
|
+
if (client.cache)
|
|
41058
|
+
ingestInCache(data, { cachedAt });
|
|
41059
|
+
const { posts } = data;
|
|
41060
|
+
return {
|
|
41061
|
+
data: LinkedObject.post(posts[0]),
|
|
41062
|
+
cachedAt,
|
|
41063
|
+
};
|
|
41064
|
+
};
|
|
41065
|
+
/* end_public_function */
|
|
40752
41066
|
|
|
40753
41067
|
/* begin_public_function
|
|
40754
41068
|
id: post.get
|
|
@@ -40772,7 +41086,7 @@ const onLocalPostDeleted = (callback) => createLocalPostEventSubscriber('local.p
|
|
|
40772
41086
|
*
|
|
40773
41087
|
* @category Post Live Object
|
|
40774
41088
|
*/
|
|
40775
|
-
const getPost
|
|
41089
|
+
const getPost = (postId, callback) => {
|
|
40776
41090
|
const responder = (snapshot) => {
|
|
40777
41091
|
const { data } = snapshot;
|
|
40778
41092
|
callback(Object.assign(Object.assign({}, snapshot), { data: data ? LinkedObject.post(snapshot.data) : data }));
|
|
@@ -40861,19 +41175,6 @@ class PostPaginationController extends PaginationController {
|
|
|
40861
41175
|
}
|
|
40862
41176
|
}
|
|
40863
41177
|
|
|
40864
|
-
var EnumPostActions;
|
|
40865
|
-
(function (EnumPostActions) {
|
|
40866
|
-
EnumPostActions["OnPostCreated"] = "onPostCreated";
|
|
40867
|
-
EnumPostActions["OnPostUpdated"] = "onPostUpdated";
|
|
40868
|
-
EnumPostActions["OnPostDeleted"] = "onPostDeleted";
|
|
40869
|
-
EnumPostActions["OnPostFlagged"] = "onPostFlagged";
|
|
40870
|
-
EnumPostActions["OnPostUnflagged"] = "onPostUnflagged";
|
|
40871
|
-
EnumPostActions["OnPostReactionAdded"] = "onPostReactionAdded";
|
|
40872
|
-
EnumPostActions["OnPostReactionRemoved"] = "onPostReactionRemoved";
|
|
40873
|
-
EnumPostActions["OnPostApproved"] = "onPostApproved";
|
|
40874
|
-
EnumPostActions["OnPostDeclined"] = "onPostDeclined";
|
|
40875
|
-
})(EnumPostActions || (EnumPostActions = {}));
|
|
40876
|
-
|
|
40877
41178
|
class PostQueryStreamController extends QueryStreamController {
|
|
40878
41179
|
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
40879
41180
|
super(query, cacheKey);
|
|
@@ -40939,47 +41240,6 @@ class PostQueryStreamController extends QueryStreamController {
|
|
|
40939
41240
|
}
|
|
40940
41241
|
}
|
|
40941
41242
|
|
|
40942
|
-
const getPost = async (postId) => {
|
|
40943
|
-
const client = getActiveClient();
|
|
40944
|
-
client.log('post/getPost', postId);
|
|
40945
|
-
isInTombstone('post', postId);
|
|
40946
|
-
let payload;
|
|
40947
|
-
try {
|
|
40948
|
-
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
40949
|
-
const response = await client.http.get(`/api/v3/posts/${encodeURIComponent(postId)}`);
|
|
40950
|
-
payload = response.data;
|
|
40951
|
-
}
|
|
40952
|
-
catch (error) {
|
|
40953
|
-
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
40954
|
-
pushToTombstone('post', postId);
|
|
40955
|
-
}
|
|
40956
|
-
throw error;
|
|
40957
|
-
}
|
|
40958
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
40959
|
-
const cachedAt = client.cache && Date.now();
|
|
40960
|
-
if (client.cache)
|
|
40961
|
-
ingestInCache(data, { cachedAt });
|
|
40962
|
-
const { posts } = data;
|
|
40963
|
-
const result = posts.find(post => post.postId === postId);
|
|
40964
|
-
return {
|
|
40965
|
-
data: result,
|
|
40966
|
-
cachedAt,
|
|
40967
|
-
};
|
|
40968
|
-
};
|
|
40969
|
-
getPost.locally = (postId) => {
|
|
40970
|
-
const client = getActiveClient();
|
|
40971
|
-
client.log('post/getPost.locally', postId);
|
|
40972
|
-
if (!client.cache)
|
|
40973
|
-
return;
|
|
40974
|
-
const cached = pullFromCache(['post', 'get', postId]);
|
|
40975
|
-
if (!cached)
|
|
40976
|
-
return;
|
|
40977
|
-
return {
|
|
40978
|
-
data: cached.data,
|
|
40979
|
-
cachedAt: cached.cachedAt,
|
|
40980
|
-
};
|
|
40981
|
-
};
|
|
40982
|
-
|
|
40983
41243
|
class PostLiveCollectionController extends LiveCollectionController {
|
|
40984
41244
|
constructor(query, callback) {
|
|
40985
41245
|
const queryStreamId = hash(query);
|
|
@@ -41029,7 +41289,7 @@ class PostLiveCollectionController extends LiveCollectionController {
|
|
|
41029
41289
|
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
41030
41290
|
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
41031
41291
|
return;
|
|
41032
|
-
await getPost(comment.referenceId);
|
|
41292
|
+
await getPost$1(comment.referenceId);
|
|
41033
41293
|
callback(comment);
|
|
41034
41294
|
});
|
|
41035
41295
|
}, 'referenceId', 'post'),
|
|
@@ -41042,7 +41302,7 @@ class PostLiveCollectionController extends LiveCollectionController {
|
|
|
41042
41302
|
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
41043
41303
|
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
41044
41304
|
return;
|
|
41045
|
-
await getPost(comment.referenceId);
|
|
41305
|
+
await getPost$1(comment.referenceId);
|
|
41046
41306
|
callback(comment);
|
|
41047
41307
|
});
|
|
41048
41308
|
}, 'referenceId', 'post'),
|
|
@@ -41668,7 +41928,7 @@ var index$8 = /*#__PURE__*/Object.freeze({
|
|
|
41668
41928
|
onPostUnflagged: onPostUnflagged,
|
|
41669
41929
|
onPostReactionAdded: onPostReactionAdded,
|
|
41670
41930
|
onPostReactionRemoved: onPostReactionRemoved,
|
|
41671
|
-
getPost: getPost
|
|
41931
|
+
getPost: getPost,
|
|
41672
41932
|
getPosts: getPosts,
|
|
41673
41933
|
getPinnedPosts: getPinnedPosts,
|
|
41674
41934
|
getGlobalPinnedPosts: getGlobalPinnedPosts,
|
|
@@ -42551,7 +42811,7 @@ var index$6 = /*#__PURE__*/Object.freeze({
|
|
|
42551
42811
|
getPoll: getPoll
|
|
42552
42812
|
});
|
|
42553
42813
|
|
|
42554
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
42814
|
+
const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDAARz+hmBgi8pJ\nQb8LeY41gtHhk+ACMwRfhsn7GqpqRQNG2qU0755mzZuVDUqjQMGSo8THJB7O+OJs\nflbZRkFXlFoFOVNw1UpNOgwEQZ6wB9oRwzepTJAfF1sVhm/o/ixvXh1zDFNDy6yZ\npXyiiJHUVxqyjllZhxnwdvjoVtDs6hW6awG09bB9nh/TTejlUKXoAgzqVwu/1QMu\nUVViET495elEe19aUarEy+oL2iKeXCEvqda/pWNBdbieFyJvvZ08HN8dPuT88wq2\njZLEAth1vrwQ2IAa4ktaLcBQdLJgIkrbDvAiVZ8lQAjS/bq5vXQikTGvoPlC5bbn\nvuOM/3eLAgMBAAECggEAVZ+peHAghq2QVj71nX5lxsNCKaCyYwixSJBpfouTt7Rz\nE6PpzMOXFi1W1o+I22jDakuSM2SOQKqI/u0QefB0r0O/KVk5NrZHXk0mkrdYtxOp\nUgaGyf8UvmjB+8VqHrNKyZdk9qtmbnNj01kTTcAtmE4H39zPR7eR/8Rul94vaZbs\nwCnKJS3mLT3JxyGug6lxanveKkjG+CKC1nJQYWaxCJxaFSzbwXQPvDhB+TvrIbee\npd5v4EAyEJohpr+T9oDGGJkb/KARBZCtwLyB976PKJwwBA8MRVL1i5QwawuMiMq5\nUtnOnbGKtCeFzaLbNU0Qi8bqyims84EQxC6DOu1fkQKBgQDdvsoBsEhsOXV7hlIJ\naEd0eSJZVkdqimxH8uGoMM2FeNaOrcB6yBXqTSP0R3OIyf8eaY6yjRvP30ZNXcll\n/gD3O1Mu6YmWQdt1W2WA6pKOsUuPXasf0pdOF7IiFZKlSabz5YHXFqwVuqm8loaj\nsXel3YWqPVdHiankE7tz+3ssnQKBgQDdqi4TNdD1MdEpihx19jr0QjUiXW3939FK\nqp30HESPEGDGQzXdmJgif9HhZb+cJSuWaHEbjgBrYahvgCF+y6LbEpOD+D/dmT+s\nDEAQaR84sah6dokwPjV8fjBSrcVFjCS+doxv0d3p/9OUEeyUhFrY03nxtIEYkLIE\n/Zvn37b4RwKBgQCLENVFe9XfsaVhQ5r9dV2iyTlmh7qgMZG5CbTFs12hQGhm8McO\n+Z7s41YSJCFr/yq1WwP4LJDtrBw99vyQr1zRsG35tNLp3gGRNzGQSQyC2uQFVHw2\np+7mNewsfhUK/gbrXNsyFnDz6635rPlhfbII3sWuP2wWXFqkxE9CbMwR7QKBgQC6\nawDMzxmo2/iYArrkyevSuEuPVxvFwpF1RgAI6C0QVCnPE38dmdN4UB7mfHekje4W\nVEercMURidPp0cxZolCYBQtilUjAyL0vqC3In1/Ogjq6oy3FEMxSop1pKxMY5j+Q\nnoqFD+6deLUrddeNH7J3X4LSr4dSbX4JjG+tlgt+yQKBgQCuwTL4hA6KqeInQ0Ta\n9VQX5Qr8hFlqJz1gpymi/k63tW/Ob8yedbg3WWNWyShwRMFYyY9S81ITFWM95uL6\nvF3x9rmRjwElJw9PMwVu6dmf/CO0Z1wzXSp2VVD12gbrUD/0/d7MUoJ9LgC8X8f/\nn0txLHYGHbx+nf95+JUg6lV3hg==\n-----END PRIVATE KEY-----";
|
|
42555
42815
|
/*
|
|
42556
42816
|
* The crypto algorithm used for importing key and signing string
|
|
42557
42817
|
*/
|
|
@@ -44866,4 +45126,4 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
44866
45126
|
getReactions: getReactions
|
|
44867
45127
|
});
|
|
44868
45128
|
|
|
44869
|
-
export { API_REGIONS, index$3 as AdRepository, index$b as CategoryRepository, index$f as ChannelRepository, index$o as Client, index$
|
|
45129
|
+
export { API_REGIONS, index$3 as AdRepository, index$b as CategoryRepository, index$f as ChannelRepository, index$o as Client, index$a as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$c as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, FeedDataTypeEnum, index$9 as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$l as FileRepository, FileType, index$1 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index as LiveReactionRepository, index$5 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$j as MessageRepository, index$6 as PollRepository, PostContentType, index$8 as PostRepository, index$k as ReactionRepository, index$4 as StoryRepository, index$7 as StreamRepository, index$i as SubChannelRepository, SubscriptionLevels, index$m as UserRepository, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$2 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };
|