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