@amityco/ts-sdk 7.7.1-47be9e51.0 → 7.7.1-4843378b.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/domains/feed.d.ts +0 -31
- 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 +1 -21
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/feed.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/hashtag.d.ts +11 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/hashtag.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/hashtag.js +2 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/hashtag.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/post.d.ts +8 -3
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/post.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/post.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.d.ts +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.js +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.d.ts +0 -1
- 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 +0 -1
- 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/postRepository/api/createPost.d.ts +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/createPost.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/editPost.d.ts +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/editPost.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/getPostsByHashtag.d.ts +16 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/getPostsByHashtag.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/getPostsByHashtag.js +62 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/getPostsByHashtag.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/index.d.ts +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/index.js +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPosts/PostPaginationController.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPosts/PostPaginationController.js +2 -3
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPosts/PostPaginationController.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/{feedRepository/observers/getUserFeed/LiveCollectionController.d.ts → postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.d.ts} +4 -4
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/{feedRepository/observers/getUserFeed/LiveCollectionController.js → postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.js} +9 -12
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.d.ts +5 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.js +26 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.js.map +1 -0
- package/{dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts → .rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.d.ts} +4 -4
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/{feedRepository/observers/getUserFeed/QueryStreamController.js → postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.js} +6 -19
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/index.d.ts +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/index.js +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/searchPostsByHashtag.d.ts +22 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/searchPostsByHashtag.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/searchPostsByHashtag.js +45 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/searchPostsByHashtag.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/tsconfig.tsbuildinfo +1 -1
- package/dist/@types/domains/feed.d.ts +0 -31
- package/dist/@types/domains/feed.d.ts.map +1 -1
- package/dist/@types/domains/hashtag.d.ts +11 -0
- package/dist/@types/domains/hashtag.d.ts.map +1 -0
- package/dist/@types/domains/post.d.ts +8 -3
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/index.d.ts +1 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/feedRepository/index.d.ts +0 -1
- package/dist/feedRepository/index.d.ts.map +1 -1
- package/dist/index.cjs.js +1394 -1343
- package/dist/index.esm.js +1393 -1342
- package/dist/index.umd.js +4 -4
- package/dist/postRepository/api/createPost.d.ts +1 -1
- package/dist/postRepository/api/editPost.d.ts +1 -1
- package/dist/postRepository/api/getPostsByHashtag.d.ts +16 -0
- package/dist/postRepository/api/getPostsByHashtag.d.ts.map +1 -0
- package/dist/postRepository/api/index.d.ts +1 -0
- package/dist/postRepository/api/index.d.ts.map +1 -1
- package/dist/postRepository/observers/getPosts/PostPaginationController.d.ts.map +1 -1
- package/dist/{feedRepository/observers/getUserFeed/LiveCollectionController.d.ts → postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.d.ts} +4 -4
- package/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.d.ts.map +1 -0
- package/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.d.ts +5 -0
- package/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.d.ts.map +1 -0
- package/{.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts → dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.d.ts} +4 -4
- package/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.d.ts.map +1 -0
- package/dist/postRepository/observers/index.d.ts +1 -0
- package/dist/postRepository/observers/index.d.ts.map +1 -1
- package/dist/postRepository/observers/searchPostsByHashtag.d.ts +22 -0
- package/dist/postRepository/observers/searchPostsByHashtag.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/@types/domains/feed.ts +0 -43
- package/src/@types/domains/hashtag.ts +11 -0
- package/src/@types/domains/post.ts +12 -3
- package/src/@types/index.ts +1 -0
- package/src/feedRepository/index.ts +0 -1
- package/src/postRepository/api/createPost.ts +1 -1
- package/src/postRepository/api/editPost.ts +1 -1
- package/src/postRepository/api/getPostsByHashtag.ts +77 -0
- package/src/postRepository/api/index.ts +2 -0
- package/src/postRepository/observers/getPosts/PostPaginationController.ts +0 -3
- package/src/{feedRepository/observers/getUserFeed/LiveCollectionController.ts → postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.ts} +17 -23
- package/src/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.ts +45 -0
- package/src/{feedRepository/observers/getUserFeed/QueryStreamController.ts → postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.ts} +9 -29
- package/src/postRepository/observers/index.ts +1 -0
- package/src/postRepository/observers/searchPostsByHashtag.ts +56 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts.map +0 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.js.map +0 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts +0 -5
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts.map +0 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.js +0 -15
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.js.map +0 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts.map +0 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.js.map +0 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.d.ts +0 -23
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.d.ts.map +0 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.js +0 -46
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.js.map +0 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.d.ts +0 -2
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.d.ts.map +0 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.js +0 -2
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.js.map +0 -1
- package/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts.map +0 -1
- package/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts +0 -5
- package/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts.map +0 -1
- package/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts.map +0 -1
- package/dist/feedRepository/observers/getUserFeed.d.ts +0 -23
- package/dist/feedRepository/observers/getUserFeed.d.ts.map +0 -1
- package/dist/feedRepository/observers/index.d.ts +0 -2
- package/dist/feedRepository/observers/index.d.ts.map +0 -1
- package/src/feedRepository/observers/getUserFeed/PaginationController.ts +0 -37
- package/src/feedRepository/observers/getUserFeed.ts +0 -56
- package/src/feedRepository/observers/index.ts +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -23181,1779 +23181,1543 @@ getCustomRankingGlobalFeed.locally = (query) => {
|
|
|
23181
23181
|
: undefined;
|
|
23182
23182
|
};
|
|
23183
23183
|
|
|
23184
|
-
|
|
23185
|
-
|
|
23186
|
-
|
|
23187
|
-
|
|
23188
|
-
|
|
23189
|
-
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) }),
|
|
23190
|
-
});
|
|
23191
|
-
return queryResponse;
|
|
23192
|
-
}
|
|
23193
|
-
}
|
|
23194
|
-
|
|
23195
|
-
var EnumPostActions;
|
|
23196
|
-
(function (EnumPostActions) {
|
|
23197
|
-
EnumPostActions["OnPostCreated"] = "onPostCreated";
|
|
23198
|
-
EnumPostActions["OnPostUpdated"] = "onPostUpdated";
|
|
23199
|
-
EnumPostActions["OnPostDeleted"] = "onPostDeleted";
|
|
23200
|
-
EnumPostActions["OnPostFlagged"] = "onPostFlagged";
|
|
23201
|
-
EnumPostActions["OnPostUnflagged"] = "onPostUnflagged";
|
|
23202
|
-
EnumPostActions["OnPostReactionAdded"] = "onPostReactionAdded";
|
|
23203
|
-
EnumPostActions["OnPostReactionRemoved"] = "onPostReactionRemoved";
|
|
23204
|
-
EnumPostActions["OnPostApproved"] = "onPostApproved";
|
|
23205
|
-
EnumPostActions["OnPostDeclined"] = "onPostDeclined";
|
|
23206
|
-
})(EnumPostActions || (EnumPostActions = {}));
|
|
23207
|
-
|
|
23208
|
-
class UserFeedQueryStreamController extends QueryStreamController {
|
|
23209
|
-
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
23210
|
-
super(query, cacheKey);
|
|
23211
|
-
this.notifyChange = notifyChange;
|
|
23212
|
-
this.preparePayload = preparePayload;
|
|
23213
|
-
}
|
|
23214
|
-
async saveToMainDB(response) {
|
|
23215
|
-
const processedPayload = await this.preparePayload(response);
|
|
23216
|
-
const client = getActiveClient();
|
|
23217
|
-
const cachedAt = client.cache && Date.now();
|
|
23218
|
-
if (client.cache) {
|
|
23219
|
-
ingestInCache(processedPayload, { cachedAt });
|
|
23220
|
-
}
|
|
23221
|
-
}
|
|
23222
|
-
appendToQueryStream(response, direction, refresh = false) {
|
|
23223
|
-
var _a, _b;
|
|
23224
|
-
if (refresh) {
|
|
23225
|
-
pushToCache(this.cacheKey, {
|
|
23226
|
-
data: response.posts.map(getResolver('post')),
|
|
23227
|
-
});
|
|
23228
|
-
}
|
|
23229
|
-
else {
|
|
23230
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
23231
|
-
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
23232
|
-
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
|
|
23233
|
-
}
|
|
23234
|
-
}
|
|
23235
|
-
reactor(action) {
|
|
23236
|
-
return (post) => {
|
|
23237
|
-
var _a, _b;
|
|
23238
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
23239
|
-
if (!collection)
|
|
23240
|
-
return;
|
|
23241
|
-
// if the collection is parent post collection and
|
|
23242
|
-
// post is not included in the collection or post is child post
|
|
23243
|
-
if ((!this.query.dataTypes || this.query.dataTypes.length === 0) &&
|
|
23244
|
-
!collection.data.includes(post.parentPostId ? post.parentPostId : post.postId))
|
|
23245
|
-
return;
|
|
23246
|
-
if (action === EnumPostActions.OnPostDeleted) {
|
|
23247
|
-
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
23248
|
-
}
|
|
23249
|
-
if (post.parentPostId && post.isDeleted) {
|
|
23250
|
-
const parentPost = (_b = pullFromCache([
|
|
23251
|
-
'post',
|
|
23252
|
-
'get',
|
|
23253
|
-
post.parentPostId,
|
|
23254
|
-
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
23255
|
-
if (!parentPost)
|
|
23256
|
-
return;
|
|
23257
|
-
parentPost.children = parentPost.children.filter(childId => childId !== post.postId);
|
|
23258
|
-
pushToCache(['post', 'get', parentPost.postId], parentPost);
|
|
23259
|
-
}
|
|
23260
|
-
if (action === EnumPostActions.OnPostDeclined) {
|
|
23261
|
-
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
23262
|
-
}
|
|
23263
|
-
if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
|
|
23264
|
-
if (this.query.dataTypes &&
|
|
23265
|
-
this.query.dataTypes.length > 0 &&
|
|
23266
|
-
!this.query.dataTypes.includes(post.dataType)) {
|
|
23267
|
-
return;
|
|
23268
|
-
}
|
|
23269
|
-
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
23270
|
-
}
|
|
23271
|
-
pushToCache(this.cacheKey, collection);
|
|
23272
|
-
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
23273
|
-
};
|
|
23274
|
-
}
|
|
23275
|
-
subscribeRTE(createSubscriber) {
|
|
23276
|
-
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
23277
|
-
}
|
|
23278
|
-
}
|
|
23184
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
23185
|
+
__proto__: null,
|
|
23186
|
+
queryGlobalFeed: queryGlobalFeed,
|
|
23187
|
+
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed
|
|
23188
|
+
});
|
|
23279
23189
|
|
|
23280
23190
|
/* begin_public_function
|
|
23281
|
-
id:
|
|
23191
|
+
id: post.get_by_ids
|
|
23282
23192
|
*/
|
|
23283
23193
|
/**
|
|
23284
23194
|
* ```js
|
|
23285
|
-
* import {
|
|
23286
|
-
* const
|
|
23195
|
+
* import { getPostByIds } from '@amityco/ts-sdk'
|
|
23196
|
+
* const { data: posts } = await getPostByIds(['foo', 'bar'])
|
|
23287
23197
|
* ```
|
|
23288
23198
|
*
|
|
23289
|
-
* Fetches a collection of {@link Amity.
|
|
23199
|
+
* Fetches a collection of {@link Amity.Post} objects
|
|
23290
23200
|
*
|
|
23291
|
-
* @param
|
|
23292
|
-
* @returns the associated collection of {@link Amity.
|
|
23201
|
+
* @param postIds the IDs of the {@link Amity.Post} to fetch
|
|
23202
|
+
* @returns the associated collection of {@link Amity.Post} objects
|
|
23293
23203
|
*
|
|
23294
|
-
* @category
|
|
23204
|
+
* @category Post API
|
|
23295
23205
|
* @async
|
|
23296
23206
|
*/
|
|
23297
|
-
const
|
|
23207
|
+
const getPostByIds = async (postIds) => {
|
|
23298
23208
|
const client = getActiveClient();
|
|
23299
|
-
client.log('
|
|
23300
|
-
const
|
|
23301
|
-
let
|
|
23209
|
+
client.log('post/getPostByIds', postIds);
|
|
23210
|
+
const encodedPostIds = postIds.map(postId => encodeURIComponent(postId));
|
|
23211
|
+
let payload;
|
|
23302
23212
|
try {
|
|
23303
23213
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
23304
|
-
const response = await client.http.get(`/api/v3/
|
|
23305
|
-
params: {
|
|
23214
|
+
const response = await client.http.get(`/api/v3/posts/list`, {
|
|
23215
|
+
params: { postIds: encodedPostIds },
|
|
23306
23216
|
});
|
|
23307
|
-
|
|
23217
|
+
payload = response.data;
|
|
23308
23218
|
}
|
|
23309
23219
|
catch (error) {
|
|
23310
|
-
|
|
23220
|
+
postIds.forEach(postId => {
|
|
23311
23221
|
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
23312
|
-
pushToTombstone('
|
|
23222
|
+
pushToTombstone('post', postId);
|
|
23313
23223
|
}
|
|
23314
23224
|
});
|
|
23315
23225
|
throw error;
|
|
23316
23226
|
}
|
|
23227
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23317
23228
|
const cachedAt = client.cache && Date.now();
|
|
23318
23229
|
if (client.cache)
|
|
23319
23230
|
ingestInCache(data, { cachedAt });
|
|
23320
23231
|
return {
|
|
23321
|
-
data: data.
|
|
23232
|
+
data: data.posts.map(LinkedObject.post),
|
|
23322
23233
|
cachedAt,
|
|
23323
23234
|
};
|
|
23324
23235
|
};
|
|
23325
23236
|
/* end_public_function */
|
|
23326
23237
|
/**
|
|
23327
23238
|
* ```js
|
|
23328
|
-
* import {
|
|
23329
|
-
* const
|
|
23239
|
+
* import { getPostByIds } from '@amityco/ts-sdk'
|
|
23240
|
+
* const { data: posts } = getPostByIds.locally(['foo', 'bar'])
|
|
23330
23241
|
* ```
|
|
23331
23242
|
*
|
|
23332
|
-
* Fetches a collection of {@link Amity.
|
|
23243
|
+
* Fetches a collection of {@link Amity.Post} objects from cache
|
|
23333
23244
|
*
|
|
23334
|
-
* @param
|
|
23335
|
-
* @returns the associated collection of {@link Amity.
|
|
23245
|
+
* @param postIds the IDs of the {@link Amity.Post} to fetch
|
|
23246
|
+
* @returns the associated collection of {@link Amity.Post} objects
|
|
23336
23247
|
*
|
|
23337
|
-
* @category
|
|
23248
|
+
* @category Post API
|
|
23338
23249
|
*/
|
|
23339
|
-
|
|
23250
|
+
getPostByIds.locally = (postIds) => {
|
|
23340
23251
|
var _a;
|
|
23341
23252
|
const client = getActiveClient();
|
|
23342
|
-
client.log('
|
|
23253
|
+
client.log('post/getPostByIds.locally', postIds);
|
|
23343
23254
|
if (!client.cache)
|
|
23344
23255
|
return;
|
|
23345
|
-
const cached =
|
|
23346
|
-
.map(
|
|
23256
|
+
const cached = postIds
|
|
23257
|
+
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
23347
23258
|
.filter(Boolean);
|
|
23348
|
-
const
|
|
23259
|
+
const posts = cached.map(({ data }) => data);
|
|
23349
23260
|
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
23350
|
-
if ((cached === null || cached === void 0 ? void 0 : cached.length) <
|
|
23261
|
+
if ((cached === null || cached === void 0 ? void 0 : cached.length) < postIds.length)
|
|
23351
23262
|
return;
|
|
23352
23263
|
return {
|
|
23353
|
-
data:
|
|
23264
|
+
data: posts.map(LinkedObject.post),
|
|
23354
23265
|
cachedAt: oldest.cachedAt,
|
|
23355
23266
|
};
|
|
23356
23267
|
};
|
|
23357
23268
|
|
|
23358
23269
|
/* begin_public_function
|
|
23359
|
-
id:
|
|
23270
|
+
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
|
|
23360
23271
|
*/
|
|
23361
23272
|
/**
|
|
23362
23273
|
* ```js
|
|
23363
|
-
* import {
|
|
23364
|
-
* const
|
|
23274
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
23275
|
+
* const created = await PostRepository.createPost({
|
|
23276
|
+
* targetType: 'user',
|
|
23277
|
+
* targetId: 'foobar',
|
|
23278
|
+
* data: { text: 'hello world' }
|
|
23279
|
+
* }))
|
|
23365
23280
|
* ```
|
|
23366
23281
|
*
|
|
23367
|
-
* Creates an {@link Amity.
|
|
23282
|
+
* Creates an {@link Amity.Post}
|
|
23368
23283
|
*
|
|
23369
|
-
* @param bundle The data necessary to create a new {@link Amity.
|
|
23370
|
-
* @returns The newly created {@link Amity.
|
|
23284
|
+
* @param bundle The data necessary to create a new {@link Amity.Post}
|
|
23285
|
+
* @returns The newly created {@link Amity.Post}
|
|
23371
23286
|
*
|
|
23372
|
-
* @category
|
|
23287
|
+
* @category Post API
|
|
23373
23288
|
* @async
|
|
23374
23289
|
*/
|
|
23375
|
-
const
|
|
23376
|
-
var _a;
|
|
23290
|
+
const createPost = async (bundle) => {
|
|
23377
23291
|
const client = getActiveClient();
|
|
23378
|
-
client.log('
|
|
23379
|
-
|
|
23380
|
-
|
|
23381
|
-
|
|
23382
|
-
|
|
23383
|
-
|
|
23292
|
+
client.log('post/createPost', bundle);
|
|
23293
|
+
if (!bundle.dataType || ['text', 'image', 'file', 'video'].includes(bundle.dataType)) {
|
|
23294
|
+
// eslint-disable-next-line no-param-reassign
|
|
23295
|
+
delete bundle.dataType;
|
|
23296
|
+
}
|
|
23297
|
+
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
23298
|
+
fireEvent('post.created', payload);
|
|
23299
|
+
const data = preparePostPayload(payload);
|
|
23384
23300
|
const cachedAt = client.cache && Date.now();
|
|
23385
23301
|
if (client.cache)
|
|
23386
23302
|
ingestInCache(data, { cachedAt });
|
|
23387
|
-
|
|
23388
|
-
const post = (_a = pullFromCache(['post', 'get', bundle.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
23389
|
-
if (post) {
|
|
23390
|
-
post.commentsCount += 1;
|
|
23391
|
-
fireEvent('local.post.updated', {
|
|
23392
|
-
posts: [post],
|
|
23393
|
-
categories: [],
|
|
23394
|
-
comments: [],
|
|
23395
|
-
communities: [],
|
|
23396
|
-
communityUsers: data.communityUsers,
|
|
23397
|
-
feeds: [],
|
|
23398
|
-
files: data.files,
|
|
23399
|
-
postChildren: [],
|
|
23400
|
-
users: data.users,
|
|
23401
|
-
videoStreamings: [],
|
|
23402
|
-
});
|
|
23403
|
-
}
|
|
23404
|
-
}
|
|
23405
|
-
else if (bundle.referenceType === 'story') {
|
|
23406
|
-
const storyIndex = pullFromCache([
|
|
23407
|
-
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
23408
|
-
bundle.referenceId,
|
|
23409
|
-
]);
|
|
23410
|
-
if (storyIndex === null || storyIndex === void 0 ? void 0 : storyIndex.data) {
|
|
23411
|
-
const cacheStory = pullFromCache([
|
|
23412
|
-
"story" /* STORY_KEY_CACHE.STORY */,
|
|
23413
|
-
'get',
|
|
23414
|
-
storyIndex.data,
|
|
23415
|
-
]);
|
|
23416
|
-
if (cacheStory === null || cacheStory === void 0 ? void 0 : cacheStory.data) {
|
|
23417
|
-
fireEvent('story.updated', {
|
|
23418
|
-
stories: [
|
|
23419
|
-
Object.assign(Object.assign({}, cacheStory.data), { commentsCount: cacheStory.data.commentsCount + 1, comments: [...new Set([...cacheStory.data.comments, comments[0].commentId])] }),
|
|
23420
|
-
],
|
|
23421
|
-
categories: [],
|
|
23422
|
-
comments,
|
|
23423
|
-
communities: [],
|
|
23424
|
-
communityUsers: data.communityUsers,
|
|
23425
|
-
files: data.files,
|
|
23426
|
-
users: data.users,
|
|
23427
|
-
});
|
|
23428
|
-
}
|
|
23429
|
-
}
|
|
23430
|
-
}
|
|
23431
|
-
fireEvent('local.comment.created', data);
|
|
23303
|
+
const { posts } = data;
|
|
23432
23304
|
return {
|
|
23433
|
-
data: LinkedObject.
|
|
23305
|
+
data: LinkedObject.post(posts[0]),
|
|
23434
23306
|
cachedAt,
|
|
23435
23307
|
};
|
|
23436
23308
|
};
|
|
23437
23309
|
/* end_public_function */
|
|
23438
23310
|
|
|
23439
23311
|
/* begin_public_function
|
|
23440
|
-
id:
|
|
23312
|
+
id: post.edit, post.edit.custom_post
|
|
23441
23313
|
*/
|
|
23442
23314
|
/**
|
|
23443
23315
|
* ```js
|
|
23444
|
-
* import {
|
|
23445
|
-
* const updated = await
|
|
23316
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
23317
|
+
* const updated = await PostRepository.editPost(postId, {
|
|
23446
23318
|
* data: { text: 'hello world' }
|
|
23447
23319
|
* })
|
|
23448
23320
|
* ```
|
|
23449
23321
|
*
|
|
23450
|
-
* Updates an {@link Amity.
|
|
23322
|
+
* Updates an {@link Amity.Post}
|
|
23451
23323
|
*
|
|
23452
|
-
* @param
|
|
23324
|
+
* @param postId The ID of the {@link Amity.Post} to edit
|
|
23453
23325
|
* @param patch The patch data to apply
|
|
23454
|
-
* @returns the updated {@link Amity.
|
|
23326
|
+
* @returns the updated {@link Amity.Post} object
|
|
23455
23327
|
*
|
|
23456
|
-
* @category
|
|
23328
|
+
* @category Post API
|
|
23457
23329
|
* @async
|
|
23458
23330
|
*/
|
|
23459
|
-
const
|
|
23331
|
+
const editPost = async (postId, patch) => {
|
|
23460
23332
|
const client = getActiveClient();
|
|
23461
|
-
client.log('user/
|
|
23462
|
-
const { data } = await client.http.put(`/api/
|
|
23333
|
+
client.log('user/editPost', patch);
|
|
23334
|
+
const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
|
|
23335
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23463
23336
|
const cachedAt = client.cache && Date.now();
|
|
23464
23337
|
if (client.cache)
|
|
23465
23338
|
ingestInCache(data, { cachedAt });
|
|
23466
|
-
fireEvent('
|
|
23467
|
-
const {
|
|
23339
|
+
fireEvent('local.post.updated', data);
|
|
23340
|
+
const { posts } = data;
|
|
23468
23341
|
return {
|
|
23469
|
-
data: LinkedObject.
|
|
23342
|
+
data: LinkedObject.post(posts.find(post => post.postId === postId)),
|
|
23470
23343
|
cachedAt,
|
|
23471
23344
|
};
|
|
23472
23345
|
};
|
|
23473
23346
|
/* end_public_function */
|
|
23474
23347
|
|
|
23475
|
-
// Due to we have optimistic logic, we will use referenceId as a id in SDK instead of storyId
|
|
23476
|
-
const applyMissingField = (rawData, isCreated = false) => {
|
|
23477
|
-
const { storyId, referenceId } = rawData;
|
|
23478
|
-
if (!isCreated) {
|
|
23479
|
-
if (referenceId)
|
|
23480
|
-
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */ });
|
|
23481
|
-
}
|
|
23482
|
-
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */, referenceId: storyId });
|
|
23483
|
-
};
|
|
23484
|
-
const convertRawStoryToInternal = (data, isCreated = false) => {
|
|
23485
|
-
const { stories } = data;
|
|
23486
|
-
const storiesData = stories.map(story => applyMissingField(story, isCreated));
|
|
23487
|
-
return Object.assign(Object.assign({}, data), { stories: storiesData });
|
|
23488
|
-
};
|
|
23489
|
-
|
|
23490
|
-
const getStoryByStoryId$1 = async (storyId) => {
|
|
23491
|
-
const client = getActiveClient();
|
|
23492
|
-
client.log('story/getStoryByStoryId', storyId);
|
|
23493
|
-
// Get story referenceId from cache
|
|
23494
|
-
const cacheReferenceId = pullFromCache([
|
|
23495
|
-
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
23496
|
-
storyId,
|
|
23497
|
-
]);
|
|
23498
|
-
if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
|
|
23499
|
-
const { data: referenceId } = cacheReferenceId;
|
|
23500
|
-
isInTombstone('story', referenceId);
|
|
23501
|
-
}
|
|
23502
|
-
let data;
|
|
23503
|
-
try {
|
|
23504
|
-
const response = await client.http.get(`/api/v4/stories/${storyId}`);
|
|
23505
|
-
data = convertRawStoryToInternal(response.data);
|
|
23506
|
-
}
|
|
23507
|
-
catch (error) {
|
|
23508
|
-
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
23509
|
-
pushToTombstone('story', storyId);
|
|
23510
|
-
}
|
|
23511
|
-
throw error;
|
|
23512
|
-
}
|
|
23513
|
-
const cachedAt = client.cache && Date.now();
|
|
23514
|
-
if (client.cache) {
|
|
23515
|
-
ingestInCache(data, { cachedAt });
|
|
23516
|
-
}
|
|
23517
|
-
return {
|
|
23518
|
-
data: data.stories[0],
|
|
23519
|
-
cachedAt,
|
|
23520
|
-
};
|
|
23521
|
-
};
|
|
23522
|
-
getStoryByStoryId$1.locally = (storyId) => {
|
|
23523
|
-
const client = getActiveClient();
|
|
23524
|
-
client.log('story/getStorybyStoryId', storyId);
|
|
23525
|
-
// Get story referenceId from cache
|
|
23526
|
-
const cacheReferenceId = pullFromCache([
|
|
23527
|
-
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
23528
|
-
storyId,
|
|
23529
|
-
]);
|
|
23530
|
-
if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
|
|
23531
|
-
const { data: referenceId } = cacheReferenceId;
|
|
23532
|
-
isInTombstone('story', referenceId);
|
|
23533
|
-
}
|
|
23534
|
-
const cachedAt = client.cache && Date.now();
|
|
23535
|
-
const storyCache = pullFromCache(['story', 'get', storyId]);
|
|
23536
|
-
if (!storyCache)
|
|
23537
|
-
return;
|
|
23538
|
-
return {
|
|
23539
|
-
data: storyCache.data,
|
|
23540
|
-
cachedAt,
|
|
23541
|
-
};
|
|
23542
|
-
};
|
|
23543
|
-
|
|
23544
|
-
/* begin_public_function
|
|
23545
|
-
id: comment.soft_delete, comment.hard_delete
|
|
23546
|
-
*/
|
|
23547
23348
|
/**
|
|
23548
23349
|
* ```js
|
|
23549
|
-
* import {
|
|
23550
|
-
* const success = await
|
|
23350
|
+
* import { deletePost } from '@amityco/ts-sdk'
|
|
23351
|
+
* const success = await deletePost('foobar')
|
|
23551
23352
|
* ```
|
|
23552
23353
|
*
|
|
23553
|
-
* Deletes a {@link Amity.
|
|
23354
|
+
* Deletes a {@link Amity.Post}
|
|
23554
23355
|
*
|
|
23555
|
-
* @param
|
|
23556
|
-
* @return A success boolean if the {@link Amity.
|
|
23356
|
+
* @param postId The {@link Amity.Post} ID to delete
|
|
23357
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
23557
23358
|
*
|
|
23558
|
-
* @
|
|
23359
|
+
* @private
|
|
23559
23360
|
* @async
|
|
23560
23361
|
*/
|
|
23561
|
-
const
|
|
23362
|
+
const deletePost = async (postId, permanent = false) => {
|
|
23562
23363
|
var _a;
|
|
23563
23364
|
const client = getActiveClient();
|
|
23564
|
-
const
|
|
23565
|
-
|
|
23566
|
-
await client.http.delete(`/api/v4/comments/${encodeURIComponent(commentId)}`, {
|
|
23365
|
+
const post = await getPost$2(postId);
|
|
23366
|
+
await client.http.delete(`/api/v4/posts/${encodeURIComponent(postId)}`, {
|
|
23567
23367
|
params: {
|
|
23568
|
-
|
|
23368
|
+
postId,
|
|
23569
23369
|
permanent,
|
|
23570
23370
|
},
|
|
23571
23371
|
});
|
|
23572
|
-
// to
|
|
23573
|
-
|
|
23574
|
-
|
|
23575
|
-
|
|
23576
|
-
|
|
23577
|
-
|
|
23372
|
+
// there is currently a limitation which doesn't allow us to fire event to tell that community
|
|
23373
|
+
// has been updated. reason is that, when the object is deleted, we don't have its `communityId`
|
|
23374
|
+
// and so we cannot refetch the community or advertise on events. hopefully this should be solved
|
|
23375
|
+
// later when realtime events covers that for us.
|
|
23376
|
+
if (post.data.targetType === 'community') {
|
|
23377
|
+
const community = await getCommunity$1(post.data.targetId);
|
|
23378
|
+
const communityUsersCache = (_a = queryCache(['communityUsers', 'get'])) !== null && _a !== void 0 ? _a : [];
|
|
23379
|
+
const communityUsers = communityUsersCache
|
|
23380
|
+
.filter(({ key }) => {
|
|
23381
|
+
// cache key is ['communityUsers', 'get', `${communityId}#`${userId}`}]
|
|
23382
|
+
if (key[0] !== 'communityUsers')
|
|
23383
|
+
return false;
|
|
23384
|
+
if (key[1] !== 'get')
|
|
23385
|
+
return false;
|
|
23386
|
+
if (typeof key[2] === 'string')
|
|
23387
|
+
return key[2].includes(community.data.communityId);
|
|
23388
|
+
return false;
|
|
23389
|
+
})
|
|
23390
|
+
.map(({ data }) => data);
|
|
23391
|
+
fireEvent('community.updated', {
|
|
23392
|
+
communities: [community.data],
|
|
23578
23393
|
categories: [],
|
|
23579
|
-
|
|
23580
|
-
|
|
23581
|
-
communityUsers: [],
|
|
23394
|
+
communityUsers,
|
|
23395
|
+
feeds: [],
|
|
23582
23396
|
files: [],
|
|
23583
23397
|
users: [],
|
|
23584
23398
|
});
|
|
23585
23399
|
}
|
|
23400
|
+
// to support hard deletion
|
|
23401
|
+
const deleted = Object.assign(Object.assign({}, post.data), { isDeleted: true });
|
|
23402
|
+
if (permanent) {
|
|
23403
|
+
setTimeout(() => {
|
|
23404
|
+
pushToTombstone('post', postId);
|
|
23405
|
+
}, 0);
|
|
23406
|
+
}
|
|
23586
23407
|
else {
|
|
23587
|
-
|
|
23588
|
-
if (post) {
|
|
23589
|
-
let removeCount;
|
|
23590
|
-
if (!deleted.parentId) {
|
|
23591
|
-
// NOTE: delete the parent comment will remove all children comments
|
|
23592
|
-
removeCount = deleted.childrenNumber + 1;
|
|
23593
|
-
}
|
|
23594
|
-
else
|
|
23595
|
-
removeCount = 1;
|
|
23596
|
-
post.commentsCount -= removeCount;
|
|
23597
|
-
fireEvent('local.post.updated', {
|
|
23598
|
-
posts: [post],
|
|
23599
|
-
categories: [],
|
|
23600
|
-
comments: [],
|
|
23601
|
-
communities: [],
|
|
23602
|
-
communityUsers: [],
|
|
23603
|
-
feeds: [],
|
|
23604
|
-
files: [],
|
|
23605
|
-
postChildren: [],
|
|
23606
|
-
users: [],
|
|
23607
|
-
videoStreamings: [],
|
|
23608
|
-
});
|
|
23609
|
-
}
|
|
23408
|
+
upsertInCache(['post', 'get', postId], { isDeleted: true });
|
|
23610
23409
|
}
|
|
23611
|
-
fireEvent('local.
|
|
23612
|
-
|
|
23613
|
-
|
|
23410
|
+
fireEvent('local.post.deleted', {
|
|
23411
|
+
posts: [deleted],
|
|
23412
|
+
categories: [],
|
|
23413
|
+
comments: [],
|
|
23414
|
+
communities: [],
|
|
23415
|
+
communityUsers: [],
|
|
23416
|
+
feeds: [],
|
|
23614
23417
|
files: [],
|
|
23418
|
+
postChildren: [],
|
|
23615
23419
|
users: [],
|
|
23616
|
-
|
|
23420
|
+
videoStreamings: [],
|
|
23617
23421
|
});
|
|
23618
|
-
|
|
23619
|
-
scheduleTask(() => pushToTombstone('comment', commentId));
|
|
23620
|
-
}
|
|
23621
|
-
else {
|
|
23622
|
-
upsertInCache(['comment', 'get', commentId], { isDeleted: true });
|
|
23623
|
-
}
|
|
23624
|
-
return deleted;
|
|
23422
|
+
return LinkedObject.post(deleted);
|
|
23625
23423
|
};
|
|
23626
|
-
/* end_public_function */
|
|
23627
23424
|
|
|
23628
23425
|
/* begin_public_function
|
|
23629
|
-
id:
|
|
23426
|
+
id: post.soft_delete
|
|
23630
23427
|
*/
|
|
23631
23428
|
/**
|
|
23632
23429
|
* ```js
|
|
23633
|
-
* import {
|
|
23634
|
-
* const success = await
|
|
23430
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
23431
|
+
* const success = await PostRepository.softDeletePost('foobar')
|
|
23635
23432
|
* ```
|
|
23636
23433
|
*
|
|
23637
|
-
*
|
|
23434
|
+
* Soft deletes a {@link Amity.Post}
|
|
23638
23435
|
*
|
|
23639
|
-
* @param
|
|
23640
|
-
* @return A success boolean if the {@link Amity.
|
|
23436
|
+
* @param postId The {@link Amity.Post} ID to soft delete
|
|
23437
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
23641
23438
|
*
|
|
23642
|
-
* @category
|
|
23439
|
+
* @category Post API
|
|
23643
23440
|
* @async
|
|
23644
23441
|
*/
|
|
23645
|
-
const
|
|
23442
|
+
const softDeletePost = async (postId) => {
|
|
23646
23443
|
const client = getActiveClient();
|
|
23647
|
-
client.log('
|
|
23648
|
-
const softDeleted =
|
|
23649
|
-
return softDeleted;
|
|
23444
|
+
client.log('post/softDeletePost', postId);
|
|
23445
|
+
const softDeleted = await deletePost(postId, false);
|
|
23446
|
+
return LinkedObject.post(softDeleted);
|
|
23650
23447
|
};
|
|
23651
23448
|
/* end_public_function */
|
|
23652
23449
|
|
|
23653
23450
|
/* begin_public_function
|
|
23654
|
-
id:
|
|
23451
|
+
id: post.hard_delete
|
|
23655
23452
|
*/
|
|
23656
23453
|
/**
|
|
23657
23454
|
* ```js
|
|
23658
|
-
* import {
|
|
23659
|
-
* const success = await
|
|
23455
|
+
* import { hardDeletePost } from '@amityco/ts-sdk'
|
|
23456
|
+
* const success = await hardDeletePost('foobar')
|
|
23660
23457
|
* ```
|
|
23661
23458
|
*
|
|
23662
|
-
*
|
|
23459
|
+
* Hard deletes a {@link Amity.Post}
|
|
23663
23460
|
*
|
|
23664
|
-
* @param
|
|
23665
|
-
* @return A success boolean if the {@link Amity.
|
|
23461
|
+
* @param postId The {@link Amity.Post} ID to be hard delete
|
|
23462
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
23666
23463
|
*
|
|
23667
|
-
* @category
|
|
23464
|
+
* @category Post API
|
|
23668
23465
|
* @async
|
|
23669
23466
|
*/
|
|
23670
|
-
const
|
|
23467
|
+
const hardDeletePost = async (postId) => {
|
|
23671
23468
|
const client = getActiveClient();
|
|
23672
|
-
client.log('
|
|
23673
|
-
const hardDeleted =
|
|
23674
|
-
return hardDeleted;
|
|
23469
|
+
client.log('post/hardDeletePost', postId);
|
|
23470
|
+
const hardDeleted = await deletePost(postId, true);
|
|
23471
|
+
return LinkedObject.post(hardDeleted);
|
|
23675
23472
|
};
|
|
23676
23473
|
/* end_public_function */
|
|
23677
23474
|
|
|
23678
23475
|
/* begin_public_function
|
|
23679
|
-
id:
|
|
23476
|
+
id: post.approve
|
|
23680
23477
|
*/
|
|
23681
23478
|
/**
|
|
23682
23479
|
* ```js
|
|
23683
|
-
* import {
|
|
23684
|
-
*
|
|
23480
|
+
* import { approvePost } from '@amityco/ts-sdk'
|
|
23481
|
+
*
|
|
23482
|
+
* const { data: post } = await approvePost('postId')
|
|
23685
23483
|
* ```
|
|
23686
23484
|
*
|
|
23687
|
-
*
|
|
23688
|
-
* @param reason the reason to flag the comment
|
|
23689
|
-
* @returns the created report result
|
|
23485
|
+
* Approves a {@link Amity.Post}
|
|
23690
23486
|
*
|
|
23691
|
-
* @
|
|
23487
|
+
* @param postId The {@link Amity.Post} ID to be approved
|
|
23488
|
+
* @return A {@link Amity.Post} that was approved
|
|
23489
|
+
*
|
|
23490
|
+
* @category Post API
|
|
23692
23491
|
* @async
|
|
23693
|
-
|
|
23694
|
-
const
|
|
23492
|
+
*/
|
|
23493
|
+
const approvePost = async (postId) => {
|
|
23695
23494
|
const client = getActiveClient();
|
|
23696
|
-
client.log('
|
|
23697
|
-
const
|
|
23698
|
-
|
|
23699
|
-
|
|
23700
|
-
|
|
23701
|
-
|
|
23702
|
-
}
|
|
23703
|
-
const
|
|
23704
|
-
|
|
23705
|
-
|
|
23706
|
-
|
|
23707
|
-
|
|
23708
|
-
|
|
23495
|
+
client.log('post/approvePost', postId);
|
|
23496
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/approve`);
|
|
23497
|
+
fireEvent('post.approved', payload);
|
|
23498
|
+
// fire virtual event for community update
|
|
23499
|
+
if (payload.posts[0].targetType === 'community') {
|
|
23500
|
+
fireEvent('community.updated', payload);
|
|
23501
|
+
}
|
|
23502
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23503
|
+
const cachedAt = client.cache && Date.now();
|
|
23504
|
+
if (client.cache)
|
|
23505
|
+
ingestInCache(data, { cachedAt });
|
|
23506
|
+
return {
|
|
23507
|
+
data: LinkedObject.post(data.posts.find(post => post.postId === postId)),
|
|
23508
|
+
cachedAt,
|
|
23509
|
+
};
|
|
23709
23510
|
};
|
|
23710
23511
|
/* end_public_function */
|
|
23711
23512
|
|
|
23712
23513
|
/* begin_public_function
|
|
23713
|
-
id:
|
|
23514
|
+
id: post.decline
|
|
23714
23515
|
*/
|
|
23715
23516
|
/**
|
|
23716
23517
|
* ```js
|
|
23717
|
-
* import {
|
|
23718
|
-
*
|
|
23518
|
+
* import { declinePost } from '@amityco/ts-sdk'
|
|
23519
|
+
*
|
|
23520
|
+
* const {data: post} = await declinePost('postId')
|
|
23719
23521
|
* ```
|
|
23720
23522
|
*
|
|
23721
|
-
*
|
|
23722
|
-
* @returns the unflagged result
|
|
23523
|
+
* Declines a {@link Amity.Post}
|
|
23723
23524
|
*
|
|
23724
|
-
* @
|
|
23525
|
+
* @param postId The {@link Amity.Post} ID to be declined
|
|
23526
|
+
* @return A {@link Amity.Post} that was declined
|
|
23527
|
+
*
|
|
23528
|
+
* @category Post API
|
|
23725
23529
|
* @async
|
|
23726
|
-
|
|
23727
|
-
const
|
|
23530
|
+
*/
|
|
23531
|
+
const declinePost = async (postId) => {
|
|
23728
23532
|
const client = getActiveClient();
|
|
23729
|
-
client.log('
|
|
23730
|
-
const { data: payload } = await client.http.
|
|
23731
|
-
|
|
23732
|
-
|
|
23533
|
+
client.log('post/declinePost', postId);
|
|
23534
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/decline`);
|
|
23535
|
+
// fire virtual event
|
|
23536
|
+
if (payload.posts[0].targetType === 'community') {
|
|
23537
|
+
fireEvent('community.updated', payload);
|
|
23733
23538
|
}
|
|
23734
|
-
fireEvent('
|
|
23735
|
-
|
|
23539
|
+
fireEvent('post.declined', payload);
|
|
23540
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23541
|
+
const cachedAt = client.cache && Date.now();
|
|
23542
|
+
if (client.cache)
|
|
23543
|
+
ingestInCache(data, { cachedAt });
|
|
23544
|
+
return {
|
|
23545
|
+
data: LinkedObject.post(payload.posts.find(post => post.postId === postId)),
|
|
23546
|
+
cachedAt,
|
|
23547
|
+
};
|
|
23736
23548
|
};
|
|
23737
23549
|
/* end_public_function */
|
|
23738
23550
|
|
|
23739
23551
|
/* begin_public_function
|
|
23740
|
-
id:
|
|
23552
|
+
id: post.flag
|
|
23741
23553
|
*/
|
|
23742
23554
|
/**
|
|
23743
23555
|
* ```js
|
|
23744
|
-
* import {
|
|
23745
|
-
* const
|
|
23556
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
23557
|
+
* const flagged = await PostRepository.flagPost(postId, reason)
|
|
23746
23558
|
* ```
|
|
23747
23559
|
*
|
|
23748
|
-
* @param
|
|
23749
|
-
* @
|
|
23560
|
+
* @param postId of the post to flag
|
|
23561
|
+
* @param reason the reason to flag the post
|
|
23562
|
+
* @returns a boolean
|
|
23750
23563
|
*
|
|
23751
|
-
* @category
|
|
23564
|
+
* @category Post API
|
|
23752
23565
|
* @async
|
|
23753
23566
|
* */
|
|
23754
|
-
const
|
|
23755
|
-
const client = getActiveClient();
|
|
23756
|
-
client.log('comment/isCommentFlaggedByMe', commentId);
|
|
23757
|
-
const { data: { result }, } = await client.http.get(`/api/v3/comments/${commentId}/isflagbyme`);
|
|
23758
|
-
return result;
|
|
23759
|
-
};
|
|
23760
|
-
/* end_public_function */
|
|
23761
|
-
|
|
23762
|
-
const getComment$1 = async (commentId) => {
|
|
23763
|
-
const client = getActiveClient();
|
|
23764
|
-
client.log('comment/getComment', commentId);
|
|
23765
|
-
isInTombstone('comment', commentId);
|
|
23766
|
-
let data;
|
|
23767
|
-
try {
|
|
23768
|
-
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
23769
|
-
const response = await client.http.get(`/api/v3/comments/${encodeURIComponent(commentId)}`);
|
|
23770
|
-
data = response.data;
|
|
23771
|
-
}
|
|
23772
|
-
catch (error) {
|
|
23773
|
-
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
23774
|
-
pushToTombstone('comment', commentId);
|
|
23775
|
-
}
|
|
23776
|
-
throw error;
|
|
23777
|
-
}
|
|
23778
|
-
const cachedAt = client.cache && Date.now();
|
|
23779
|
-
if (client.cache)
|
|
23780
|
-
ingestInCache(data, { cachedAt });
|
|
23781
|
-
const { comments } = data;
|
|
23782
|
-
return {
|
|
23783
|
-
data: comments.find(comment => comment.commentId === commentId),
|
|
23784
|
-
cachedAt,
|
|
23785
|
-
};
|
|
23786
|
-
};
|
|
23787
|
-
getComment$1.locally = (commentId) => {
|
|
23567
|
+
const flagPost = async (postId, reason) => {
|
|
23788
23568
|
const client = getActiveClient();
|
|
23789
|
-
client.log('
|
|
23790
|
-
|
|
23791
|
-
|
|
23792
|
-
const
|
|
23793
|
-
|
|
23794
|
-
|
|
23795
|
-
return {
|
|
23796
|
-
data: cached.data,
|
|
23797
|
-
cachedAt: cached.cachedAt,
|
|
23569
|
+
client.log('post/flagPost', postId);
|
|
23570
|
+
const isPredefinedReason = reason &&
|
|
23571
|
+
Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
|
|
23572
|
+
const body = {
|
|
23573
|
+
reason: reason && isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
|
|
23574
|
+
detail: reason && !isPredefinedReason ? reason : '',
|
|
23798
23575
|
};
|
|
23576
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
|
|
23577
|
+
if (client.cache) {
|
|
23578
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
23579
|
+
}
|
|
23580
|
+
fireEvent('post.flagged', payload);
|
|
23581
|
+
return !!payload;
|
|
23799
23582
|
};
|
|
23583
|
+
/* end_public_function */
|
|
23800
23584
|
|
|
23585
|
+
/* begin_public_function
|
|
23586
|
+
id: post.unflag
|
|
23587
|
+
*/
|
|
23801
23588
|
/**
|
|
23802
23589
|
* ```js
|
|
23803
|
-
* import {
|
|
23804
|
-
* const
|
|
23805
|
-
* // ...
|
|
23806
|
-
* })
|
|
23590
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
23591
|
+
* const unflagged = await PostRepository.unflagPost(postId)
|
|
23807
23592
|
* ```
|
|
23808
23593
|
*
|
|
23809
|
-
*
|
|
23810
|
-
*
|
|
23811
|
-
* @param callback The function to call when the event was fired
|
|
23812
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
23594
|
+
* @param postId of the post to unflag
|
|
23595
|
+
* @returns the unflag post result
|
|
23813
23596
|
*
|
|
23814
|
-
* @category
|
|
23815
|
-
|
|
23816
|
-
|
|
23597
|
+
* @category Post API
|
|
23598
|
+
* @async
|
|
23599
|
+
* */
|
|
23600
|
+
const unflagPost = async (postId) => {
|
|
23601
|
+
const client = getActiveClient();
|
|
23602
|
+
client.log('post/unflagPost', postId);
|
|
23603
|
+
const { data: payload } = await client.http.delete(`/api/v3/posts/${encodeURIComponent(postId)}/unflag`);
|
|
23604
|
+
if (client.cache) {
|
|
23605
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
23606
|
+
}
|
|
23607
|
+
fireEvent('post.unflagged', payload);
|
|
23608
|
+
return !!payload;
|
|
23609
|
+
};
|
|
23610
|
+
/* end_public_function */
|
|
23817
23611
|
|
|
23612
|
+
/* begin_public_function
|
|
23613
|
+
id: post.check_flag_by_me
|
|
23614
|
+
*/
|
|
23818
23615
|
/**
|
|
23819
23616
|
* ```js
|
|
23820
|
-
* import {
|
|
23821
|
-
* const
|
|
23822
|
-
* // ...
|
|
23823
|
-
* })
|
|
23617
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
23618
|
+
* const isReported = await PostRepository.isPostFlaggedByMe('post', postId)
|
|
23824
23619
|
* ```
|
|
23825
23620
|
*
|
|
23826
|
-
*
|
|
23827
|
-
*
|
|
23828
|
-
* @param callback The function to call when the event was fired
|
|
23829
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
23621
|
+
* @param postId of the post to check if flagged by current user
|
|
23622
|
+
* @returns `true` if the post is flagged by me, `false` if doesn't.
|
|
23830
23623
|
*
|
|
23831
|
-
* @category
|
|
23832
|
-
|
|
23833
|
-
|
|
23624
|
+
* @category Post API
|
|
23625
|
+
* @async
|
|
23626
|
+
* */
|
|
23627
|
+
const isPostFlaggedByMe = async (postId) => {
|
|
23834
23628
|
const client = getActiveClient();
|
|
23835
|
-
|
|
23836
|
-
|
|
23837
|
-
|
|
23838
|
-
}
|
|
23839
|
-
else {
|
|
23840
|
-
upsertInCache(['comment', 'get', comment.commentId], comment);
|
|
23841
|
-
callback(commentLinkedObject(comment));
|
|
23842
|
-
}
|
|
23843
|
-
};
|
|
23844
|
-
return createEventSubscriber(client, 'local.comment.addReaction', 'local.comment.addReaction', filter);
|
|
23629
|
+
client.log('post/isPostFlaggedByMe', postId);
|
|
23630
|
+
const { data: { result }, } = await client.http.get(`/api/v3/posts/${postId}/isflagbyme`);
|
|
23631
|
+
return result;
|
|
23845
23632
|
};
|
|
23633
|
+
/* end_public_function */
|
|
23846
23634
|
|
|
23635
|
+
/* begin_public_function
|
|
23636
|
+
id: post.create.clip_post
|
|
23637
|
+
*/
|
|
23847
23638
|
/**
|
|
23848
23639
|
* ```js
|
|
23849
|
-
* import {
|
|
23850
|
-
* const
|
|
23851
|
-
*
|
|
23852
|
-
*
|
|
23640
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
23641
|
+
* const created = await PostRepository.createClipPost({
|
|
23642
|
+
* targetType: 'user',
|
|
23643
|
+
* targetId: 'foobar',
|
|
23644
|
+
* dataType: 'clip',
|
|
23645
|
+
* data: { text: 'hello world' },
|
|
23646
|
+
* attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
|
|
23647
|
+
* }))
|
|
23853
23648
|
* ```
|
|
23854
23649
|
*
|
|
23855
|
-
*
|
|
23650
|
+
* Creates an {@link Amity.Post}
|
|
23856
23651
|
*
|
|
23857
|
-
* @param
|
|
23858
|
-
* @returns
|
|
23652
|
+
* @param bundle The data necessary to create a new {@link Amity.Post}
|
|
23653
|
+
* @returns The newly created {@link Amity.Post}
|
|
23859
23654
|
*
|
|
23860
|
-
* @category
|
|
23655
|
+
* @category Post API
|
|
23656
|
+
* @async
|
|
23861
23657
|
*/
|
|
23862
|
-
const
|
|
23658
|
+
const createClipPost = async (bundle) => {
|
|
23863
23659
|
const client = getActiveClient();
|
|
23864
|
-
|
|
23865
|
-
|
|
23866
|
-
|
|
23867
|
-
|
|
23868
|
-
|
|
23869
|
-
|
|
23870
|
-
|
|
23871
|
-
|
|
23660
|
+
client.log('post/createPost', bundle);
|
|
23661
|
+
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
23662
|
+
fireEvent('post.created', payload);
|
|
23663
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23664
|
+
const cachedAt = client.cache && Date.now();
|
|
23665
|
+
if (client.cache)
|
|
23666
|
+
ingestInCache(data, { cachedAt });
|
|
23667
|
+
const { posts } = data;
|
|
23668
|
+
return {
|
|
23669
|
+
data: LinkedObject.post(posts[0]),
|
|
23670
|
+
cachedAt,
|
|
23872
23671
|
};
|
|
23873
|
-
return createEventSubscriber(client, 'local.comment.removeReaction', 'local.comment.removeReaction', filter);
|
|
23874
23672
|
};
|
|
23673
|
+
/* end_public_function */
|
|
23875
23674
|
|
|
23876
|
-
/* begin_public_function
|
|
23877
|
-
id: comment.get
|
|
23878
|
-
*/
|
|
23879
23675
|
/**
|
|
23880
23676
|
* ```js
|
|
23881
|
-
* import {
|
|
23882
|
-
*
|
|
23883
|
-
* let comment;
|
|
23884
|
-
*
|
|
23885
|
-
* const unsub = CommentRepository.getComment(commentId, response => {
|
|
23886
|
-
* comment = response.data;
|
|
23887
|
-
* });
|
|
23677
|
+
* import { searchPostsByHashtag } from '@amityco/ts-sdk'
|
|
23678
|
+
* const { data: posts, prevPage, nextPage } = await searchPostsByHashtag({ hashtags: ['amity'], limit: 10 });
|
|
23888
23679
|
* ```
|
|
23889
23680
|
*
|
|
23890
|
-
*
|
|
23681
|
+
* Queries a paginable list of {@link Amity.Post} objects
|
|
23891
23682
|
*
|
|
23892
|
-
* @param
|
|
23893
|
-
* @
|
|
23894
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
|
|
23683
|
+
* @param query The query parameters
|
|
23684
|
+
* @returns posts
|
|
23895
23685
|
*
|
|
23896
|
-
* @category
|
|
23686
|
+
* @category Post API
|
|
23687
|
+
* @async
|
|
23897
23688
|
*/
|
|
23898
|
-
const
|
|
23899
|
-
|
|
23900
|
-
|
|
23901
|
-
|
|
23902
|
-
|
|
23903
|
-
|
|
23904
|
-
|
|
23905
|
-
|
|
23906
|
-
|
|
23907
|
-
|
|
23908
|
-
|
|
23909
|
-
|
|
23689
|
+
const getPostsByHashtag = async (query) => {
|
|
23690
|
+
const client = getActiveClient();
|
|
23691
|
+
client.log('post/queryByHashtag', query);
|
|
23692
|
+
const { page, limit = 10 } = query, params = __rest(query, ["page", "limit"]);
|
|
23693
|
+
const { dataTypes, matchingOnlyParentPost, hashtags } = params;
|
|
23694
|
+
const options = (() => {
|
|
23695
|
+
if (page)
|
|
23696
|
+
return { token: page };
|
|
23697
|
+
if (limit)
|
|
23698
|
+
return { limit };
|
|
23699
|
+
return undefined;
|
|
23700
|
+
})();
|
|
23701
|
+
// API-FIX: parameters should be querystring. (1)
|
|
23702
|
+
// API-FIX: backend should answer Amity.Response (2)
|
|
23703
|
+
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<Amity.PostPayload>>>(
|
|
23704
|
+
const { data } = await client.http.get(`/api/v5/posts`, {
|
|
23705
|
+
params: Object.assign(Object.assign({}, params), { hashtags,
|
|
23706
|
+
/*
|
|
23707
|
+
* when creating post like image, file, video BE will create 2 posts
|
|
23708
|
+
* 1. parent post to store text with dataType=text
|
|
23709
|
+
* 2. child post to store dataTypes post data
|
|
23710
|
+
*
|
|
23711
|
+
* By default, BE queries only parent post
|
|
23712
|
+
*/
|
|
23713
|
+
matchingOnlyParentPost: matchingOnlyParentPost !== null && matchingOnlyParentPost !== void 0 ? matchingOnlyParentPost : !(dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.length), options }),
|
|
23714
|
+
});
|
|
23715
|
+
// API-FIX: backend should answer Amity.Response (2)
|
|
23716
|
+
// const { paging, posts } = unwrapPayload(data)
|
|
23717
|
+
// unpacking
|
|
23718
|
+
const { paging } = data, payload = __rest(data, ["paging"]);
|
|
23719
|
+
const paperedPayload = prepareMembershipPayload(payload, 'communityUsers');
|
|
23720
|
+
const { posts } = payload;
|
|
23721
|
+
const cachedAt = client.cache && Date.now();
|
|
23722
|
+
if (client.cache) {
|
|
23723
|
+
ingestInCache(paperedPayload, { cachedAt });
|
|
23724
|
+
const cacheKey = ['post', 'query', Object.assign(Object.assign({}, params), { options })];
|
|
23725
|
+
pushToCache(cacheKey, { posts: posts.map(getResolver('post')), paging });
|
|
23726
|
+
}
|
|
23727
|
+
return { data: posts.map(LinkedObject.post), cachedAt, paging };
|
|
23910
23728
|
};
|
|
23911
|
-
/* end_public_function */
|
|
23912
23729
|
|
|
23913
|
-
|
|
23914
|
-
|
|
23915
|
-
|
|
23916
|
-
|
|
23917
|
-
|
|
23918
|
-
|
|
23919
|
-
|
|
23920
|
-
|
|
23921
|
-
|
|
23730
|
+
/* begin_public_function
|
|
23731
|
+
id: comment.get_by_ids
|
|
23732
|
+
*/
|
|
23733
|
+
/**
|
|
23734
|
+
* ```js
|
|
23735
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23736
|
+
* const comments = await CommentRepository.getCommentByIds(['foo', 'bar'])
|
|
23737
|
+
* ```
|
|
23738
|
+
*
|
|
23739
|
+
* Fetches a collection of {@link Amity.Comment} objects
|
|
23740
|
+
*
|
|
23741
|
+
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
23742
|
+
* @returns the associated collection of {@link Amity.Comment} objects
|
|
23743
|
+
*
|
|
23744
|
+
* @category Comment API
|
|
23745
|
+
* @async
|
|
23746
|
+
*/
|
|
23747
|
+
const getCommentByIds = async (commentIds) => {
|
|
23748
|
+
const client = getActiveClient();
|
|
23749
|
+
client.log('comment/getCommentByIds', commentIds);
|
|
23750
|
+
const encodedCommentIds = commentIds.map(commentId => encodeURIComponent(commentId));
|
|
23751
|
+
let data;
|
|
23752
|
+
try {
|
|
23753
|
+
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
23754
|
+
const response = await client.http.get(`/api/v3/comments/list`, {
|
|
23755
|
+
params: { commentIds: encodedCommentIds },
|
|
23922
23756
|
});
|
|
23923
|
-
|
|
23924
|
-
}
|
|
23925
|
-
}
|
|
23926
|
-
|
|
23927
|
-
var EnumCommentActions;
|
|
23928
|
-
(function (EnumCommentActions) {
|
|
23929
|
-
EnumCommentActions["OnCommentCreated"] = "onCommentCreated";
|
|
23930
|
-
EnumCommentActions["OnCommentUpdated"] = "onCommentUpdated";
|
|
23931
|
-
EnumCommentActions["OnCommentDeleted"] = "onCommentDeleted";
|
|
23932
|
-
EnumCommentActions["OnCommentFlagged"] = "onCommentFlagged";
|
|
23933
|
-
EnumCommentActions["OnCommentUnflagged"] = "onCommentUnflagged";
|
|
23934
|
-
EnumCommentActions["OnCommentReactionAdded"] = "onCommentReactionAdded";
|
|
23935
|
-
EnumCommentActions["OnCommentReactionRemoved"] = "onCommentReactionRemoved";
|
|
23936
|
-
})(EnumCommentActions || (EnumCommentActions = {}));
|
|
23937
|
-
|
|
23938
|
-
class CommentQueryStreamController extends QueryStreamController {
|
|
23939
|
-
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
23940
|
-
super(query, cacheKey);
|
|
23941
|
-
this.notifyChange = notifyChange;
|
|
23942
|
-
this.preparePayload = preparePayload;
|
|
23943
|
-
}
|
|
23944
|
-
async saveToMainDB(response) {
|
|
23945
|
-
const processedPayload = await this.preparePayload(response);
|
|
23946
|
-
const client = getActiveClient();
|
|
23947
|
-
const cachedAt = client.cache && Date.now();
|
|
23948
|
-
if (client.cache) {
|
|
23949
|
-
ingestInCache(processedPayload, { cachedAt });
|
|
23950
|
-
}
|
|
23951
|
-
}
|
|
23952
|
-
appendToQueryStream(response, direction, refresh = false) {
|
|
23953
|
-
var _a, _b;
|
|
23954
|
-
if (refresh) {
|
|
23955
|
-
pushToCache(this.cacheKey, {
|
|
23956
|
-
data: response.comments.map(getResolver('comment')),
|
|
23957
|
-
});
|
|
23958
|
-
}
|
|
23959
|
-
else {
|
|
23960
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
23961
|
-
const comments = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
23962
|
-
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...comments, ...response.comments.map(getResolver('comment'))])] }));
|
|
23963
|
-
}
|
|
23757
|
+
data = response.data;
|
|
23964
23758
|
}
|
|
23965
|
-
|
|
23966
|
-
|
|
23967
|
-
|
|
23968
|
-
|
|
23969
|
-
if (this.query.referenceId !== comment.referenceId ||
|
|
23970
|
-
this.query.referenceType !== comment.referenceType ||
|
|
23971
|
-
!collection) {
|
|
23972
|
-
return;
|
|
23973
|
-
}
|
|
23974
|
-
if (this.query.parentId && this.query.parentId !== comment.parentId) {
|
|
23975
|
-
return;
|
|
23976
|
-
}
|
|
23977
|
-
if (!this.query.parentId && comment.parentId) {
|
|
23978
|
-
return;
|
|
23979
|
-
}
|
|
23980
|
-
if (action === EnumCommentActions.OnCommentCreated) {
|
|
23981
|
-
collection.data = [...new Set([comment.commentId, ...collection.data])];
|
|
23759
|
+
catch (error) {
|
|
23760
|
+
commentIds.forEach(commentId => {
|
|
23761
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
23762
|
+
pushToTombstone('comment', commentId);
|
|
23982
23763
|
}
|
|
23983
|
-
|
|
23984
|
-
|
|
23985
|
-
};
|
|
23986
|
-
}
|
|
23987
|
-
subscribeRTE(createSubscriber) {
|
|
23988
|
-
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
23764
|
+
});
|
|
23765
|
+
throw error;
|
|
23989
23766
|
}
|
|
23990
|
-
|
|
23991
|
-
|
|
23767
|
+
const cachedAt = client.cache && Date.now();
|
|
23768
|
+
if (client.cache)
|
|
23769
|
+
ingestInCache(data, { cachedAt });
|
|
23770
|
+
return {
|
|
23771
|
+
data: data.comments.map(comment => LinkedObject.comment(comment)),
|
|
23772
|
+
cachedAt,
|
|
23773
|
+
};
|
|
23774
|
+
};
|
|
23775
|
+
/* end_public_function */
|
|
23992
23776
|
/**
|
|
23993
23777
|
* ```js
|
|
23994
|
-
* import {
|
|
23995
|
-
* const
|
|
23996
|
-
* // ...
|
|
23997
|
-
* })
|
|
23778
|
+
* import { getCommentByIds } from '@amityco/ts-sdk'
|
|
23779
|
+
* const comments = getCommentByIds.locally(['foo', 'bar'])
|
|
23998
23780
|
* ```
|
|
23999
23781
|
*
|
|
24000
|
-
*
|
|
23782
|
+
* Fetches a collection of {@link Amity.Comment} objects from cache
|
|
24001
23783
|
*
|
|
24002
|
-
* @param
|
|
24003
|
-
* @returns
|
|
23784
|
+
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
23785
|
+
* @returns the associated collection of {@link Amity.Comment} objects
|
|
24004
23786
|
*
|
|
24005
|
-
* @category Comment
|
|
23787
|
+
* @category Comment API
|
|
24006
23788
|
*/
|
|
24007
|
-
|
|
24008
|
-
|
|
23789
|
+
getCommentByIds.locally = (commentIds) => {
|
|
23790
|
+
var _a;
|
|
23791
|
+
const client = getActiveClient();
|
|
23792
|
+
client.log('comment/getCommentByIds.locally', commentIds);
|
|
23793
|
+
if (!client.cache)
|
|
23794
|
+
return;
|
|
23795
|
+
const cached = commentIds
|
|
23796
|
+
.map(commentId => pullFromCache(['comment', 'get', commentId]))
|
|
23797
|
+
.filter(Boolean);
|
|
23798
|
+
const comments = cached.map(({ data }) => data);
|
|
23799
|
+
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
23800
|
+
if ((cached === null || cached === void 0 ? void 0 : cached.length) < commentIds.length)
|
|
23801
|
+
return;
|
|
23802
|
+
return {
|
|
23803
|
+
data: comments.map(comment => LinkedObject.comment(comment)),
|
|
23804
|
+
cachedAt: oldest.cachedAt,
|
|
23805
|
+
};
|
|
24009
23806
|
};
|
|
24010
23807
|
|
|
24011
|
-
|
|
24012
|
-
|
|
24013
|
-
|
|
24014
|
-
|
|
24015
|
-
|
|
24016
|
-
|
|
24017
|
-
|
|
24018
|
-
|
|
24019
|
-
|
|
24020
|
-
|
|
24021
|
-
|
|
24022
|
-
|
|
24023
|
-
|
|
24024
|
-
|
|
24025
|
-
|
|
24026
|
-
|
|
24027
|
-
|
|
24028
|
-
|
|
23808
|
+
/* begin_public_function
|
|
23809
|
+
id: comment.create
|
|
23810
|
+
*/
|
|
23811
|
+
/**
|
|
23812
|
+
* ```js
|
|
23813
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23814
|
+
* const newComment = await CommentRepository.createComment(bundle)
|
|
23815
|
+
* ```
|
|
23816
|
+
*
|
|
23817
|
+
* Creates an {@link Amity.Comment}
|
|
23818
|
+
*
|
|
23819
|
+
* @param bundle The data necessary to create a new {@link Amity.Comment}
|
|
23820
|
+
* @returns The newly created {@link Amity.Comment}
|
|
23821
|
+
*
|
|
23822
|
+
* @category Comment API
|
|
23823
|
+
* @async
|
|
23824
|
+
*/
|
|
23825
|
+
const createComment = async (bundle) => {
|
|
23826
|
+
var _a;
|
|
23827
|
+
const client = getActiveClient();
|
|
23828
|
+
client.log('comment/createComment', bundle);
|
|
23829
|
+
const { data } = await client.http.post('/api/v3/comments', bundle);
|
|
23830
|
+
const { comments } = data;
|
|
23831
|
+
// BE always returns an array of comments If it got record 0 from BE it might have a problem on creation logic
|
|
23832
|
+
if (comments.length === 0)
|
|
23833
|
+
throw new Error('Comment not created');
|
|
23834
|
+
const cachedAt = client.cache && Date.now();
|
|
23835
|
+
if (client.cache)
|
|
23836
|
+
ingestInCache(data, { cachedAt });
|
|
23837
|
+
if (['post', 'content'].includes(bundle.referenceType)) {
|
|
23838
|
+
const post = (_a = pullFromCache(['post', 'get', bundle.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
23839
|
+
if (post) {
|
|
23840
|
+
post.commentsCount += 1;
|
|
23841
|
+
fireEvent('local.post.updated', {
|
|
23842
|
+
posts: [post],
|
|
23843
|
+
categories: [],
|
|
23844
|
+
comments: [],
|
|
23845
|
+
communities: [],
|
|
23846
|
+
communityUsers: data.communityUsers,
|
|
23847
|
+
feeds: [],
|
|
23848
|
+
files: data.files,
|
|
23849
|
+
postChildren: [],
|
|
23850
|
+
users: data.users,
|
|
23851
|
+
videoStreamings: [],
|
|
24029
23852
|
});
|
|
24030
23853
|
}
|
|
24031
23854
|
}
|
|
24032
|
-
|
|
24033
|
-
|
|
24034
|
-
|
|
24035
|
-
|
|
24036
|
-
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
24037
|
-
}
|
|
24038
|
-
startSubscription() {
|
|
24039
|
-
return this.queryStreamController.subscribeRTE([
|
|
24040
|
-
{ fn: onCommentCreatedLocal, action: EnumCommentActions.OnCommentCreated },
|
|
24041
|
-
{ fn: onCommentDeleteLocal, action: EnumCommentActions.OnCommentDeleted },
|
|
24042
|
-
{ fn: onCommentCreated, action: EnumCommentActions.OnCommentCreated },
|
|
24043
|
-
{ fn: onCommentUpdated, action: EnumCommentActions.OnCommentUpdated },
|
|
24044
|
-
{ fn: onCommentDeleted, action: EnumCommentActions.OnCommentDeleted },
|
|
24045
|
-
{ fn: onCommentFlagged, action: EnumCommentActions.OnCommentFlagged },
|
|
24046
|
-
{ fn: onCommentUnflagged, action: EnumCommentActions.OnCommentUnflagged },
|
|
24047
|
-
{ fn: onCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
24048
|
-
{ fn: onCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
24049
|
-
{ fn: onLocalCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
24050
|
-
{ fn: onLocalCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
23855
|
+
else if (bundle.referenceType === 'story') {
|
|
23856
|
+
const storyIndex = pullFromCache([
|
|
23857
|
+
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
23858
|
+
bundle.referenceId,
|
|
24051
23859
|
]);
|
|
24052
|
-
|
|
24053
|
-
|
|
24054
|
-
|
|
24055
|
-
|
|
24056
|
-
|
|
24057
|
-
|
|
24058
|
-
|
|
24059
|
-
|
|
24060
|
-
|
|
24061
|
-
|
|
24062
|
-
|
|
24063
|
-
|
|
24064
|
-
|
|
24065
|
-
|
|
24066
|
-
|
|
24067
|
-
|
|
24068
|
-
|
|
24069
|
-
error,
|
|
24070
|
-
});
|
|
24071
|
-
}
|
|
24072
|
-
applyFilter(data) {
|
|
24073
|
-
let comments = data;
|
|
24074
|
-
if (!this.query.includeDeleted) {
|
|
24075
|
-
comments = filterByPropEquality(comments, 'isDeleted', false);
|
|
24076
|
-
}
|
|
24077
|
-
if (this.query.parentId) {
|
|
24078
|
-
comments = comments.filter(comment => comment.parentId === this.query.parentId);
|
|
24079
|
-
}
|
|
24080
|
-
if (typeof this.query.hasFlag === 'boolean') {
|
|
24081
|
-
if (this.query.hasFlag) {
|
|
24082
|
-
comments = comments.filter(comment => comment.hashFlag != null);
|
|
24083
|
-
}
|
|
24084
|
-
else {
|
|
24085
|
-
comments = comments.filter(comment => comment.hashFlag == null);
|
|
24086
|
-
}
|
|
24087
|
-
}
|
|
24088
|
-
if (this.query.dataTypes) {
|
|
24089
|
-
if (this.query.dataTypes.matchType === 'exact') {
|
|
24090
|
-
comments = comments.filter(comment => {
|
|
24091
|
-
var _a, _b;
|
|
24092
|
-
const sortedDataTypesQueryValue = ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.sort()) || [];
|
|
24093
|
-
const sortedDataTypesCommentValue = ((_b = comment.dataTypes) === null || _b === void 0 ? void 0 : _b.sort()) || [];
|
|
24094
|
-
if (sortedDataTypesCommentValue.length !== sortedDataTypesQueryValue.length) {
|
|
24095
|
-
return false;
|
|
24096
|
-
}
|
|
24097
|
-
return sortedDataTypesQueryValue.every((value, index) => value === sortedDataTypesCommentValue[index]);
|
|
23860
|
+
if (storyIndex === null || storyIndex === void 0 ? void 0 : storyIndex.data) {
|
|
23861
|
+
const cacheStory = pullFromCache([
|
|
23862
|
+
"story" /* STORY_KEY_CACHE.STORY */,
|
|
23863
|
+
'get',
|
|
23864
|
+
storyIndex.data,
|
|
23865
|
+
]);
|
|
23866
|
+
if (cacheStory === null || cacheStory === void 0 ? void 0 : cacheStory.data) {
|
|
23867
|
+
fireEvent('story.updated', {
|
|
23868
|
+
stories: [
|
|
23869
|
+
Object.assign(Object.assign({}, cacheStory.data), { commentsCount: cacheStory.data.commentsCount + 1, comments: [...new Set([...cacheStory.data.comments, comments[0].commentId])] }),
|
|
23870
|
+
],
|
|
23871
|
+
categories: [],
|
|
23872
|
+
comments,
|
|
23873
|
+
communities: [],
|
|
23874
|
+
communityUsers: data.communityUsers,
|
|
23875
|
+
files: data.files,
|
|
23876
|
+
users: data.users,
|
|
24098
23877
|
});
|
|
24099
23878
|
}
|
|
24100
|
-
if (this.query.dataTypes.matchType === 'any') {
|
|
24101
|
-
comments = comments.filter(comment => { var _a; return (_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.some(value => { var _a; return (_a = comment.dataTypes) === null || _a === void 0 ? void 0 : _a.includes(value); }); });
|
|
24102
|
-
}
|
|
24103
|
-
}
|
|
24104
|
-
switch (this.query.sortBy) {
|
|
24105
|
-
case 'firstCreated':
|
|
24106
|
-
comments = comments.sort(sortByFirstCreated);
|
|
24107
|
-
break;
|
|
24108
|
-
case 'lastCreated':
|
|
24109
|
-
default:
|
|
24110
|
-
comments = comments.sort(sortByLastCreated);
|
|
24111
|
-
break;
|
|
24112
23879
|
}
|
|
24113
|
-
return comments;
|
|
24114
23880
|
}
|
|
24115
|
-
|
|
23881
|
+
fireEvent('local.comment.created', data);
|
|
23882
|
+
return {
|
|
23883
|
+
data: LinkedObject.comment(comments[0]),
|
|
23884
|
+
cachedAt,
|
|
23885
|
+
};
|
|
23886
|
+
};
|
|
23887
|
+
/* end_public_function */
|
|
24116
23888
|
|
|
24117
23889
|
/* begin_public_function
|
|
24118
|
-
id: comment.
|
|
23890
|
+
id: comment.update_comment
|
|
24119
23891
|
*/
|
|
24120
23892
|
/**
|
|
24121
23893
|
* ```js
|
|
24122
|
-
* import {
|
|
24123
|
-
*
|
|
24124
|
-
*
|
|
24125
|
-
*
|
|
24126
|
-
* referenceType: Amity.InternalComment['referenceType'];
|
|
24127
|
-
* referenceId: Amity.InternalComment['referenceId'];
|
|
24128
|
-
* }, response => merge(comments, response.data))
|
|
23894
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23895
|
+
* const updated = await CommentRepository.updateComment(commentId, {
|
|
23896
|
+
* data: { text: 'hello world' }
|
|
23897
|
+
* })
|
|
24129
23898
|
* ```
|
|
24130
23899
|
*
|
|
24131
|
-
*
|
|
23900
|
+
* Updates an {@link Amity.Comment}
|
|
24132
23901
|
*
|
|
24133
|
-
* @param
|
|
24134
|
-
* @param
|
|
24135
|
-
* @
|
|
24136
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
23902
|
+
* @param commentId The ID of the {@link Amity.Comment} to edit
|
|
23903
|
+
* @param patch The patch data to apply
|
|
23904
|
+
* @returns the updated {@link Amity.Comment} object
|
|
24137
23905
|
*
|
|
24138
|
-
* @category
|
|
23906
|
+
* @category Comment API
|
|
23907
|
+
* @async
|
|
24139
23908
|
*/
|
|
24140
|
-
const
|
|
24141
|
-
const
|
|
24142
|
-
|
|
24143
|
-
|
|
24144
|
-
|
|
24145
|
-
|
|
24146
|
-
|
|
24147
|
-
|
|
24148
|
-
const
|
|
24149
|
-
|
|
24150
|
-
|
|
24151
|
-
|
|
24152
|
-
log(`getComments(tmpid: ${timestamp}) > dispose`);
|
|
24153
|
-
disposers.forEach(fn => fn());
|
|
23909
|
+
const updateComment = async (commentId, patch) => {
|
|
23910
|
+
const client = getActiveClient();
|
|
23911
|
+
client.log('user/updateComment', patch);
|
|
23912
|
+
const { data } = await client.http.put(`/api/v3/comments/${encodeURIComponent(commentId)}`, patch);
|
|
23913
|
+
const cachedAt = client.cache && Date.now();
|
|
23914
|
+
if (client.cache)
|
|
23915
|
+
ingestInCache(data, { cachedAt });
|
|
23916
|
+
fireEvent('comment.updated', data);
|
|
23917
|
+
const { comments } = data;
|
|
23918
|
+
return {
|
|
23919
|
+
data: LinkedObject.comment(comments.find(comment => comment.commentId === commentId)),
|
|
23920
|
+
cachedAt,
|
|
24154
23921
|
};
|
|
24155
23922
|
};
|
|
24156
23923
|
/* end_public_function */
|
|
24157
23924
|
|
|
24158
|
-
|
|
24159
|
-
|
|
24160
|
-
|
|
24161
|
-
|
|
24162
|
-
|
|
24163
|
-
|
|
24164
|
-
|
|
24165
|
-
|
|
24166
|
-
|
|
24167
|
-
|
|
24168
|
-
|
|
24169
|
-
|
|
24170
|
-
|
|
24171
|
-
|
|
24172
|
-
onCommentFlagged: onCommentFlagged,
|
|
24173
|
-
onCommentUnflagged: onCommentUnflagged,
|
|
24174
|
-
onCommentReactionAdded: onCommentReactionAdded,
|
|
24175
|
-
onCommentReactionRemoved: onCommentReactionRemoved,
|
|
24176
|
-
getComment: getComment,
|
|
24177
|
-
getComments: getComments
|
|
24178
|
-
});
|
|
23925
|
+
// Due to we have optimistic logic, we will use referenceId as a id in SDK instead of storyId
|
|
23926
|
+
const applyMissingField = (rawData, isCreated = false) => {
|
|
23927
|
+
const { storyId, referenceId } = rawData;
|
|
23928
|
+
if (!isCreated) {
|
|
23929
|
+
if (referenceId)
|
|
23930
|
+
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */ });
|
|
23931
|
+
}
|
|
23932
|
+
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */, referenceId: storyId });
|
|
23933
|
+
};
|
|
23934
|
+
const convertRawStoryToInternal = (data, isCreated = false) => {
|
|
23935
|
+
const { stories } = data;
|
|
23936
|
+
const storiesData = stories.map(story => applyMissingField(story, isCreated));
|
|
23937
|
+
return Object.assign(Object.assign({}, data), { stories: storiesData });
|
|
23938
|
+
};
|
|
24179
23939
|
|
|
24180
|
-
const
|
|
23940
|
+
const getStoryByStoryId$1 = async (storyId) => {
|
|
24181
23941
|
const client = getActiveClient();
|
|
24182
|
-
client.log('
|
|
24183
|
-
|
|
24184
|
-
|
|
23942
|
+
client.log('story/getStoryByStoryId', storyId);
|
|
23943
|
+
// Get story referenceId from cache
|
|
23944
|
+
const cacheReferenceId = pullFromCache([
|
|
23945
|
+
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
23946
|
+
storyId,
|
|
23947
|
+
]);
|
|
23948
|
+
if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
|
|
23949
|
+
const { data: referenceId } = cacheReferenceId;
|
|
23950
|
+
isInTombstone('story', referenceId);
|
|
23951
|
+
}
|
|
23952
|
+
let data;
|
|
24185
23953
|
try {
|
|
24186
|
-
|
|
24187
|
-
|
|
24188
|
-
payload = response.data;
|
|
23954
|
+
const response = await client.http.get(`/api/v4/stories/${storyId}`);
|
|
23955
|
+
data = convertRawStoryToInternal(response.data);
|
|
24189
23956
|
}
|
|
24190
23957
|
catch (error) {
|
|
24191
23958
|
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
24192
|
-
pushToTombstone('
|
|
23959
|
+
pushToTombstone('story', storyId);
|
|
24193
23960
|
}
|
|
24194
23961
|
throw error;
|
|
24195
23962
|
}
|
|
24196
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
24197
23963
|
const cachedAt = client.cache && Date.now();
|
|
24198
|
-
if (client.cache)
|
|
23964
|
+
if (client.cache) {
|
|
24199
23965
|
ingestInCache(data, { cachedAt });
|
|
24200
|
-
|
|
24201
|
-
const result = posts.find(post => post.postId === postId);
|
|
23966
|
+
}
|
|
24202
23967
|
return {
|
|
24203
|
-
data:
|
|
23968
|
+
data: data.stories[0],
|
|
24204
23969
|
cachedAt,
|
|
24205
23970
|
};
|
|
24206
23971
|
};
|
|
24207
|
-
|
|
23972
|
+
getStoryByStoryId$1.locally = (storyId) => {
|
|
24208
23973
|
const client = getActiveClient();
|
|
24209
|
-
client.log('
|
|
24210
|
-
|
|
24211
|
-
|
|
24212
|
-
|
|
24213
|
-
|
|
23974
|
+
client.log('story/getStorybyStoryId', storyId);
|
|
23975
|
+
// Get story referenceId from cache
|
|
23976
|
+
const cacheReferenceId = pullFromCache([
|
|
23977
|
+
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
23978
|
+
storyId,
|
|
23979
|
+
]);
|
|
23980
|
+
if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
|
|
23981
|
+
const { data: referenceId } = cacheReferenceId;
|
|
23982
|
+
isInTombstone('story', referenceId);
|
|
23983
|
+
}
|
|
23984
|
+
const cachedAt = client.cache && Date.now();
|
|
23985
|
+
const storyCache = pullFromCache(['story', 'get', storyId]);
|
|
23986
|
+
if (!storyCache)
|
|
24214
23987
|
return;
|
|
24215
23988
|
return {
|
|
24216
|
-
data:
|
|
24217
|
-
cachedAt
|
|
23989
|
+
data: storyCache.data,
|
|
23990
|
+
cachedAt,
|
|
24218
23991
|
};
|
|
24219
23992
|
};
|
|
24220
23993
|
|
|
23994
|
+
/* begin_public_function
|
|
23995
|
+
id: comment.soft_delete, comment.hard_delete
|
|
23996
|
+
*/
|
|
24221
23997
|
/**
|
|
24222
23998
|
* ```js
|
|
24223
|
-
* import {
|
|
24224
|
-
* const
|
|
24225
|
-
* // ...
|
|
24226
|
-
* })
|
|
24227
|
-
* ```
|
|
24228
|
-
*
|
|
24229
|
-
* Fired when a {@link Amity.InternalPost} has been updated
|
|
24230
|
-
*
|
|
24231
|
-
* @param callback The function to call when the event was fired
|
|
24232
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24233
|
-
*
|
|
24234
|
-
* @category Post Events
|
|
24235
|
-
*/
|
|
24236
|
-
const onPostUpdatedLocal = (callback) => createLocalPostEventSubscriber('local.post.updated', callback);
|
|
24237
|
-
|
|
24238
|
-
/**
|
|
24239
|
-
* ```js
|
|
24240
|
-
* import { onLocalPostReactionAdded } from '@amityco/ts-sdk'
|
|
24241
|
-
* const dispose = onPostReactionAdded(post => {
|
|
24242
|
-
* // ...
|
|
24243
|
-
* })
|
|
23999
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
24000
|
+
* const success = await CommentRepository.deleteComment('foobar')
|
|
24244
24001
|
* ```
|
|
24245
24002
|
*
|
|
24246
|
-
*
|
|
24003
|
+
* Deletes a {@link Amity.Comment}
|
|
24247
24004
|
*
|
|
24248
|
-
* @param
|
|
24249
|
-
* @
|
|
24005
|
+
* @param commentId The {@link Amity.Comment} ID to delete
|
|
24006
|
+
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
24250
24007
|
*
|
|
24251
|
-
* @category
|
|
24008
|
+
* @category Comment API
|
|
24009
|
+
* @async
|
|
24252
24010
|
*/
|
|
24253
|
-
const
|
|
24011
|
+
const deleteComment = async (commentId, permanent = false) => {
|
|
24012
|
+
var _a;
|
|
24254
24013
|
const client = getActiveClient();
|
|
24255
|
-
const
|
|
24256
|
-
|
|
24257
|
-
|
|
24258
|
-
|
|
24259
|
-
|
|
24260
|
-
|
|
24261
|
-
|
|
24014
|
+
const comment = await getComment$2(commentId);
|
|
24015
|
+
// API-FIX: This endpoint has not been implemented yet.
|
|
24016
|
+
await client.http.delete(`/api/v4/comments/${encodeURIComponent(commentId)}`, {
|
|
24017
|
+
params: {
|
|
24018
|
+
commentId,
|
|
24019
|
+
permanent,
|
|
24020
|
+
},
|
|
24021
|
+
});
|
|
24022
|
+
// to support hard deletion
|
|
24023
|
+
const deleted = Object.assign(Object.assign({}, comment.data), { isDeleted: true });
|
|
24024
|
+
if (comment.data.referenceType === 'story') {
|
|
24025
|
+
const story = await getStoryByStoryId$1(comment.data.referenceId);
|
|
24026
|
+
fireEvent('local.story.updated', {
|
|
24027
|
+
stories: [story.data],
|
|
24028
|
+
categories: [],
|
|
24029
|
+
comments: [],
|
|
24030
|
+
communities: [],
|
|
24031
|
+
communityUsers: [],
|
|
24032
|
+
files: [],
|
|
24033
|
+
users: [],
|
|
24034
|
+
});
|
|
24035
|
+
}
|
|
24036
|
+
else {
|
|
24037
|
+
const post = (_a = pullFromCache(['post', 'get', comment.data.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
24038
|
+
if (post) {
|
|
24039
|
+
let removeCount;
|
|
24040
|
+
if (!deleted.parentId) {
|
|
24041
|
+
// NOTE: delete the parent comment will remove all children comments
|
|
24042
|
+
removeCount = deleted.childrenNumber + 1;
|
|
24043
|
+
}
|
|
24044
|
+
else
|
|
24045
|
+
removeCount = 1;
|
|
24046
|
+
post.commentsCount -= removeCount;
|
|
24047
|
+
fireEvent('local.post.updated', {
|
|
24048
|
+
posts: [post],
|
|
24049
|
+
categories: [],
|
|
24050
|
+
comments: [],
|
|
24051
|
+
communities: [],
|
|
24052
|
+
communityUsers: [],
|
|
24053
|
+
feeds: [],
|
|
24054
|
+
files: [],
|
|
24055
|
+
postChildren: [],
|
|
24056
|
+
users: [],
|
|
24057
|
+
videoStreamings: [],
|
|
24058
|
+
});
|
|
24262
24059
|
}
|
|
24263
|
-
}
|
|
24264
|
-
|
|
24060
|
+
}
|
|
24061
|
+
fireEvent('local.comment.deleted', {
|
|
24062
|
+
comments: [deleted],
|
|
24063
|
+
commentChildren: [],
|
|
24064
|
+
files: [],
|
|
24065
|
+
users: [],
|
|
24066
|
+
communityUsers: [],
|
|
24067
|
+
});
|
|
24068
|
+
if (permanent) {
|
|
24069
|
+
scheduleTask(() => pushToTombstone('comment', commentId));
|
|
24070
|
+
}
|
|
24071
|
+
else {
|
|
24072
|
+
upsertInCache(['comment', 'get', commentId], { isDeleted: true });
|
|
24073
|
+
}
|
|
24074
|
+
return deleted;
|
|
24265
24075
|
};
|
|
24076
|
+
/* end_public_function */
|
|
24266
24077
|
|
|
24078
|
+
/* begin_public_function
|
|
24079
|
+
id: comment.soft_delete
|
|
24080
|
+
*/
|
|
24267
24081
|
/**
|
|
24268
24082
|
* ```js
|
|
24269
|
-
* import {
|
|
24270
|
-
* const
|
|
24271
|
-
* // ...
|
|
24272
|
-
* })
|
|
24083
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
24084
|
+
* const success = await CommentRepository.softDeleteComment('foobar')
|
|
24273
24085
|
* ```
|
|
24274
24086
|
*
|
|
24275
|
-
*
|
|
24087
|
+
* Deletes a {@link Amity.Comment}
|
|
24276
24088
|
*
|
|
24277
|
-
* @param
|
|
24278
|
-
* @
|
|
24089
|
+
* @param commentId The {@link Amity.Comment} ID to delete
|
|
24090
|
+
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
24279
24091
|
*
|
|
24280
|
-
* @category
|
|
24092
|
+
* @category Comment API
|
|
24093
|
+
* @async
|
|
24281
24094
|
*/
|
|
24282
|
-
const
|
|
24095
|
+
const softDeleteComment = async (commentId) => {
|
|
24283
24096
|
const client = getActiveClient();
|
|
24284
|
-
|
|
24285
|
-
|
|
24286
|
-
|
|
24287
|
-
}
|
|
24288
|
-
else {
|
|
24289
|
-
upsertInCache(['post', 'get', post.postId], post);
|
|
24290
|
-
callback(post);
|
|
24291
|
-
}
|
|
24292
|
-
};
|
|
24293
|
-
return createEventSubscriber(client, 'local.post.removeReaction', 'local.post.removeReaction', filter);
|
|
24097
|
+
client.log('comment/softDeleteComment', commentId);
|
|
24098
|
+
const softDeleted = deleteComment(commentId);
|
|
24099
|
+
return softDeleted;
|
|
24294
24100
|
};
|
|
24295
|
-
|
|
24296
|
-
/**
|
|
24297
|
-
* ```js
|
|
24298
|
-
* import { onLocalPostDeleted } from '@amityco/ts-sdk'
|
|
24299
|
-
* const dispose = onLocalPostDeleted(post => {
|
|
24300
|
-
* // ...
|
|
24301
|
-
* })
|
|
24302
|
-
* ```
|
|
24303
|
-
*
|
|
24304
|
-
* Fired when a {@link Amity.InternalPost} has been deleted
|
|
24305
|
-
*
|
|
24306
|
-
* @param callback The function to call when the event was fired
|
|
24307
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24308
|
-
*
|
|
24309
|
-
* @category Post Events
|
|
24310
|
-
*/
|
|
24311
|
-
const onLocalPostDeleted = (callback) => createLocalPostEventSubscriber('local.post.deleted', callback);
|
|
24312
|
-
|
|
24313
|
-
class UserFeedLiveCollectionController extends LiveCollectionController {
|
|
24314
|
-
constructor(query, callback) {
|
|
24315
|
-
const queryStreamId = hash__default["default"](query);
|
|
24316
|
-
const cacheKey = ['userFeed', 'collection', queryStreamId];
|
|
24317
|
-
const paginationController = new UserFeedPaginationController(query);
|
|
24318
|
-
super(paginationController, queryStreamId, cacheKey, callback);
|
|
24319
|
-
this.query = query;
|
|
24320
|
-
this.queryStreamController = new UserFeedQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
24321
|
-
this.callback = callback.bind(this);
|
|
24322
|
-
this.loadPage({ initial: true });
|
|
24323
|
-
}
|
|
24324
|
-
setup() {
|
|
24325
|
-
var _a;
|
|
24326
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24327
|
-
if (!collection) {
|
|
24328
|
-
pushToCache(this.cacheKey, {
|
|
24329
|
-
data: [],
|
|
24330
|
-
params: {},
|
|
24331
|
-
});
|
|
24332
|
-
}
|
|
24333
|
-
}
|
|
24334
|
-
async persistModel(queryPayload) {
|
|
24335
|
-
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
24336
|
-
}
|
|
24337
|
-
persistQueryStream({ response, direction, refresh, }) {
|
|
24338
|
-
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
24339
|
-
}
|
|
24340
|
-
startSubscription() {
|
|
24341
|
-
return this.queryStreamController.subscribeRTE([
|
|
24342
|
-
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
24343
|
-
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
24344
|
-
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
24345
|
-
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
24346
|
-
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
24347
|
-
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
24348
|
-
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
24349
|
-
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
24350
|
-
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
24351
|
-
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
24352
|
-
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
24353
|
-
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
24354
|
-
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
24355
|
-
{
|
|
24356
|
-
fn: convertEventPayload((callback) => {
|
|
24357
|
-
return onCommentCreated(async (comment) => {
|
|
24358
|
-
var _a;
|
|
24359
|
-
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24360
|
-
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
24361
|
-
return;
|
|
24362
|
-
await getPost$1(comment.referenceId);
|
|
24363
|
-
callback(comment);
|
|
24364
|
-
});
|
|
24365
|
-
}, 'referenceId', 'post'),
|
|
24366
|
-
action: EnumPostActions.OnPostUpdated,
|
|
24367
|
-
},
|
|
24368
|
-
{
|
|
24369
|
-
fn: convertEventPayload((callback) => {
|
|
24370
|
-
return onCommentDeleted(async (comment) => {
|
|
24371
|
-
var _a;
|
|
24372
|
-
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24373
|
-
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
24374
|
-
return;
|
|
24375
|
-
await getPost$1(comment.referenceId);
|
|
24376
|
-
callback(comment);
|
|
24377
|
-
});
|
|
24378
|
-
}, 'referenceId', 'post'),
|
|
24379
|
-
action: EnumPostActions.OnPostUpdated,
|
|
24380
|
-
},
|
|
24381
|
-
]);
|
|
24382
|
-
}
|
|
24383
|
-
notifyChange({ origin, loading, error }) {
|
|
24384
|
-
var _a, _b;
|
|
24385
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24386
|
-
if (!collection)
|
|
24387
|
-
return;
|
|
24388
|
-
const data = this.applyFilter((_b = collection.data
|
|
24389
|
-
.map(id => pullFromCache(['post', 'get', id]))
|
|
24390
|
-
.filter(isNonNullable)
|
|
24391
|
-
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
24392
|
-
if (!this.shouldNotify(data) && origin === 'event')
|
|
24393
|
-
return;
|
|
24394
|
-
this.callback({
|
|
24395
|
-
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
24396
|
-
data,
|
|
24397
|
-
hasNextPage: !!this.paginationController.getNextToken(),
|
|
24398
|
-
loading,
|
|
24399
|
-
error,
|
|
24400
|
-
});
|
|
24401
|
-
}
|
|
24402
|
-
applyFilter(data) {
|
|
24403
|
-
var _a;
|
|
24404
|
-
let posts = data;
|
|
24405
|
-
if (!this.query.includeDeleted) {
|
|
24406
|
-
posts = filterByPropEquality(posts, 'isDeleted', false);
|
|
24407
|
-
}
|
|
24408
|
-
if ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.length) {
|
|
24409
|
-
posts = filterByPostDataTypes(posts, this.query.dataTypes);
|
|
24410
|
-
}
|
|
24411
|
-
switch (this.query.sortBy) {
|
|
24412
|
-
case 'firstCreated':
|
|
24413
|
-
posts = posts.sort(sortByFirstCreated);
|
|
24414
|
-
break;
|
|
24415
|
-
case 'lastCreated':
|
|
24416
|
-
default:
|
|
24417
|
-
posts = posts.sort(sortByLastCreated);
|
|
24418
|
-
break;
|
|
24419
|
-
}
|
|
24420
|
-
return posts;
|
|
24421
|
-
}
|
|
24422
|
-
}
|
|
24101
|
+
/* end_public_function */
|
|
24423
24102
|
|
|
24424
24103
|
/* begin_public_function
|
|
24425
|
-
id:
|
|
24104
|
+
id: comment.hard_delete
|
|
24426
24105
|
*/
|
|
24427
24106
|
/**
|
|
24428
24107
|
* ```js
|
|
24429
|
-
* import {
|
|
24430
|
-
*
|
|
24431
|
-
* let posts = []
|
|
24432
|
-
* const unsubscribe = FeedRepository.getUserFeed({
|
|
24433
|
-
* userId: string,
|
|
24434
|
-
* feedSources: ['user', 'community'],
|
|
24435
|
-
* }, response => response => processResponse(response))
|
|
24108
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
24109
|
+
* const success = await CommentRepository.hardDeleteComment('foobar')
|
|
24436
24110
|
* ```
|
|
24437
24111
|
*
|
|
24438
|
-
*
|
|
24112
|
+
* Deletes a {@link Amity.Comment}
|
|
24439
24113
|
*
|
|
24440
|
-
* @param
|
|
24441
|
-
* @
|
|
24442
|
-
* @param callback the function to call when new data are available
|
|
24443
|
-
* @param config
|
|
24444
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
24114
|
+
* @param commentId The {@link Amity.Comment} ID to delete
|
|
24115
|
+
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
24445
24116
|
*
|
|
24446
|
-
* @category
|
|
24117
|
+
* @category Comment API
|
|
24118
|
+
* @async
|
|
24447
24119
|
*/
|
|
24448
|
-
const
|
|
24449
|
-
const
|
|
24450
|
-
|
|
24451
|
-
|
|
24452
|
-
|
|
24453
|
-
const timestamp = Date.now();
|
|
24454
|
-
log(`getUserFeed(tmpid: ${timestamp}) > listen`);
|
|
24455
|
-
const userFeedLiveCollection = new UserFeedLiveCollectionController(params, callback);
|
|
24456
|
-
const disposers = userFeedLiveCollection.startSubscription();
|
|
24457
|
-
const cacheKey = userFeedLiveCollection.getCacheKey();
|
|
24458
|
-
disposers.push(() => dropFromCache(cacheKey));
|
|
24459
|
-
return () => {
|
|
24460
|
-
log(`getUserFeed(tmpid: ${timestamp}) > dispose`);
|
|
24461
|
-
disposers.forEach(fn => fn());
|
|
24462
|
-
};
|
|
24120
|
+
const hardDeleteComment = async (commentId) => {
|
|
24121
|
+
const client = getActiveClient();
|
|
24122
|
+
client.log('comment/hardDeleteComment', commentId);
|
|
24123
|
+
const hardDeleted = deleteComment(commentId, true);
|
|
24124
|
+
return hardDeleted;
|
|
24463
24125
|
};
|
|
24464
24126
|
/* end_public_function */
|
|
24465
24127
|
|
|
24466
|
-
var index$9 = /*#__PURE__*/Object.freeze({
|
|
24467
|
-
__proto__: null,
|
|
24468
|
-
queryGlobalFeed: queryGlobalFeed,
|
|
24469
|
-
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
|
|
24470
|
-
getUserFeed: getUserFeed
|
|
24471
|
-
});
|
|
24472
|
-
|
|
24473
24128
|
/* begin_public_function
|
|
24474
|
-
id:
|
|
24129
|
+
id: comment.flag
|
|
24475
24130
|
*/
|
|
24476
24131
|
/**
|
|
24477
24132
|
* ```js
|
|
24478
|
-
* import {
|
|
24479
|
-
* const
|
|
24133
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
24134
|
+
* const flagged = await CommentRepository.flagComment(commentId, reason)
|
|
24480
24135
|
* ```
|
|
24481
24136
|
*
|
|
24482
|
-
*
|
|
24483
|
-
*
|
|
24484
|
-
* @
|
|
24485
|
-
* @returns the associated collection of {@link Amity.Post} objects
|
|
24137
|
+
* @param commentId The ID of the comment to flag
|
|
24138
|
+
* @param reason the reason to flag the comment
|
|
24139
|
+
* @returns the created report result
|
|
24486
24140
|
*
|
|
24487
|
-
* @category
|
|
24141
|
+
* @category Comment API
|
|
24488
24142
|
* @async
|
|
24489
|
-
*/
|
|
24490
|
-
const
|
|
24143
|
+
* */
|
|
24144
|
+
const flagComment = async (commentId, reason) => {
|
|
24491
24145
|
const client = getActiveClient();
|
|
24492
|
-
client.log('
|
|
24493
|
-
const
|
|
24494
|
-
|
|
24495
|
-
|
|
24496
|
-
|
|
24497
|
-
|
|
24498
|
-
params: { postIds: encodedPostIds },
|
|
24499
|
-
});
|
|
24500
|
-
payload = response.data;
|
|
24501
|
-
}
|
|
24502
|
-
catch (error) {
|
|
24503
|
-
postIds.forEach(postId => {
|
|
24504
|
-
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
24505
|
-
pushToTombstone('post', postId);
|
|
24506
|
-
}
|
|
24507
|
-
});
|
|
24508
|
-
throw error;
|
|
24509
|
-
}
|
|
24510
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
24511
|
-
const cachedAt = client.cache && Date.now();
|
|
24512
|
-
if (client.cache)
|
|
24513
|
-
ingestInCache(data, { cachedAt });
|
|
24514
|
-
return {
|
|
24515
|
-
data: data.posts.map(LinkedObject.post),
|
|
24516
|
-
cachedAt,
|
|
24146
|
+
client.log('comment/flagComment', commentId);
|
|
24147
|
+
const isPredefinedReason = reason &&
|
|
24148
|
+
Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
|
|
24149
|
+
const body = {
|
|
24150
|
+
reason: reason && isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
|
|
24151
|
+
detail: reason && !isPredefinedReason ? reason : '',
|
|
24517
24152
|
};
|
|
24153
|
+
const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
|
|
24154
|
+
if (client.cache) {
|
|
24155
|
+
ingestInCache(payload);
|
|
24156
|
+
}
|
|
24157
|
+
fireEvent('comment.flagged', payload);
|
|
24158
|
+
return !!payload;
|
|
24518
24159
|
};
|
|
24519
24160
|
/* end_public_function */
|
|
24161
|
+
|
|
24162
|
+
/* begin_public_function
|
|
24163
|
+
id: comment.unflag
|
|
24164
|
+
*/
|
|
24520
24165
|
/**
|
|
24521
24166
|
* ```js
|
|
24522
|
-
* import {
|
|
24523
|
-
* const
|
|
24167
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
24168
|
+
* const unflagged = await CommentRepository.unflagComment('commentId')
|
|
24524
24169
|
* ```
|
|
24525
24170
|
*
|
|
24526
|
-
*
|
|
24527
|
-
*
|
|
24528
|
-
* @param postIds the IDs of the {@link Amity.Post} to fetch
|
|
24529
|
-
* @returns the associated collection of {@link Amity.Post} objects
|
|
24171
|
+
* @param commentId The ID of comment to unflag
|
|
24172
|
+
* @returns the unflagged result
|
|
24530
24173
|
*
|
|
24531
|
-
* @category
|
|
24532
|
-
|
|
24533
|
-
|
|
24534
|
-
|
|
24174
|
+
* @category Comment API
|
|
24175
|
+
* @async
|
|
24176
|
+
* */
|
|
24177
|
+
const unflagComment = async (commentId) => {
|
|
24535
24178
|
const client = getActiveClient();
|
|
24536
|
-
client.log('
|
|
24537
|
-
|
|
24538
|
-
|
|
24539
|
-
|
|
24540
|
-
|
|
24541
|
-
|
|
24542
|
-
|
|
24543
|
-
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
24544
|
-
if ((cached === null || cached === void 0 ? void 0 : cached.length) < postIds.length)
|
|
24545
|
-
return;
|
|
24546
|
-
return {
|
|
24547
|
-
data: posts.map(LinkedObject.post),
|
|
24548
|
-
cachedAt: oldest.cachedAt,
|
|
24549
|
-
};
|
|
24179
|
+
client.log('comment/unflagComment', commentId);
|
|
24180
|
+
const { data: payload } = await client.http.delete(`/api/v3/comments/${encodeURIComponent(commentId)}/unflag`);
|
|
24181
|
+
if (client.cache) {
|
|
24182
|
+
ingestInCache(payload);
|
|
24183
|
+
}
|
|
24184
|
+
fireEvent('comment.unflagged', payload);
|
|
24185
|
+
return !!payload;
|
|
24550
24186
|
};
|
|
24187
|
+
/* end_public_function */
|
|
24551
24188
|
|
|
24552
24189
|
/* begin_public_function
|
|
24553
|
-
id:
|
|
24190
|
+
id: comment.check_flag_by_me
|
|
24554
24191
|
*/
|
|
24555
24192
|
/**
|
|
24556
24193
|
* ```js
|
|
24557
|
-
* import {
|
|
24558
|
-
* const
|
|
24559
|
-
* targetType: 'user',
|
|
24560
|
-
* targetId: 'foobar',
|
|
24561
|
-
* data: { text: 'hello world' }
|
|
24562
|
-
* }))
|
|
24194
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
24195
|
+
* const isReported = await CommentRepository.isCommentFlaggedByMe('commentId')
|
|
24563
24196
|
* ```
|
|
24564
24197
|
*
|
|
24565
|
-
*
|
|
24566
|
-
*
|
|
24567
|
-
* @param bundle The data necessary to create a new {@link Amity.Post}
|
|
24568
|
-
* @returns The newly created {@link Amity.Post}
|
|
24198
|
+
* @param commentId The ID of the comment to check if flagged by current user
|
|
24199
|
+
* @returns `true` if the comment is flagged by me, `false` if doesn't.
|
|
24569
24200
|
*
|
|
24570
|
-
* @category
|
|
24201
|
+
* @category Comment API
|
|
24571
24202
|
* @async
|
|
24572
|
-
*/
|
|
24573
|
-
const
|
|
24203
|
+
* */
|
|
24204
|
+
const isCommentFlaggedByMe = async (commentId) => {
|
|
24574
24205
|
const client = getActiveClient();
|
|
24575
|
-
client.log('
|
|
24576
|
-
|
|
24577
|
-
|
|
24578
|
-
|
|
24206
|
+
client.log('comment/isCommentFlaggedByMe', commentId);
|
|
24207
|
+
const { data: { result }, } = await client.http.get(`/api/v3/comments/${commentId}/isflagbyme`);
|
|
24208
|
+
return result;
|
|
24209
|
+
};
|
|
24210
|
+
/* end_public_function */
|
|
24211
|
+
|
|
24212
|
+
const getComment$1 = async (commentId) => {
|
|
24213
|
+
const client = getActiveClient();
|
|
24214
|
+
client.log('comment/getComment', commentId);
|
|
24215
|
+
isInTombstone('comment', commentId);
|
|
24216
|
+
let data;
|
|
24217
|
+
try {
|
|
24218
|
+
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
24219
|
+
const response = await client.http.get(`/api/v3/comments/${encodeURIComponent(commentId)}`);
|
|
24220
|
+
data = response.data;
|
|
24221
|
+
}
|
|
24222
|
+
catch (error) {
|
|
24223
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
24224
|
+
pushToTombstone('comment', commentId);
|
|
24225
|
+
}
|
|
24226
|
+
throw error;
|
|
24579
24227
|
}
|
|
24580
|
-
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
24581
|
-
fireEvent('post.created', payload);
|
|
24582
|
-
const data = preparePostPayload(payload);
|
|
24583
24228
|
const cachedAt = client.cache && Date.now();
|
|
24584
24229
|
if (client.cache)
|
|
24585
24230
|
ingestInCache(data, { cachedAt });
|
|
24586
|
-
const {
|
|
24231
|
+
const { comments } = data;
|
|
24587
24232
|
return {
|
|
24588
|
-
data:
|
|
24233
|
+
data: comments.find(comment => comment.commentId === commentId),
|
|
24589
24234
|
cachedAt,
|
|
24590
24235
|
};
|
|
24591
24236
|
};
|
|
24592
|
-
|
|
24237
|
+
getComment$1.locally = (commentId) => {
|
|
24238
|
+
const client = getActiveClient();
|
|
24239
|
+
client.log('comment/getComment.locally', commentId);
|
|
24240
|
+
if (!client.cache)
|
|
24241
|
+
return;
|
|
24242
|
+
const cached = pullFromCache(['comment', 'get', commentId]);
|
|
24243
|
+
if (!cached)
|
|
24244
|
+
return;
|
|
24245
|
+
return {
|
|
24246
|
+
data: cached.data,
|
|
24247
|
+
cachedAt: cached.cachedAt,
|
|
24248
|
+
};
|
|
24249
|
+
};
|
|
24593
24250
|
|
|
24594
|
-
/* begin_public_function
|
|
24595
|
-
id: post.edit, post.edit.custom_post
|
|
24596
|
-
*/
|
|
24597
24251
|
/**
|
|
24598
24252
|
* ```js
|
|
24599
|
-
* import {
|
|
24600
|
-
* const
|
|
24601
|
-
*
|
|
24253
|
+
* import { onCommentDeleteLocal } from '@amityco/ts-sdk'
|
|
24254
|
+
* const dispose = onCommentDeleteLocal(comment => {
|
|
24255
|
+
* // ...
|
|
24602
24256
|
* })
|
|
24603
24257
|
* ```
|
|
24604
24258
|
*
|
|
24605
|
-
*
|
|
24259
|
+
* Fired when a {@link Amity.InternalComment} has been deleted
|
|
24606
24260
|
*
|
|
24607
|
-
* @param
|
|
24608
|
-
* @
|
|
24609
|
-
* @returns the updated {@link Amity.Post} object
|
|
24261
|
+
* @param callback The function to call when the event was fired
|
|
24262
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24610
24263
|
*
|
|
24611
|
-
* @category
|
|
24612
|
-
* @async
|
|
24264
|
+
* @category Comment Events
|
|
24613
24265
|
*/
|
|
24614
|
-
const
|
|
24615
|
-
const client = getActiveClient();
|
|
24616
|
-
client.log('user/editPost', patch);
|
|
24617
|
-
const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
|
|
24618
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
24619
|
-
const cachedAt = client.cache && Date.now();
|
|
24620
|
-
if (client.cache)
|
|
24621
|
-
ingestInCache(data, { cachedAt });
|
|
24622
|
-
fireEvent('local.post.updated', data);
|
|
24623
|
-
const { posts } = data;
|
|
24624
|
-
return {
|
|
24625
|
-
data: LinkedObject.post(posts.find(post => post.postId === postId)),
|
|
24626
|
-
cachedAt,
|
|
24627
|
-
};
|
|
24628
|
-
};
|
|
24629
|
-
/* end_public_function */
|
|
24266
|
+
const onCommentDeleteLocal = (callback) => createLocalCommentEventSubscriber('local.comment.deleted', callback);
|
|
24630
24267
|
|
|
24631
24268
|
/**
|
|
24632
24269
|
* ```js
|
|
24633
|
-
* import {
|
|
24634
|
-
* const
|
|
24270
|
+
* import { onLocalCommentReactionAdded } from '@amityco/ts-sdk'
|
|
24271
|
+
* const dispose = onLocalCommentReactionAdded(comment => {
|
|
24272
|
+
* // ...
|
|
24273
|
+
* })
|
|
24635
24274
|
* ```
|
|
24636
24275
|
*
|
|
24637
|
-
*
|
|
24276
|
+
* Fired when a {@link Amity.InternalComment} has been reacted
|
|
24638
24277
|
*
|
|
24639
|
-
* @param
|
|
24640
|
-
* @
|
|
24278
|
+
* @param callback The function to call when the event was fired
|
|
24279
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24641
24280
|
*
|
|
24642
|
-
* @
|
|
24643
|
-
* @async
|
|
24281
|
+
* @category Comment Events
|
|
24644
24282
|
*/
|
|
24645
|
-
const
|
|
24646
|
-
var _a;
|
|
24283
|
+
const onLocalCommentReactionAdded = (callback) => {
|
|
24647
24284
|
const client = getActiveClient();
|
|
24648
|
-
const
|
|
24649
|
-
|
|
24650
|
-
|
|
24651
|
-
|
|
24652
|
-
|
|
24653
|
-
|
|
24654
|
-
|
|
24655
|
-
|
|
24656
|
-
|
|
24657
|
-
|
|
24658
|
-
// later when realtime events covers that for us.
|
|
24659
|
-
if (post.data.targetType === 'community') {
|
|
24660
|
-
const community = await getCommunity$1(post.data.targetId);
|
|
24661
|
-
const communityUsersCache = (_a = queryCache(['communityUsers', 'get'])) !== null && _a !== void 0 ? _a : [];
|
|
24662
|
-
const communityUsers = communityUsersCache
|
|
24663
|
-
.filter(({ key }) => {
|
|
24664
|
-
// cache key is ['communityUsers', 'get', `${communityId}#`${userId}`}]
|
|
24665
|
-
if (key[0] !== 'communityUsers')
|
|
24666
|
-
return false;
|
|
24667
|
-
if (key[1] !== 'get')
|
|
24668
|
-
return false;
|
|
24669
|
-
if (typeof key[2] === 'string')
|
|
24670
|
-
return key[2].includes(community.data.communityId);
|
|
24671
|
-
return false;
|
|
24672
|
-
})
|
|
24673
|
-
.map(({ data }) => data);
|
|
24674
|
-
fireEvent('community.updated', {
|
|
24675
|
-
communities: [community.data],
|
|
24676
|
-
categories: [],
|
|
24677
|
-
communityUsers,
|
|
24678
|
-
feeds: [],
|
|
24679
|
-
files: [],
|
|
24680
|
-
users: [],
|
|
24681
|
-
});
|
|
24682
|
-
}
|
|
24683
|
-
// to support hard deletion
|
|
24684
|
-
const deleted = Object.assign(Object.assign({}, post.data), { isDeleted: true });
|
|
24685
|
-
if (permanent) {
|
|
24686
|
-
setTimeout(() => {
|
|
24687
|
-
pushToTombstone('post', postId);
|
|
24688
|
-
}, 0);
|
|
24689
|
-
}
|
|
24690
|
-
else {
|
|
24691
|
-
upsertInCache(['post', 'get', postId], { isDeleted: true });
|
|
24692
|
-
}
|
|
24693
|
-
fireEvent('local.post.deleted', {
|
|
24694
|
-
posts: [deleted],
|
|
24695
|
-
categories: [],
|
|
24696
|
-
comments: [],
|
|
24697
|
-
communities: [],
|
|
24698
|
-
communityUsers: [],
|
|
24699
|
-
feeds: [],
|
|
24700
|
-
files: [],
|
|
24701
|
-
postChildren: [],
|
|
24702
|
-
users: [],
|
|
24703
|
-
videoStreamings: [],
|
|
24704
|
-
});
|
|
24705
|
-
return LinkedObject.post(deleted);
|
|
24285
|
+
const filter = ({ comment }) => {
|
|
24286
|
+
if (!client.cache) {
|
|
24287
|
+
callback(comment);
|
|
24288
|
+
}
|
|
24289
|
+
else {
|
|
24290
|
+
upsertInCache(['comment', 'get', comment.commentId], comment);
|
|
24291
|
+
callback(commentLinkedObject(comment));
|
|
24292
|
+
}
|
|
24293
|
+
};
|
|
24294
|
+
return createEventSubscriber(client, 'local.comment.addReaction', 'local.comment.addReaction', filter);
|
|
24706
24295
|
};
|
|
24707
24296
|
|
|
24708
|
-
/* begin_public_function
|
|
24709
|
-
id: post.soft_delete
|
|
24710
|
-
*/
|
|
24711
24297
|
/**
|
|
24712
24298
|
* ```js
|
|
24713
|
-
* import {
|
|
24714
|
-
* const
|
|
24299
|
+
* import { onLocalCommentReactionRemoved } from '@amityco/ts-sdk'
|
|
24300
|
+
* const dispose = onLocalCommentReactionRemoved(comment => {
|
|
24301
|
+
* // ...
|
|
24302
|
+
* })
|
|
24715
24303
|
* ```
|
|
24716
24304
|
*
|
|
24717
|
-
*
|
|
24305
|
+
* Fired when a {@link Amity.InternalComment} has been reacted
|
|
24718
24306
|
*
|
|
24719
|
-
* @param
|
|
24720
|
-
* @
|
|
24307
|
+
* @param callback The function to call when the event was fired
|
|
24308
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24721
24309
|
*
|
|
24722
|
-
* @category
|
|
24723
|
-
* @async
|
|
24310
|
+
* @category Comment Events
|
|
24724
24311
|
*/
|
|
24725
|
-
const
|
|
24312
|
+
const onLocalCommentReactionRemoved = (callback) => {
|
|
24726
24313
|
const client = getActiveClient();
|
|
24727
|
-
|
|
24728
|
-
|
|
24729
|
-
|
|
24314
|
+
const filter = ({ comment }) => {
|
|
24315
|
+
if (!client.cache) {
|
|
24316
|
+
callback(comment);
|
|
24317
|
+
}
|
|
24318
|
+
else {
|
|
24319
|
+
upsertInCache(['comment', 'get', comment.commentId], comment);
|
|
24320
|
+
callback(commentLinkedObject(comment));
|
|
24321
|
+
}
|
|
24322
|
+
};
|
|
24323
|
+
return createEventSubscriber(client, 'local.comment.removeReaction', 'local.comment.removeReaction', filter);
|
|
24730
24324
|
};
|
|
24731
|
-
/* end_public_function */
|
|
24732
24325
|
|
|
24733
24326
|
/* begin_public_function
|
|
24734
|
-
id:
|
|
24327
|
+
id: comment.get
|
|
24735
24328
|
*/
|
|
24736
24329
|
/**
|
|
24737
24330
|
* ```js
|
|
24738
|
-
* import {
|
|
24739
|
-
*
|
|
24331
|
+
* import { CommentRepository } from '@amityco/ts-sdk';
|
|
24332
|
+
*
|
|
24333
|
+
* let comment;
|
|
24334
|
+
*
|
|
24335
|
+
* const unsub = CommentRepository.getComment(commentId, response => {
|
|
24336
|
+
* comment = response.data;
|
|
24337
|
+
* });
|
|
24740
24338
|
* ```
|
|
24741
24339
|
*
|
|
24742
|
-
*
|
|
24340
|
+
* Observe all mutation on a given {@link Amity.Comment}
|
|
24743
24341
|
*
|
|
24744
|
-
* @param
|
|
24745
|
-
* @
|
|
24342
|
+
* @param commentId the ID of the comment to observe
|
|
24343
|
+
* @param callback the function to call when new data are available
|
|
24344
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
|
|
24746
24345
|
*
|
|
24747
|
-
* @category
|
|
24748
|
-
* @async
|
|
24346
|
+
* @category Comment Live Object
|
|
24749
24347
|
*/
|
|
24750
|
-
const
|
|
24751
|
-
|
|
24752
|
-
|
|
24753
|
-
|
|
24754
|
-
|
|
24348
|
+
const getComment = (commentId, callback) => {
|
|
24349
|
+
return liveObject(commentId, callback, 'commentId', getComment$1, [
|
|
24350
|
+
onCommentDeleteLocal,
|
|
24351
|
+
onCommentDeleted,
|
|
24352
|
+
onCommentFlagged,
|
|
24353
|
+
onCommentReactionAdded,
|
|
24354
|
+
onCommentReactionRemoved,
|
|
24355
|
+
onCommentUnflagged,
|
|
24356
|
+
onCommentUpdated,
|
|
24357
|
+
onLocalCommentReactionAdded,
|
|
24358
|
+
onLocalCommentReactionRemoved,
|
|
24359
|
+
]);
|
|
24755
24360
|
};
|
|
24756
24361
|
/* end_public_function */
|
|
24757
24362
|
|
|
24758
|
-
|
|
24759
|
-
|
|
24760
|
-
|
|
24363
|
+
class CommentPaginationController extends PaginationController {
|
|
24364
|
+
async getRequest(queryParams, token) {
|
|
24365
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
|
|
24366
|
+
const baseOptions = {
|
|
24367
|
+
type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
|
|
24368
|
+
};
|
|
24369
|
+
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
24370
|
+
const { data: queryResponse } = await this.http.get(`/api/v3/comments`, {
|
|
24371
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
|
|
24372
|
+
});
|
|
24373
|
+
return queryResponse;
|
|
24374
|
+
}
|
|
24375
|
+
}
|
|
24376
|
+
|
|
24377
|
+
var EnumCommentActions;
|
|
24378
|
+
(function (EnumCommentActions) {
|
|
24379
|
+
EnumCommentActions["OnCommentCreated"] = "onCommentCreated";
|
|
24380
|
+
EnumCommentActions["OnCommentUpdated"] = "onCommentUpdated";
|
|
24381
|
+
EnumCommentActions["OnCommentDeleted"] = "onCommentDeleted";
|
|
24382
|
+
EnumCommentActions["OnCommentFlagged"] = "onCommentFlagged";
|
|
24383
|
+
EnumCommentActions["OnCommentUnflagged"] = "onCommentUnflagged";
|
|
24384
|
+
EnumCommentActions["OnCommentReactionAdded"] = "onCommentReactionAdded";
|
|
24385
|
+
EnumCommentActions["OnCommentReactionRemoved"] = "onCommentReactionRemoved";
|
|
24386
|
+
})(EnumCommentActions || (EnumCommentActions = {}));
|
|
24387
|
+
|
|
24388
|
+
class CommentQueryStreamController extends QueryStreamController {
|
|
24389
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
24390
|
+
super(query, cacheKey);
|
|
24391
|
+
this.notifyChange = notifyChange;
|
|
24392
|
+
this.preparePayload = preparePayload;
|
|
24393
|
+
}
|
|
24394
|
+
async saveToMainDB(response) {
|
|
24395
|
+
const processedPayload = await this.preparePayload(response);
|
|
24396
|
+
const client = getActiveClient();
|
|
24397
|
+
const cachedAt = client.cache && Date.now();
|
|
24398
|
+
if (client.cache) {
|
|
24399
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
24400
|
+
}
|
|
24401
|
+
}
|
|
24402
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
24403
|
+
var _a, _b;
|
|
24404
|
+
if (refresh) {
|
|
24405
|
+
pushToCache(this.cacheKey, {
|
|
24406
|
+
data: response.comments.map(getResolver('comment')),
|
|
24407
|
+
});
|
|
24408
|
+
}
|
|
24409
|
+
else {
|
|
24410
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24411
|
+
const comments = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
24412
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...comments, ...response.comments.map(getResolver('comment'))])] }));
|
|
24413
|
+
}
|
|
24414
|
+
}
|
|
24415
|
+
reactor(action) {
|
|
24416
|
+
return (comment) => {
|
|
24417
|
+
var _a;
|
|
24418
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24419
|
+
if (this.query.referenceId !== comment.referenceId ||
|
|
24420
|
+
this.query.referenceType !== comment.referenceType ||
|
|
24421
|
+
!collection) {
|
|
24422
|
+
return;
|
|
24423
|
+
}
|
|
24424
|
+
if (this.query.parentId && this.query.parentId !== comment.parentId) {
|
|
24425
|
+
return;
|
|
24426
|
+
}
|
|
24427
|
+
if (!this.query.parentId && comment.parentId) {
|
|
24428
|
+
return;
|
|
24429
|
+
}
|
|
24430
|
+
if (action === EnumCommentActions.OnCommentCreated) {
|
|
24431
|
+
collection.data = [...new Set([comment.commentId, ...collection.data])];
|
|
24432
|
+
}
|
|
24433
|
+
pushToCache(this.cacheKey, collection);
|
|
24434
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
24435
|
+
};
|
|
24436
|
+
}
|
|
24437
|
+
subscribeRTE(createSubscriber) {
|
|
24438
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
24439
|
+
}
|
|
24440
|
+
}
|
|
24441
|
+
|
|
24761
24442
|
/**
|
|
24762
24443
|
* ```js
|
|
24763
|
-
* import {
|
|
24764
|
-
*
|
|
24765
|
-
*
|
|
24444
|
+
* import { onCommentCreated } from '@amityco/ts-sdk'
|
|
24445
|
+
* const dispose = onCommentCreated(comment => {
|
|
24446
|
+
* // ...
|
|
24447
|
+
* })
|
|
24766
24448
|
* ```
|
|
24767
24449
|
*
|
|
24768
|
-
*
|
|
24450
|
+
* Fired when a {@link Amity.InternalComment} has been created
|
|
24769
24451
|
*
|
|
24770
|
-
* @param
|
|
24771
|
-
* @
|
|
24452
|
+
* @param callback The function to call when the event was fired
|
|
24453
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24772
24454
|
*
|
|
24773
|
-
* @category
|
|
24774
|
-
* @async
|
|
24455
|
+
* @category Comment Events
|
|
24775
24456
|
*/
|
|
24776
|
-
const
|
|
24777
|
-
|
|
24778
|
-
|
|
24779
|
-
|
|
24780
|
-
|
|
24781
|
-
|
|
24782
|
-
|
|
24783
|
-
|
|
24457
|
+
const onCommentCreatedLocal = (callback) => {
|
|
24458
|
+
return createLocalCommentEventSubscriber('local.comment.created', callback);
|
|
24459
|
+
};
|
|
24460
|
+
|
|
24461
|
+
class CommentLiveCollectionController extends LiveCollectionController {
|
|
24462
|
+
constructor(query, callback) {
|
|
24463
|
+
const queryStreamId = hash__default["default"](query);
|
|
24464
|
+
const cacheKey = ['comments', 'collection', queryStreamId];
|
|
24465
|
+
const paginationController = new CommentPaginationController(query);
|
|
24466
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
24467
|
+
this.query = query;
|
|
24468
|
+
this.queryStreamController = new CommentQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareCommentPayload);
|
|
24469
|
+
this.callback = callback.bind(this);
|
|
24470
|
+
this.loadPage({ initial: true });
|
|
24471
|
+
}
|
|
24472
|
+
setup() {
|
|
24473
|
+
var _a;
|
|
24474
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24475
|
+
if (!collection) {
|
|
24476
|
+
pushToCache(this.cacheKey, {
|
|
24477
|
+
data: [],
|
|
24478
|
+
params: {},
|
|
24479
|
+
});
|
|
24480
|
+
}
|
|
24481
|
+
}
|
|
24482
|
+
async persistModel(queryPayload) {
|
|
24483
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
24484
|
+
}
|
|
24485
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
24486
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
24487
|
+
}
|
|
24488
|
+
startSubscription() {
|
|
24489
|
+
return this.queryStreamController.subscribeRTE([
|
|
24490
|
+
{ fn: onCommentCreatedLocal, action: EnumCommentActions.OnCommentCreated },
|
|
24491
|
+
{ fn: onCommentDeleteLocal, action: EnumCommentActions.OnCommentDeleted },
|
|
24492
|
+
{ fn: onCommentCreated, action: EnumCommentActions.OnCommentCreated },
|
|
24493
|
+
{ fn: onCommentUpdated, action: EnumCommentActions.OnCommentUpdated },
|
|
24494
|
+
{ fn: onCommentDeleted, action: EnumCommentActions.OnCommentDeleted },
|
|
24495
|
+
{ fn: onCommentFlagged, action: EnumCommentActions.OnCommentFlagged },
|
|
24496
|
+
{ fn: onCommentUnflagged, action: EnumCommentActions.OnCommentUnflagged },
|
|
24497
|
+
{ fn: onCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
24498
|
+
{ fn: onCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
24499
|
+
{ fn: onLocalCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
24500
|
+
{ fn: onLocalCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
24501
|
+
]);
|
|
24502
|
+
}
|
|
24503
|
+
notifyChange({ origin, loading, error }) {
|
|
24504
|
+
var _a, _b;
|
|
24505
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24506
|
+
if (!collection)
|
|
24507
|
+
return;
|
|
24508
|
+
const data = this.applyFilter((_b = collection.data
|
|
24509
|
+
.map(id => pullFromCache(['comment', 'get', id]))
|
|
24510
|
+
.filter(isNonNullable)
|
|
24511
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.comment);
|
|
24512
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
24513
|
+
return;
|
|
24514
|
+
this.callback({
|
|
24515
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
24516
|
+
data,
|
|
24517
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
24518
|
+
loading,
|
|
24519
|
+
error,
|
|
24520
|
+
});
|
|
24521
|
+
}
|
|
24522
|
+
applyFilter(data) {
|
|
24523
|
+
let comments = data;
|
|
24524
|
+
if (!this.query.includeDeleted) {
|
|
24525
|
+
comments = filterByPropEquality(comments, 'isDeleted', false);
|
|
24526
|
+
}
|
|
24527
|
+
if (this.query.parentId) {
|
|
24528
|
+
comments = comments.filter(comment => comment.parentId === this.query.parentId);
|
|
24529
|
+
}
|
|
24530
|
+
if (typeof this.query.hasFlag === 'boolean') {
|
|
24531
|
+
if (this.query.hasFlag) {
|
|
24532
|
+
comments = comments.filter(comment => comment.hashFlag != null);
|
|
24533
|
+
}
|
|
24534
|
+
else {
|
|
24535
|
+
comments = comments.filter(comment => comment.hashFlag == null);
|
|
24536
|
+
}
|
|
24537
|
+
}
|
|
24538
|
+
if (this.query.dataTypes) {
|
|
24539
|
+
if (this.query.dataTypes.matchType === 'exact') {
|
|
24540
|
+
comments = comments.filter(comment => {
|
|
24541
|
+
var _a, _b;
|
|
24542
|
+
const sortedDataTypesQueryValue = ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.sort()) || [];
|
|
24543
|
+
const sortedDataTypesCommentValue = ((_b = comment.dataTypes) === null || _b === void 0 ? void 0 : _b.sort()) || [];
|
|
24544
|
+
if (sortedDataTypesCommentValue.length !== sortedDataTypesQueryValue.length) {
|
|
24545
|
+
return false;
|
|
24546
|
+
}
|
|
24547
|
+
return sortedDataTypesQueryValue.every((value, index) => value === sortedDataTypesCommentValue[index]);
|
|
24548
|
+
});
|
|
24549
|
+
}
|
|
24550
|
+
if (this.query.dataTypes.matchType === 'any') {
|
|
24551
|
+
comments = comments.filter(comment => { var _a; return (_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.some(value => { var _a; return (_a = comment.dataTypes) === null || _a === void 0 ? void 0 : _a.includes(value); }); });
|
|
24552
|
+
}
|
|
24553
|
+
}
|
|
24554
|
+
switch (this.query.sortBy) {
|
|
24555
|
+
case 'firstCreated':
|
|
24556
|
+
comments = comments.sort(sortByFirstCreated);
|
|
24557
|
+
break;
|
|
24558
|
+
case 'lastCreated':
|
|
24559
|
+
default:
|
|
24560
|
+
comments = comments.sort(sortByLastCreated);
|
|
24561
|
+
break;
|
|
24562
|
+
}
|
|
24563
|
+
return comments;
|
|
24784
24564
|
}
|
|
24785
|
-
|
|
24786
|
-
const cachedAt = client.cache && Date.now();
|
|
24787
|
-
if (client.cache)
|
|
24788
|
-
ingestInCache(data, { cachedAt });
|
|
24789
|
-
return {
|
|
24790
|
-
data: LinkedObject.post(data.posts.find(post => post.postId === postId)),
|
|
24791
|
-
cachedAt,
|
|
24792
|
-
};
|
|
24793
|
-
};
|
|
24794
|
-
/* end_public_function */
|
|
24565
|
+
}
|
|
24795
24566
|
|
|
24796
24567
|
/* begin_public_function
|
|
24797
|
-
id:
|
|
24568
|
+
id: comment.query
|
|
24798
24569
|
*/
|
|
24799
24570
|
/**
|
|
24800
24571
|
* ```js
|
|
24801
|
-
* import {
|
|
24572
|
+
* import { getComments } from '@amityco/ts-sdk'
|
|
24802
24573
|
*
|
|
24803
|
-
*
|
|
24574
|
+
* let comments = []
|
|
24575
|
+
* const unsub = getComments({
|
|
24576
|
+
* referenceType: Amity.InternalComment['referenceType'];
|
|
24577
|
+
* referenceId: Amity.InternalComment['referenceId'];
|
|
24578
|
+
* }, response => merge(comments, response.data))
|
|
24804
24579
|
* ```
|
|
24805
24580
|
*
|
|
24806
|
-
*
|
|
24581
|
+
* Observe all mutations on a list of {@link Amity.InternalComment} for a given target object
|
|
24807
24582
|
*
|
|
24808
|
-
* @param
|
|
24809
|
-
* @
|
|
24583
|
+
* @param referenceType the type of the target
|
|
24584
|
+
* @param referenceId the ID of the target
|
|
24585
|
+
* @param callback the function to call when new data are available
|
|
24586
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
24810
24587
|
*
|
|
24811
|
-
* @category
|
|
24812
|
-
* @async
|
|
24588
|
+
* @category Comments Live Collection
|
|
24813
24589
|
*/
|
|
24814
|
-
const
|
|
24815
|
-
const
|
|
24816
|
-
|
|
24817
|
-
|
|
24818
|
-
// fire virtual event
|
|
24819
|
-
if (payload.posts[0].targetType === 'community') {
|
|
24820
|
-
fireEvent('community.updated', payload);
|
|
24590
|
+
const getComments = (params, callback, config) => {
|
|
24591
|
+
const { log, cache } = getActiveClient();
|
|
24592
|
+
if (!cache) {
|
|
24593
|
+
console.log('For using Live Collection feature you need to enable Cache!');
|
|
24821
24594
|
}
|
|
24822
|
-
|
|
24823
|
-
|
|
24824
|
-
const
|
|
24825
|
-
|
|
24826
|
-
|
|
24827
|
-
|
|
24828
|
-
|
|
24829
|
-
|
|
24595
|
+
const timestamp = Date.now();
|
|
24596
|
+
log(`getComments(tmpid: ${timestamp}) > listen`);
|
|
24597
|
+
const commentsLiveCollection = new CommentLiveCollectionController(params, callback);
|
|
24598
|
+
const disposers = commentsLiveCollection.startSubscription();
|
|
24599
|
+
const cacheKey = commentsLiveCollection.getCacheKey();
|
|
24600
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
24601
|
+
return () => {
|
|
24602
|
+
log(`getComments(tmpid: ${timestamp}) > dispose`);
|
|
24603
|
+
disposers.forEach(fn => fn());
|
|
24830
24604
|
};
|
|
24831
24605
|
};
|
|
24832
24606
|
/* end_public_function */
|
|
24833
24607
|
|
|
24834
|
-
|
|
24835
|
-
|
|
24836
|
-
|
|
24608
|
+
var index$9 = /*#__PURE__*/Object.freeze({
|
|
24609
|
+
__proto__: null,
|
|
24610
|
+
getCommentByIds: getCommentByIds,
|
|
24611
|
+
createComment: createComment,
|
|
24612
|
+
updateComment: updateComment,
|
|
24613
|
+
deleteComment: deleteComment,
|
|
24614
|
+
softDeleteComment: softDeleteComment,
|
|
24615
|
+
hardDeleteComment: hardDeleteComment,
|
|
24616
|
+
flagComment: flagComment,
|
|
24617
|
+
unflagComment: unflagComment,
|
|
24618
|
+
isCommentFlaggedByMe: isCommentFlaggedByMe,
|
|
24619
|
+
onCommentCreated: onCommentCreated,
|
|
24620
|
+
onCommentUpdated: onCommentUpdated,
|
|
24621
|
+
onCommentDeleted: onCommentDeleted,
|
|
24622
|
+
onCommentFlagged: onCommentFlagged,
|
|
24623
|
+
onCommentUnflagged: onCommentUnflagged,
|
|
24624
|
+
onCommentReactionAdded: onCommentReactionAdded,
|
|
24625
|
+
onCommentReactionRemoved: onCommentReactionRemoved,
|
|
24626
|
+
getComment: getComment,
|
|
24627
|
+
getComments: getComments
|
|
24628
|
+
});
|
|
24629
|
+
|
|
24837
24630
|
/**
|
|
24838
24631
|
* ```js
|
|
24839
|
-
* import {
|
|
24840
|
-
* const
|
|
24632
|
+
* import { onPostUpdatedLocal } from '@amityco/ts-sdk'
|
|
24633
|
+
* const dispose = onPostUpdatedLocal(post => {
|
|
24634
|
+
* // ...
|
|
24635
|
+
* })
|
|
24841
24636
|
* ```
|
|
24842
24637
|
*
|
|
24843
|
-
*
|
|
24844
|
-
* @param reason the reason to flag the post
|
|
24845
|
-
* @returns a boolean
|
|
24638
|
+
* Fired when a {@link Amity.InternalPost} has been updated
|
|
24846
24639
|
*
|
|
24847
|
-
* @
|
|
24848
|
-
* @
|
|
24849
|
-
*
|
|
24850
|
-
|
|
24851
|
-
|
|
24852
|
-
|
|
24853
|
-
const isPredefinedReason = reason &&
|
|
24854
|
-
Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
|
|
24855
|
-
const body = {
|
|
24856
|
-
reason: reason && isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
|
|
24857
|
-
detail: reason && !isPredefinedReason ? reason : '',
|
|
24858
|
-
};
|
|
24859
|
-
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
|
|
24860
|
-
if (client.cache) {
|
|
24861
|
-
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
24862
|
-
}
|
|
24863
|
-
fireEvent('post.flagged', payload);
|
|
24864
|
-
return !!payload;
|
|
24865
|
-
};
|
|
24866
|
-
/* end_public_function */
|
|
24640
|
+
* @param callback The function to call when the event was fired
|
|
24641
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24642
|
+
*
|
|
24643
|
+
* @category Post Events
|
|
24644
|
+
*/
|
|
24645
|
+
const onPostUpdatedLocal = (callback) => createLocalPostEventSubscriber('local.post.updated', callback);
|
|
24867
24646
|
|
|
24868
|
-
/* begin_public_function
|
|
24869
|
-
id: post.unflag
|
|
24870
|
-
*/
|
|
24871
24647
|
/**
|
|
24872
24648
|
* ```js
|
|
24873
|
-
* import {
|
|
24874
|
-
* const
|
|
24649
|
+
* import { onLocalPostReactionAdded } from '@amityco/ts-sdk'
|
|
24650
|
+
* const dispose = onPostReactionAdded(post => {
|
|
24651
|
+
* // ...
|
|
24652
|
+
* })
|
|
24875
24653
|
* ```
|
|
24876
24654
|
*
|
|
24877
|
-
*
|
|
24878
|
-
* @returns the unflag post result
|
|
24655
|
+
* Fired when a {@link Amity.InternalPost} has been reacted
|
|
24879
24656
|
*
|
|
24880
|
-
* @
|
|
24881
|
-
* @
|
|
24882
|
-
*
|
|
24883
|
-
|
|
24657
|
+
* @param callback The function to call when the event was fired
|
|
24658
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24659
|
+
*
|
|
24660
|
+
* @category Post Events
|
|
24661
|
+
*/
|
|
24662
|
+
const onLocalPostReactionAdded = (callback) => {
|
|
24884
24663
|
const client = getActiveClient();
|
|
24885
|
-
|
|
24886
|
-
|
|
24887
|
-
|
|
24888
|
-
|
|
24889
|
-
|
|
24890
|
-
|
|
24891
|
-
|
|
24664
|
+
const filter = ({ post }) => {
|
|
24665
|
+
if (!client.cache) {
|
|
24666
|
+
callback(post);
|
|
24667
|
+
}
|
|
24668
|
+
else {
|
|
24669
|
+
upsertInCache(['post', 'get', post.postId], post);
|
|
24670
|
+
callback(post);
|
|
24671
|
+
}
|
|
24672
|
+
};
|
|
24673
|
+
return createEventSubscriber(client, 'local.post.addReaction', 'local.post.addReaction', filter);
|
|
24892
24674
|
};
|
|
24893
|
-
/* end_public_function */
|
|
24894
24675
|
|
|
24895
|
-
/* begin_public_function
|
|
24896
|
-
id: post.check_flag_by_me
|
|
24897
|
-
*/
|
|
24898
24676
|
/**
|
|
24899
24677
|
* ```js
|
|
24900
|
-
* import {
|
|
24901
|
-
* const
|
|
24678
|
+
* import { onLocalPostReactionRemoved } from '@amityco/ts-sdk'
|
|
24679
|
+
* const dispose = onPostReactionRemoved(post => {
|
|
24680
|
+
* // ...
|
|
24681
|
+
* })
|
|
24902
24682
|
* ```
|
|
24903
24683
|
*
|
|
24904
|
-
*
|
|
24905
|
-
* @returns `true` if the post is flagged by me, `false` if doesn't.
|
|
24684
|
+
* Fired when a {@link Amity.InternalPost} has been reacted
|
|
24906
24685
|
*
|
|
24907
|
-
* @
|
|
24908
|
-
* @
|
|
24909
|
-
*
|
|
24910
|
-
|
|
24686
|
+
* @param callback The function to call when the event was fired
|
|
24687
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24688
|
+
*
|
|
24689
|
+
* @category Post Events
|
|
24690
|
+
*/
|
|
24691
|
+
const onLocalPostReactionRemoved = (callback) => {
|
|
24911
24692
|
const client = getActiveClient();
|
|
24912
|
-
|
|
24913
|
-
|
|
24914
|
-
|
|
24693
|
+
const filter = ({ post }) => {
|
|
24694
|
+
if (!client.cache) {
|
|
24695
|
+
callback(post);
|
|
24696
|
+
}
|
|
24697
|
+
else {
|
|
24698
|
+
upsertInCache(['post', 'get', post.postId], post);
|
|
24699
|
+
callback(post);
|
|
24700
|
+
}
|
|
24701
|
+
};
|
|
24702
|
+
return createEventSubscriber(client, 'local.post.removeReaction', 'local.post.removeReaction', filter);
|
|
24915
24703
|
};
|
|
24916
|
-
/* end_public_function */
|
|
24917
24704
|
|
|
24918
|
-
/* begin_public_function
|
|
24919
|
-
id: post.create.clip_post
|
|
24920
|
-
*/
|
|
24921
24705
|
/**
|
|
24922
24706
|
* ```js
|
|
24923
|
-
* import {
|
|
24924
|
-
* const
|
|
24925
|
-
*
|
|
24926
|
-
*
|
|
24927
|
-
* dataType: 'clip',
|
|
24928
|
-
* data: { text: 'hello world' },
|
|
24929
|
-
* attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
|
|
24930
|
-
* }))
|
|
24707
|
+
* import { onLocalPostDeleted } from '@amityco/ts-sdk'
|
|
24708
|
+
* const dispose = onLocalPostDeleted(post => {
|
|
24709
|
+
* // ...
|
|
24710
|
+
* })
|
|
24931
24711
|
* ```
|
|
24932
24712
|
*
|
|
24933
|
-
*
|
|
24713
|
+
* Fired when a {@link Amity.InternalPost} has been deleted
|
|
24934
24714
|
*
|
|
24935
|
-
* @param
|
|
24936
|
-
* @returns
|
|
24715
|
+
* @param callback The function to call when the event was fired
|
|
24716
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24937
24717
|
*
|
|
24938
|
-
* @category Post
|
|
24939
|
-
* @async
|
|
24718
|
+
* @category Post Events
|
|
24940
24719
|
*/
|
|
24941
|
-
const
|
|
24942
|
-
const client = getActiveClient();
|
|
24943
|
-
client.log('post/createPost', bundle);
|
|
24944
|
-
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
24945
|
-
fireEvent('post.created', payload);
|
|
24946
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
24947
|
-
const cachedAt = client.cache && Date.now();
|
|
24948
|
-
if (client.cache)
|
|
24949
|
-
ingestInCache(data, { cachedAt });
|
|
24950
|
-
const { posts } = data;
|
|
24951
|
-
return {
|
|
24952
|
-
data: LinkedObject.post(posts[0]),
|
|
24953
|
-
cachedAt,
|
|
24954
|
-
};
|
|
24955
|
-
};
|
|
24956
|
-
/* end_public_function */
|
|
24720
|
+
const onLocalPostDeleted = (callback) => createLocalPostEventSubscriber('local.post.deleted', callback);
|
|
24957
24721
|
|
|
24958
24722
|
/* begin_public_function
|
|
24959
24723
|
id: post.get
|
|
@@ -24977,7 +24741,7 @@ const createClipPost = async (bundle) => {
|
|
|
24977
24741
|
*
|
|
24978
24742
|
* @category Post Live Object
|
|
24979
24743
|
*/
|
|
24980
|
-
const getPost = (postId, callback) => {
|
|
24744
|
+
const getPost$1 = (postId, callback) => {
|
|
24981
24745
|
const responder = (snapshot) => {
|
|
24982
24746
|
const { data } = snapshot;
|
|
24983
24747
|
callback(Object.assign(Object.assign({}, snapshot), { data: data ? LinkedObject.post(snapshot.data) : data }));
|
|
@@ -25045,14 +24809,14 @@ const getPost = (postId, callback) => {
|
|
|
25045
24809
|
|
|
25046
24810
|
class PostPaginationController extends PaginationController {
|
|
25047
24811
|
async getRequest(queryParams, token) {
|
|
25048
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT,
|
|
24812
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, matchingOnlyParentPost } = queryParams, params = __rest(queryParams, ["limit", "matchingOnlyParentPost"]);
|
|
25049
24813
|
const { dataTypes } = params;
|
|
25050
24814
|
const baseOptions = {
|
|
25051
24815
|
type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
|
|
25052
24816
|
};
|
|
25053
24817
|
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
25054
24818
|
const { data: queryResponse } = await this.http.get(`/api/v5/posts`, {
|
|
25055
|
-
params: Object.assign(Object.assign({}, params), {
|
|
24819
|
+
params: Object.assign(Object.assign({}, params), {
|
|
25056
24820
|
/*
|
|
25057
24821
|
* when creating post like image, file, video BE will create 2 posts
|
|
25058
24822
|
* 1. parent post to store text with dataType=text
|
|
@@ -25066,6 +24830,19 @@ class PostPaginationController extends PaginationController {
|
|
|
25066
24830
|
}
|
|
25067
24831
|
}
|
|
25068
24832
|
|
|
24833
|
+
var EnumPostActions;
|
|
24834
|
+
(function (EnumPostActions) {
|
|
24835
|
+
EnumPostActions["OnPostCreated"] = "onPostCreated";
|
|
24836
|
+
EnumPostActions["OnPostUpdated"] = "onPostUpdated";
|
|
24837
|
+
EnumPostActions["OnPostDeleted"] = "onPostDeleted";
|
|
24838
|
+
EnumPostActions["OnPostFlagged"] = "onPostFlagged";
|
|
24839
|
+
EnumPostActions["OnPostUnflagged"] = "onPostUnflagged";
|
|
24840
|
+
EnumPostActions["OnPostReactionAdded"] = "onPostReactionAdded";
|
|
24841
|
+
EnumPostActions["OnPostReactionRemoved"] = "onPostReactionRemoved";
|
|
24842
|
+
EnumPostActions["OnPostApproved"] = "onPostApproved";
|
|
24843
|
+
EnumPostActions["OnPostDeclined"] = "onPostDeclined";
|
|
24844
|
+
})(EnumPostActions || (EnumPostActions = {}));
|
|
24845
|
+
|
|
25069
24846
|
class PostQueryStreamController extends QueryStreamController {
|
|
25070
24847
|
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
25071
24848
|
super(query, cacheKey);
|
|
@@ -25131,6 +24908,47 @@ class PostQueryStreamController extends QueryStreamController {
|
|
|
25131
24908
|
}
|
|
25132
24909
|
}
|
|
25133
24910
|
|
|
24911
|
+
const getPost = async (postId) => {
|
|
24912
|
+
const client = getActiveClient();
|
|
24913
|
+
client.log('post/getPost', postId);
|
|
24914
|
+
isInTombstone('post', postId);
|
|
24915
|
+
let payload;
|
|
24916
|
+
try {
|
|
24917
|
+
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
24918
|
+
const response = await client.http.get(`/api/v3/posts/${encodeURIComponent(postId)}`);
|
|
24919
|
+
payload = response.data;
|
|
24920
|
+
}
|
|
24921
|
+
catch (error) {
|
|
24922
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
24923
|
+
pushToTombstone('post', postId);
|
|
24924
|
+
}
|
|
24925
|
+
throw error;
|
|
24926
|
+
}
|
|
24927
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
24928
|
+
const cachedAt = client.cache && Date.now();
|
|
24929
|
+
if (client.cache)
|
|
24930
|
+
ingestInCache(data, { cachedAt });
|
|
24931
|
+
const { posts } = data;
|
|
24932
|
+
const result = posts.find(post => post.postId === postId);
|
|
24933
|
+
return {
|
|
24934
|
+
data: result,
|
|
24935
|
+
cachedAt,
|
|
24936
|
+
};
|
|
24937
|
+
};
|
|
24938
|
+
getPost.locally = (postId) => {
|
|
24939
|
+
const client = getActiveClient();
|
|
24940
|
+
client.log('post/getPost.locally', postId);
|
|
24941
|
+
if (!client.cache)
|
|
24942
|
+
return;
|
|
24943
|
+
const cached = pullFromCache(['post', 'get', postId]);
|
|
24944
|
+
if (!cached)
|
|
24945
|
+
return;
|
|
24946
|
+
return {
|
|
24947
|
+
data: cached.data,
|
|
24948
|
+
cachedAt: cached.cachedAt,
|
|
24949
|
+
};
|
|
24950
|
+
};
|
|
24951
|
+
|
|
25134
24952
|
class PostLiveCollectionController extends LiveCollectionController {
|
|
25135
24953
|
constructor(query, callback) {
|
|
25136
24954
|
const queryStreamId = hash__default["default"](query);
|
|
@@ -25180,7 +24998,7 @@ class PostLiveCollectionController extends LiveCollectionController {
|
|
|
25180
24998
|
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
25181
24999
|
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
25182
25000
|
return;
|
|
25183
|
-
await getPost
|
|
25001
|
+
await getPost(comment.referenceId);
|
|
25184
25002
|
callback(comment);
|
|
25185
25003
|
});
|
|
25186
25004
|
}, 'referenceId', 'post'),
|
|
@@ -25193,7 +25011,7 @@ class PostLiveCollectionController extends LiveCollectionController {
|
|
|
25193
25011
|
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
25194
25012
|
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
25195
25013
|
return;
|
|
25196
|
-
await getPost
|
|
25014
|
+
await getPost(comment.referenceId);
|
|
25197
25015
|
callback(comment);
|
|
25198
25016
|
});
|
|
25199
25017
|
}, 'referenceId', 'post'),
|
|
@@ -25796,6 +25614,237 @@ const semanticSearchPosts = (params, callback, config) => {
|
|
|
25796
25614
|
};
|
|
25797
25615
|
};
|
|
25798
25616
|
|
|
25617
|
+
class SearchPostPaginationController extends PaginationController {
|
|
25618
|
+
async getRequest(queryParams, token) {
|
|
25619
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, matchingOnlyParentPost, hashtags } = queryParams, params = __rest(queryParams, ["limit", "matchingOnlyParentPost", "hashtags"]);
|
|
25620
|
+
const { dataTypes } = params;
|
|
25621
|
+
const baseOptions = {
|
|
25622
|
+
type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
|
|
25623
|
+
};
|
|
25624
|
+
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
25625
|
+
const { data: queryResponse } = await this.http.get(`/api/v1/search/posts`, {
|
|
25626
|
+
params: Object.assign(Object.assign({}, params), { hashtags,
|
|
25627
|
+
/*
|
|
25628
|
+
* when creating post like image, file, video BE will create 2 posts
|
|
25629
|
+
* 1. parent post to store text with dataType=text
|
|
25630
|
+
* 2. child post to store dataTypes post data
|
|
25631
|
+
*
|
|
25632
|
+
* By default, BE queries only parent post
|
|
25633
|
+
*/
|
|
25634
|
+
matchingOnlyParentPost: matchingOnlyParentPost !== null && matchingOnlyParentPost !== void 0 ? matchingOnlyParentPost : !(dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.length), options }),
|
|
25635
|
+
});
|
|
25636
|
+
return queryResponse;
|
|
25637
|
+
}
|
|
25638
|
+
}
|
|
25639
|
+
|
|
25640
|
+
class SearchPostQueryStreamController extends QueryStreamController {
|
|
25641
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
25642
|
+
super(query, cacheKey);
|
|
25643
|
+
this.notifyChange = notifyChange;
|
|
25644
|
+
this.preparePayload = preparePayload;
|
|
25645
|
+
}
|
|
25646
|
+
async saveToMainDB(response) {
|
|
25647
|
+
const processedPayload = await this.preparePayload(response);
|
|
25648
|
+
const client = getActiveClient();
|
|
25649
|
+
const cachedAt = client.cache && Date.now();
|
|
25650
|
+
if (client.cache) {
|
|
25651
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
25652
|
+
}
|
|
25653
|
+
}
|
|
25654
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
25655
|
+
var _a, _b;
|
|
25656
|
+
if (refresh) {
|
|
25657
|
+
pushToCache(this.cacheKey, {
|
|
25658
|
+
data: response.posts.map(getResolver('post')),
|
|
25659
|
+
});
|
|
25660
|
+
}
|
|
25661
|
+
else {
|
|
25662
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
25663
|
+
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
25664
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
|
|
25665
|
+
}
|
|
25666
|
+
}
|
|
25667
|
+
reactor(action) {
|
|
25668
|
+
return (post) => {
|
|
25669
|
+
var _a, _b;
|
|
25670
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
25671
|
+
if (!collection)
|
|
25672
|
+
return;
|
|
25673
|
+
if (post.parentPostId && post.isDeleted) {
|
|
25674
|
+
const parentPost = (_b = pullFromCache([
|
|
25675
|
+
'post',
|
|
25676
|
+
'get',
|
|
25677
|
+
post.parentPostId,
|
|
25678
|
+
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
25679
|
+
if (!parentPost)
|
|
25680
|
+
return;
|
|
25681
|
+
parentPost.children = parentPost.children.filter(childId => childId !== post.postId);
|
|
25682
|
+
pushToCache(['post', 'get', parentPost.postId], parentPost);
|
|
25683
|
+
}
|
|
25684
|
+
if (action === EnumPostActions.OnPostDeclined) {
|
|
25685
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
25686
|
+
}
|
|
25687
|
+
if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
|
|
25688
|
+
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
25689
|
+
}
|
|
25690
|
+
pushToCache(this.cacheKey, collection);
|
|
25691
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
25692
|
+
};
|
|
25693
|
+
}
|
|
25694
|
+
subscribeRTE(createSubscriber) {
|
|
25695
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
25696
|
+
}
|
|
25697
|
+
}
|
|
25698
|
+
|
|
25699
|
+
class SearchPostLiveCollectionController extends LiveCollectionController {
|
|
25700
|
+
constructor(query, callback) {
|
|
25701
|
+
const queryStreamId = hash__default["default"](query);
|
|
25702
|
+
const cacheKey = ['posts', 'collection', queryStreamId];
|
|
25703
|
+
const paginationController = new SearchPostPaginationController(query);
|
|
25704
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
25705
|
+
this.query = query;
|
|
25706
|
+
this.queryStreamController = new SearchPostQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
25707
|
+
this.callback = callback.bind(this);
|
|
25708
|
+
this.loadPage({ initial: true });
|
|
25709
|
+
}
|
|
25710
|
+
setup() {
|
|
25711
|
+
var _a;
|
|
25712
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
25713
|
+
if (!collection) {
|
|
25714
|
+
pushToCache(this.cacheKey, {
|
|
25715
|
+
data: [],
|
|
25716
|
+
params: {},
|
|
25717
|
+
});
|
|
25718
|
+
}
|
|
25719
|
+
}
|
|
25720
|
+
async persistModel(queryPayload) {
|
|
25721
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
25722
|
+
}
|
|
25723
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
25724
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
25725
|
+
}
|
|
25726
|
+
startSubscription() {
|
|
25727
|
+
return this.queryStreamController.subscribeRTE([
|
|
25728
|
+
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
25729
|
+
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
25730
|
+
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
25731
|
+
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
25732
|
+
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
25733
|
+
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
25734
|
+
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
25735
|
+
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
25736
|
+
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
25737
|
+
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
25738
|
+
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
25739
|
+
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
25740
|
+
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
25741
|
+
{
|
|
25742
|
+
fn: convertEventPayload((callback) => {
|
|
25743
|
+
return onCommentCreated(async (comment) => {
|
|
25744
|
+
var _a;
|
|
25745
|
+
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
25746
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
25747
|
+
return;
|
|
25748
|
+
await getPost(comment.referenceId);
|
|
25749
|
+
callback(comment);
|
|
25750
|
+
});
|
|
25751
|
+
}, 'referenceId', 'post'),
|
|
25752
|
+
action: EnumPostActions.OnPostUpdated,
|
|
25753
|
+
},
|
|
25754
|
+
{
|
|
25755
|
+
fn: convertEventPayload((callback) => {
|
|
25756
|
+
return onCommentDeleted(async (comment) => {
|
|
25757
|
+
var _a;
|
|
25758
|
+
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
25759
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
25760
|
+
return;
|
|
25761
|
+
await getPost(comment.referenceId);
|
|
25762
|
+
callback(comment);
|
|
25763
|
+
});
|
|
25764
|
+
}, 'referenceId', 'post'),
|
|
25765
|
+
action: EnumPostActions.OnPostUpdated,
|
|
25766
|
+
},
|
|
25767
|
+
]);
|
|
25768
|
+
}
|
|
25769
|
+
notifyChange({ origin, loading, error }) {
|
|
25770
|
+
var _a, _b;
|
|
25771
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
25772
|
+
if (!collection)
|
|
25773
|
+
return;
|
|
25774
|
+
const data = this.applyFilter((_b = collection.data
|
|
25775
|
+
.map(id => pullFromCache(['post', 'get', id]))
|
|
25776
|
+
.filter(isNonNullable)
|
|
25777
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
25778
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
25779
|
+
return;
|
|
25780
|
+
this.callback({
|
|
25781
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
25782
|
+
data,
|
|
25783
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
25784
|
+
loading,
|
|
25785
|
+
error,
|
|
25786
|
+
});
|
|
25787
|
+
}
|
|
25788
|
+
applyFilter(data) {
|
|
25789
|
+
var _a;
|
|
25790
|
+
let posts = data;
|
|
25791
|
+
if ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.length) {
|
|
25792
|
+
posts = filterByPostDataTypes(posts, this.query.dataTypes);
|
|
25793
|
+
}
|
|
25794
|
+
switch (this.query.sortBy) {
|
|
25795
|
+
case 'firstCreated':
|
|
25796
|
+
posts = posts.sort(sortByFirstCreated);
|
|
25797
|
+
break;
|
|
25798
|
+
case 'lastCreated':
|
|
25799
|
+
default:
|
|
25800
|
+
posts = posts.sort(sortByLastCreated);
|
|
25801
|
+
break;
|
|
25802
|
+
}
|
|
25803
|
+
return posts;
|
|
25804
|
+
}
|
|
25805
|
+
}
|
|
25806
|
+
|
|
25807
|
+
/* begin_public_function
|
|
25808
|
+
id: post.query
|
|
25809
|
+
*/
|
|
25810
|
+
/**
|
|
25811
|
+
* ```js
|
|
25812
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
25813
|
+
*
|
|
25814
|
+
* let posts = []
|
|
25815
|
+
* const unsub = PostRepository.searchPostsByHashtag({
|
|
25816
|
+
* hashtags: ['amity'],
|
|
25817
|
+
* limit: 10,
|
|
25818
|
+
* }, response => merge(posts, response.data))
|
|
25819
|
+
* ```
|
|
25820
|
+
*
|
|
25821
|
+
* Observe all mutations on a list of {@link Amity.Post} for a given target object
|
|
25822
|
+
*
|
|
25823
|
+
* @param params.hashtags the hashtags to search for
|
|
25824
|
+
* @param callback the function to call when new data are available
|
|
25825
|
+
* @param config
|
|
25826
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
25827
|
+
*
|
|
25828
|
+
* @category Posts Live Collection
|
|
25829
|
+
*/
|
|
25830
|
+
const searchPostsByHashtag = (params, callback, config) => {
|
|
25831
|
+
const { log, cache } = getActiveClient();
|
|
25832
|
+
if (!cache) {
|
|
25833
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
25834
|
+
}
|
|
25835
|
+
const timestamp = Date.now();
|
|
25836
|
+
log(`searchPostsByHashtag(tmpid: ${timestamp}) > listen`);
|
|
25837
|
+
const postsLiveCollection = new SearchPostLiveCollectionController(params, callback);
|
|
25838
|
+
const disposers = postsLiveCollection.startSubscription();
|
|
25839
|
+
const cacheKey = postsLiveCollection.getCacheKey();
|
|
25840
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
25841
|
+
return () => {
|
|
25842
|
+
log(`searchPostsByHashtag(tmpid: ${timestamp}) > dispose`);
|
|
25843
|
+
disposers.forEach(fn => fn());
|
|
25844
|
+
};
|
|
25845
|
+
};
|
|
25846
|
+
/* end_public_function */
|
|
25847
|
+
|
|
25799
25848
|
var index$8 = /*#__PURE__*/Object.freeze({
|
|
25800
25849
|
__proto__: null,
|
|
25801
25850
|
getPostByIds: getPostByIds,
|
|
@@ -25810,6 +25859,7 @@ var index$8 = /*#__PURE__*/Object.freeze({
|
|
|
25810
25859
|
unflagPost: unflagPost,
|
|
25811
25860
|
isPostFlaggedByMe: isPostFlaggedByMe,
|
|
25812
25861
|
createClipPost: createClipPost,
|
|
25862
|
+
getPostsByHashtag: getPostsByHashtag,
|
|
25813
25863
|
onPostCreated: onPostCreated,
|
|
25814
25864
|
onPostUpdated: onPostUpdated,
|
|
25815
25865
|
onPostDeleted: onPostDeleted,
|
|
@@ -25819,11 +25869,12 @@ var index$8 = /*#__PURE__*/Object.freeze({
|
|
|
25819
25869
|
onPostUnflagged: onPostUnflagged,
|
|
25820
25870
|
onPostReactionAdded: onPostReactionAdded,
|
|
25821
25871
|
onPostReactionRemoved: onPostReactionRemoved,
|
|
25822
|
-
getPost: getPost,
|
|
25872
|
+
getPost: getPost$1,
|
|
25823
25873
|
getPosts: getPosts,
|
|
25824
25874
|
getPinnedPosts: getPinnedPosts,
|
|
25825
25875
|
getGlobalPinnedPosts: getGlobalPinnedPosts,
|
|
25826
|
-
semanticSearchPosts: semanticSearchPosts
|
|
25876
|
+
semanticSearchPosts: semanticSearchPosts,
|
|
25877
|
+
searchPostsByHashtag: searchPostsByHashtag
|
|
25827
25878
|
});
|
|
25828
25879
|
|
|
25829
25880
|
/* begin_public_function
|
|
@@ -29025,13 +29076,13 @@ exports.AdRepository = index$3;
|
|
|
29025
29076
|
exports.CategoryRepository = index$b;
|
|
29026
29077
|
exports.ChannelRepository = index$f;
|
|
29027
29078
|
exports.Client = index$o;
|
|
29028
|
-
exports.CommentRepository = index$
|
|
29079
|
+
exports.CommentRepository = index$9;
|
|
29029
29080
|
exports.CommunityPostSettingMaps = CommunityPostSettingMaps;
|
|
29030
29081
|
exports.CommunityPostSettings = CommunityPostSettings;
|
|
29031
29082
|
exports.CommunityRepository = index$c;
|
|
29032
29083
|
exports.ContentFeedType = ContentFeedType;
|
|
29033
29084
|
exports.DefaultCommunityPostSetting = DefaultCommunityPostSetting;
|
|
29034
|
-
exports.FeedRepository = index$
|
|
29085
|
+
exports.FeedRepository = index$a;
|
|
29035
29086
|
exports.FileRepository = index$l;
|
|
29036
29087
|
exports.FileType = FileType;
|
|
29037
29088
|
exports.InvitationRepository = index$1;
|