@amityco/ts-sdk 7.8.0 → 7.8.1-1d9a9fe7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +26 -26
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/feed.d.ts +32 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/feed.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/feed.js +22 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/feed.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.d.ts +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.js +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.d.ts +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.js +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts +14 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.js +129 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts +5 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.js +15 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts +15 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.js +78 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.d.ts +23 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.js +46 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.d.ts +2 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.js +2 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/tsconfig.tsbuildinfo +1 -1
- package/dist/@types/domains/feed.d.ts +32 -0
- package/dist/@types/domains/feed.d.ts.map +1 -1
- package/dist/@types/index.d.ts +1 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/feedRepository/index.d.ts +1 -0
- package/dist/feedRepository/index.d.ts.map +1 -1
- package/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts +14 -0
- package/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts +5 -0
- package/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts +15 -0
- package/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getUserFeed.d.ts +23 -0
- package/dist/feedRepository/observers/getUserFeed.d.ts.map +1 -0
- package/dist/feedRepository/observers/index.d.ts +2 -0
- package/dist/feedRepository/observers/index.d.ts.map +1 -0
- package/dist/index.cjs.js +1217 -957
- package/dist/index.esm.js +1359 -1099
- package/dist/index.umd.js +4 -4
- package/package.json +1 -1
- package/src/@types/domains/feed.ts +44 -0
- package/src/@types/index.ts +1 -0
- package/src/feedRepository/index.ts +1 -0
- package/src/feedRepository/observers/getUserFeed/LiveCollectionController.ts +192 -0
- package/src/feedRepository/observers/getUserFeed/PaginationController.ts +37 -0
- package/src/feedRepository/observers/getUserFeed/QueryStreamController.ts +119 -0
- package/src/feedRepository/observers/getUserFeed.ts +56 -0
- package/src/feedRepository/observers/index.ts +1 -0
- package/tsconfig.tsbuildinfo +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -153,6 +153,29 @@ exports.JoinResultStatusEnum = void 0;
|
|
|
153
153
|
JoinResultStatusEnum["Pending"] = "pending";
|
|
154
154
|
})(exports.JoinResultStatusEnum || (exports.JoinResultStatusEnum = {}));
|
|
155
155
|
|
|
156
|
+
exports.FeedDataTypeEnum = void 0;
|
|
157
|
+
(function (FeedDataTypeEnum) {
|
|
158
|
+
FeedDataTypeEnum["Text"] = "text";
|
|
159
|
+
FeedDataTypeEnum["Video"] = "video";
|
|
160
|
+
FeedDataTypeEnum["Image"] = "image";
|
|
161
|
+
FeedDataTypeEnum["File"] = "file";
|
|
162
|
+
FeedDataTypeEnum["LiveStream"] = "liveStream";
|
|
163
|
+
FeedDataTypeEnum["Clip"] = "clip";
|
|
164
|
+
FeedDataTypeEnum["Poll"] = "poll";
|
|
165
|
+
})(exports.FeedDataTypeEnum || (exports.FeedDataTypeEnum = {}));
|
|
166
|
+
exports.FeedSortByEnum = void 0;
|
|
167
|
+
(function (FeedSortByEnum) {
|
|
168
|
+
FeedSortByEnum["LastCreated"] = "lastCreated";
|
|
169
|
+
FeedSortByEnum["FirstCreated"] = "firstCreated";
|
|
170
|
+
FeedSortByEnum["LastUpdated"] = "lastUpdated";
|
|
171
|
+
FeedSortByEnum["FirstUpdated"] = "firstUpdated";
|
|
172
|
+
})(exports.FeedSortByEnum || (exports.FeedSortByEnum = {}));
|
|
173
|
+
exports.FeedSourceEnum = void 0;
|
|
174
|
+
(function (FeedSourceEnum) {
|
|
175
|
+
FeedSourceEnum["Community"] = "community";
|
|
176
|
+
FeedSourceEnum["User"] = "user";
|
|
177
|
+
})(exports.FeedSourceEnum || (exports.FeedSourceEnum = {}));
|
|
178
|
+
|
|
156
179
|
function getVersion() {
|
|
157
180
|
try {
|
|
158
181
|
// the string ''v7.8.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
@@ -23176,1101 +23199,706 @@ getCustomRankingGlobalFeed.locally = (query) => {
|
|
|
23176
23199
|
: undefined;
|
|
23177
23200
|
};
|
|
23178
23201
|
|
|
23179
|
-
|
|
23180
|
-
|
|
23181
|
-
|
|
23182
|
-
|
|
23183
|
-
}
|
|
23202
|
+
class UserFeedPaginationController extends PaginationController {
|
|
23203
|
+
async getRequest(queryParams, token) {
|
|
23204
|
+
const { userId, feedSources, dataTypes, includeDeleted, matchingOnlyParentPost, limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["userId", "feedSources", "dataTypes", "includeDeleted", "matchingOnlyParentPost", "limit"]);
|
|
23205
|
+
const options = token ? { token } : { limit };
|
|
23206
|
+
const { data: queryResponse } = await this.http.get(`/api/v4/user-feeds/${userId}`, {
|
|
23207
|
+
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) }),
|
|
23208
|
+
});
|
|
23209
|
+
return queryResponse;
|
|
23210
|
+
}
|
|
23211
|
+
}
|
|
23212
|
+
|
|
23213
|
+
var EnumPostActions;
|
|
23214
|
+
(function (EnumPostActions) {
|
|
23215
|
+
EnumPostActions["OnPostCreated"] = "onPostCreated";
|
|
23216
|
+
EnumPostActions["OnPostUpdated"] = "onPostUpdated";
|
|
23217
|
+
EnumPostActions["OnPostDeleted"] = "onPostDeleted";
|
|
23218
|
+
EnumPostActions["OnPostFlagged"] = "onPostFlagged";
|
|
23219
|
+
EnumPostActions["OnPostUnflagged"] = "onPostUnflagged";
|
|
23220
|
+
EnumPostActions["OnPostReactionAdded"] = "onPostReactionAdded";
|
|
23221
|
+
EnumPostActions["OnPostReactionRemoved"] = "onPostReactionRemoved";
|
|
23222
|
+
EnumPostActions["OnPostApproved"] = "onPostApproved";
|
|
23223
|
+
EnumPostActions["OnPostDeclined"] = "onPostDeclined";
|
|
23224
|
+
})(EnumPostActions || (EnumPostActions = {}));
|
|
23225
|
+
|
|
23226
|
+
class UserFeedQueryStreamController extends QueryStreamController {
|
|
23227
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
23228
|
+
super(query, cacheKey);
|
|
23229
|
+
this.notifyChange = notifyChange;
|
|
23230
|
+
this.preparePayload = preparePayload;
|
|
23231
|
+
}
|
|
23232
|
+
async saveToMainDB(response) {
|
|
23233
|
+
const processedPayload = await this.preparePayload(response);
|
|
23234
|
+
const client = getActiveClient();
|
|
23235
|
+
const cachedAt = client.cache && Date.now();
|
|
23236
|
+
if (client.cache) {
|
|
23237
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
23238
|
+
}
|
|
23239
|
+
}
|
|
23240
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
23241
|
+
var _a, _b;
|
|
23242
|
+
if (refresh) {
|
|
23243
|
+
pushToCache(this.cacheKey, {
|
|
23244
|
+
data: response.posts.map(getResolver('post')),
|
|
23245
|
+
});
|
|
23246
|
+
}
|
|
23247
|
+
else {
|
|
23248
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
23249
|
+
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
23250
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
|
|
23251
|
+
}
|
|
23252
|
+
}
|
|
23253
|
+
reactor(action) {
|
|
23254
|
+
return (post) => {
|
|
23255
|
+
var _a, _b;
|
|
23256
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
23257
|
+
if (!collection)
|
|
23258
|
+
return;
|
|
23259
|
+
// if the collection is parent post collection and
|
|
23260
|
+
// post is not included in the collection or post is child post
|
|
23261
|
+
if ((!this.query.dataTypes || this.query.dataTypes.length === 0) &&
|
|
23262
|
+
!collection.data.includes(post.parentPostId ? post.parentPostId : post.postId))
|
|
23263
|
+
return;
|
|
23264
|
+
if (action === EnumPostActions.OnPostDeleted) {
|
|
23265
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
23266
|
+
}
|
|
23267
|
+
if (post.parentPostId && post.isDeleted) {
|
|
23268
|
+
const parentPost = (_b = pullFromCache([
|
|
23269
|
+
'post',
|
|
23270
|
+
'get',
|
|
23271
|
+
post.parentPostId,
|
|
23272
|
+
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
23273
|
+
if (!parentPost)
|
|
23274
|
+
return;
|
|
23275
|
+
parentPost.children = parentPost.children.filter(childId => childId !== post.postId);
|
|
23276
|
+
pushToCache(['post', 'get', parentPost.postId], parentPost);
|
|
23277
|
+
}
|
|
23278
|
+
if (action === EnumPostActions.OnPostDeclined) {
|
|
23279
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
23280
|
+
}
|
|
23281
|
+
if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
|
|
23282
|
+
if (this.query.dataTypes &&
|
|
23283
|
+
this.query.dataTypes.length > 0 &&
|
|
23284
|
+
!this.query.dataTypes.includes(post.dataType)) {
|
|
23285
|
+
return;
|
|
23286
|
+
}
|
|
23287
|
+
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
23288
|
+
}
|
|
23289
|
+
pushToCache(this.cacheKey, collection);
|
|
23290
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
23291
|
+
};
|
|
23292
|
+
}
|
|
23293
|
+
subscribeRTE(createSubscriber) {
|
|
23294
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
23295
|
+
}
|
|
23296
|
+
}
|
|
23184
23297
|
|
|
23185
23298
|
/* begin_public_function
|
|
23186
|
-
id:
|
|
23299
|
+
id: comment.get_by_ids
|
|
23187
23300
|
*/
|
|
23188
23301
|
/**
|
|
23189
23302
|
* ```js
|
|
23190
|
-
* import {
|
|
23191
|
-
* const
|
|
23303
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23304
|
+
* const comments = await CommentRepository.getCommentByIds(['foo', 'bar'])
|
|
23192
23305
|
* ```
|
|
23193
23306
|
*
|
|
23194
|
-
* Fetches a collection of {@link Amity.
|
|
23307
|
+
* Fetches a collection of {@link Amity.Comment} objects
|
|
23195
23308
|
*
|
|
23196
|
-
* @param
|
|
23197
|
-
* @returns the associated collection of {@link Amity.
|
|
23309
|
+
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
23310
|
+
* @returns the associated collection of {@link Amity.Comment} objects
|
|
23198
23311
|
*
|
|
23199
|
-
* @category
|
|
23312
|
+
* @category Comment API
|
|
23200
23313
|
* @async
|
|
23201
23314
|
*/
|
|
23202
|
-
const
|
|
23315
|
+
const getCommentByIds = async (commentIds) => {
|
|
23203
23316
|
const client = getActiveClient();
|
|
23204
|
-
client.log('
|
|
23205
|
-
const
|
|
23206
|
-
let
|
|
23317
|
+
client.log('comment/getCommentByIds', commentIds);
|
|
23318
|
+
const encodedCommentIds = commentIds.map(commentId => encodeURIComponent(commentId));
|
|
23319
|
+
let data;
|
|
23207
23320
|
try {
|
|
23208
23321
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
23209
|
-
const response = await client.http.get(`/api/v3/
|
|
23210
|
-
params: {
|
|
23322
|
+
const response = await client.http.get(`/api/v3/comments/list`, {
|
|
23323
|
+
params: { commentIds: encodedCommentIds },
|
|
23211
23324
|
});
|
|
23212
|
-
|
|
23325
|
+
data = response.data;
|
|
23213
23326
|
}
|
|
23214
23327
|
catch (error) {
|
|
23215
|
-
|
|
23328
|
+
commentIds.forEach(commentId => {
|
|
23216
23329
|
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
23217
|
-
pushToTombstone('
|
|
23330
|
+
pushToTombstone('comment', commentId);
|
|
23218
23331
|
}
|
|
23219
23332
|
});
|
|
23220
23333
|
throw error;
|
|
23221
23334
|
}
|
|
23222
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23223
23335
|
const cachedAt = client.cache && Date.now();
|
|
23224
23336
|
if (client.cache)
|
|
23225
23337
|
ingestInCache(data, { cachedAt });
|
|
23226
23338
|
return {
|
|
23227
|
-
data: data.
|
|
23339
|
+
data: data.comments.map(comment => LinkedObject.comment(comment)),
|
|
23228
23340
|
cachedAt,
|
|
23229
23341
|
};
|
|
23230
23342
|
};
|
|
23231
23343
|
/* end_public_function */
|
|
23232
23344
|
/**
|
|
23233
23345
|
* ```js
|
|
23234
|
-
* import {
|
|
23235
|
-
* const
|
|
23346
|
+
* import { getCommentByIds } from '@amityco/ts-sdk'
|
|
23347
|
+
* const comments = getCommentByIds.locally(['foo', 'bar'])
|
|
23236
23348
|
* ```
|
|
23237
23349
|
*
|
|
23238
|
-
* Fetches a collection of {@link Amity.
|
|
23350
|
+
* Fetches a collection of {@link Amity.Comment} objects from cache
|
|
23239
23351
|
*
|
|
23240
|
-
* @param
|
|
23241
|
-
* @returns the associated collection of {@link Amity.
|
|
23352
|
+
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
23353
|
+
* @returns the associated collection of {@link Amity.Comment} objects
|
|
23242
23354
|
*
|
|
23243
|
-
* @category
|
|
23355
|
+
* @category Comment API
|
|
23244
23356
|
*/
|
|
23245
|
-
|
|
23357
|
+
getCommentByIds.locally = (commentIds) => {
|
|
23246
23358
|
var _a;
|
|
23247
23359
|
const client = getActiveClient();
|
|
23248
|
-
client.log('
|
|
23360
|
+
client.log('comment/getCommentByIds.locally', commentIds);
|
|
23249
23361
|
if (!client.cache)
|
|
23250
23362
|
return;
|
|
23251
|
-
const cached =
|
|
23252
|
-
.map(
|
|
23363
|
+
const cached = commentIds
|
|
23364
|
+
.map(commentId => pullFromCache(['comment', 'get', commentId]))
|
|
23253
23365
|
.filter(Boolean);
|
|
23254
|
-
const
|
|
23366
|
+
const comments = cached.map(({ data }) => data);
|
|
23255
23367
|
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
23256
|
-
if ((cached === null || cached === void 0 ? void 0 : cached.length) <
|
|
23368
|
+
if ((cached === null || cached === void 0 ? void 0 : cached.length) < commentIds.length)
|
|
23257
23369
|
return;
|
|
23258
23370
|
return {
|
|
23259
|
-
data:
|
|
23371
|
+
data: comments.map(comment => LinkedObject.comment(comment)),
|
|
23260
23372
|
cachedAt: oldest.cachedAt,
|
|
23261
23373
|
};
|
|
23262
23374
|
};
|
|
23263
23375
|
|
|
23264
23376
|
/* begin_public_function
|
|
23265
|
-
id:
|
|
23377
|
+
id: comment.create
|
|
23266
23378
|
*/
|
|
23267
23379
|
/**
|
|
23268
23380
|
* ```js
|
|
23269
|
-
* import {
|
|
23270
|
-
* const
|
|
23271
|
-
* targetType: 'user',
|
|
23272
|
-
* targetId: 'foobar',
|
|
23273
|
-
* data: { text: 'hello world' }
|
|
23274
|
-
* }))
|
|
23381
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23382
|
+
* const newComment = await CommentRepository.createComment(bundle)
|
|
23275
23383
|
* ```
|
|
23276
23384
|
*
|
|
23277
|
-
* Creates an {@link Amity.
|
|
23385
|
+
* Creates an {@link Amity.Comment}
|
|
23278
23386
|
*
|
|
23279
|
-
* @param bundle The data necessary to create a new {@link Amity.
|
|
23280
|
-
* @returns The newly created {@link Amity.
|
|
23387
|
+
* @param bundle The data necessary to create a new {@link Amity.Comment}
|
|
23388
|
+
* @returns The newly created {@link Amity.Comment}
|
|
23281
23389
|
*
|
|
23282
|
-
* @category
|
|
23390
|
+
* @category Comment API
|
|
23283
23391
|
* @async
|
|
23284
23392
|
*/
|
|
23285
|
-
const
|
|
23393
|
+
const createComment = async (bundle) => {
|
|
23394
|
+
var _a;
|
|
23286
23395
|
const client = getActiveClient();
|
|
23287
|
-
client.log('
|
|
23288
|
-
|
|
23289
|
-
|
|
23290
|
-
|
|
23291
|
-
|
|
23292
|
-
|
|
23293
|
-
fireEvent('post.created', payload);
|
|
23294
|
-
const data = preparePostPayload(payload);
|
|
23396
|
+
client.log('comment/createComment', bundle);
|
|
23397
|
+
const { data } = await client.http.post('/api/v3/comments', bundle);
|
|
23398
|
+
const { comments } = data;
|
|
23399
|
+
// BE always returns an array of comments If it got record 0 from BE it might have a problem on creation logic
|
|
23400
|
+
if (comments.length === 0)
|
|
23401
|
+
throw new Error('Comment not created');
|
|
23295
23402
|
const cachedAt = client.cache && Date.now();
|
|
23296
23403
|
if (client.cache)
|
|
23297
23404
|
ingestInCache(data, { cachedAt });
|
|
23298
|
-
|
|
23405
|
+
if (['post', 'content'].includes(bundle.referenceType)) {
|
|
23406
|
+
const post = (_a = pullFromCache(['post', 'get', bundle.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
23407
|
+
if (post) {
|
|
23408
|
+
post.commentsCount += 1;
|
|
23409
|
+
fireEvent('local.post.updated', {
|
|
23410
|
+
posts: [post],
|
|
23411
|
+
categories: [],
|
|
23412
|
+
comments: [],
|
|
23413
|
+
communities: [],
|
|
23414
|
+
communityUsers: data.communityUsers,
|
|
23415
|
+
feeds: [],
|
|
23416
|
+
files: data.files,
|
|
23417
|
+
postChildren: [],
|
|
23418
|
+
users: data.users,
|
|
23419
|
+
videoStreamings: [],
|
|
23420
|
+
});
|
|
23421
|
+
}
|
|
23422
|
+
}
|
|
23423
|
+
else if (bundle.referenceType === 'story') {
|
|
23424
|
+
const storyIndex = pullFromCache([
|
|
23425
|
+
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
23426
|
+
bundle.referenceId,
|
|
23427
|
+
]);
|
|
23428
|
+
if (storyIndex === null || storyIndex === void 0 ? void 0 : storyIndex.data) {
|
|
23429
|
+
const cacheStory = pullFromCache([
|
|
23430
|
+
"story" /* STORY_KEY_CACHE.STORY */,
|
|
23431
|
+
'get',
|
|
23432
|
+
storyIndex.data,
|
|
23433
|
+
]);
|
|
23434
|
+
if (cacheStory === null || cacheStory === void 0 ? void 0 : cacheStory.data) {
|
|
23435
|
+
fireEvent('story.updated', {
|
|
23436
|
+
stories: [
|
|
23437
|
+
Object.assign(Object.assign({}, cacheStory.data), { commentsCount: cacheStory.data.commentsCount + 1, comments: [...new Set([...cacheStory.data.comments, comments[0].commentId])] }),
|
|
23438
|
+
],
|
|
23439
|
+
categories: [],
|
|
23440
|
+
comments,
|
|
23441
|
+
communities: [],
|
|
23442
|
+
communityUsers: data.communityUsers,
|
|
23443
|
+
files: data.files,
|
|
23444
|
+
users: data.users,
|
|
23445
|
+
});
|
|
23446
|
+
}
|
|
23447
|
+
}
|
|
23448
|
+
}
|
|
23449
|
+
fireEvent('local.comment.created', data);
|
|
23299
23450
|
return {
|
|
23300
|
-
data: LinkedObject.
|
|
23451
|
+
data: LinkedObject.comment(comments[0]),
|
|
23301
23452
|
cachedAt,
|
|
23302
23453
|
};
|
|
23303
23454
|
};
|
|
23304
23455
|
/* end_public_function */
|
|
23305
23456
|
|
|
23306
23457
|
/* begin_public_function
|
|
23307
|
-
id:
|
|
23458
|
+
id: comment.update_comment
|
|
23308
23459
|
*/
|
|
23309
23460
|
/**
|
|
23310
23461
|
* ```js
|
|
23311
|
-
* import {
|
|
23312
|
-
* const updated = await
|
|
23462
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23463
|
+
* const updated = await CommentRepository.updateComment(commentId, {
|
|
23313
23464
|
* data: { text: 'hello world' }
|
|
23314
23465
|
* })
|
|
23315
23466
|
* ```
|
|
23316
23467
|
*
|
|
23317
|
-
* Updates an {@link Amity.
|
|
23468
|
+
* Updates an {@link Amity.Comment}
|
|
23318
23469
|
*
|
|
23319
|
-
* @param
|
|
23470
|
+
* @param commentId The ID of the {@link Amity.Comment} to edit
|
|
23320
23471
|
* @param patch The patch data to apply
|
|
23321
|
-
* @returns the updated {@link Amity.
|
|
23472
|
+
* @returns the updated {@link Amity.Comment} object
|
|
23322
23473
|
*
|
|
23323
|
-
* @category
|
|
23474
|
+
* @category Comment API
|
|
23324
23475
|
* @async
|
|
23325
23476
|
*/
|
|
23326
|
-
const
|
|
23477
|
+
const updateComment = async (commentId, patch) => {
|
|
23327
23478
|
const client = getActiveClient();
|
|
23328
|
-
client.log('user/
|
|
23329
|
-
const { data
|
|
23330
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23479
|
+
client.log('user/updateComment', patch);
|
|
23480
|
+
const { data } = await client.http.put(`/api/v3/comments/${encodeURIComponent(commentId)}`, patch);
|
|
23331
23481
|
const cachedAt = client.cache && Date.now();
|
|
23332
23482
|
if (client.cache)
|
|
23333
23483
|
ingestInCache(data, { cachedAt });
|
|
23334
|
-
fireEvent('
|
|
23335
|
-
const {
|
|
23484
|
+
fireEvent('comment.updated', data);
|
|
23485
|
+
const { comments } = data;
|
|
23336
23486
|
return {
|
|
23337
|
-
data: LinkedObject.
|
|
23487
|
+
data: LinkedObject.comment(comments.find(comment => comment.commentId === commentId)),
|
|
23338
23488
|
cachedAt,
|
|
23339
23489
|
};
|
|
23340
23490
|
};
|
|
23341
23491
|
/* end_public_function */
|
|
23342
23492
|
|
|
23493
|
+
// Due to we have optimistic logic, we will use referenceId as a id in SDK instead of storyId
|
|
23494
|
+
const applyMissingField = (rawData, isCreated = false) => {
|
|
23495
|
+
const { storyId, referenceId } = rawData;
|
|
23496
|
+
if (!isCreated) {
|
|
23497
|
+
if (referenceId)
|
|
23498
|
+
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */ });
|
|
23499
|
+
}
|
|
23500
|
+
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */, referenceId: storyId });
|
|
23501
|
+
};
|
|
23502
|
+
const convertRawStoryToInternal = (data, isCreated = false) => {
|
|
23503
|
+
const { stories } = data;
|
|
23504
|
+
const storiesData = stories.map(story => applyMissingField(story, isCreated));
|
|
23505
|
+
return Object.assign(Object.assign({}, data), { stories: storiesData });
|
|
23506
|
+
};
|
|
23507
|
+
|
|
23508
|
+
const getStoryByStoryId$1 = async (storyId) => {
|
|
23509
|
+
const client = getActiveClient();
|
|
23510
|
+
client.log('story/getStoryByStoryId', storyId);
|
|
23511
|
+
// Get story referenceId from cache
|
|
23512
|
+
const cacheReferenceId = pullFromCache([
|
|
23513
|
+
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
23514
|
+
storyId,
|
|
23515
|
+
]);
|
|
23516
|
+
if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
|
|
23517
|
+
const { data: referenceId } = cacheReferenceId;
|
|
23518
|
+
isInTombstone('story', referenceId);
|
|
23519
|
+
}
|
|
23520
|
+
let data;
|
|
23521
|
+
try {
|
|
23522
|
+
const response = await client.http.get(`/api/v4/stories/${storyId}`);
|
|
23523
|
+
data = convertRawStoryToInternal(response.data);
|
|
23524
|
+
}
|
|
23525
|
+
catch (error) {
|
|
23526
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
23527
|
+
pushToTombstone('story', storyId);
|
|
23528
|
+
}
|
|
23529
|
+
throw error;
|
|
23530
|
+
}
|
|
23531
|
+
const cachedAt = client.cache && Date.now();
|
|
23532
|
+
if (client.cache) {
|
|
23533
|
+
ingestInCache(data, { cachedAt });
|
|
23534
|
+
}
|
|
23535
|
+
return {
|
|
23536
|
+
data: data.stories[0],
|
|
23537
|
+
cachedAt,
|
|
23538
|
+
};
|
|
23539
|
+
};
|
|
23540
|
+
getStoryByStoryId$1.locally = (storyId) => {
|
|
23541
|
+
const client = getActiveClient();
|
|
23542
|
+
client.log('story/getStorybyStoryId', storyId);
|
|
23543
|
+
// Get story referenceId from cache
|
|
23544
|
+
const cacheReferenceId = pullFromCache([
|
|
23545
|
+
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
23546
|
+
storyId,
|
|
23547
|
+
]);
|
|
23548
|
+
if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
|
|
23549
|
+
const { data: referenceId } = cacheReferenceId;
|
|
23550
|
+
isInTombstone('story', referenceId);
|
|
23551
|
+
}
|
|
23552
|
+
const cachedAt = client.cache && Date.now();
|
|
23553
|
+
const storyCache = pullFromCache(['story', 'get', storyId]);
|
|
23554
|
+
if (!storyCache)
|
|
23555
|
+
return;
|
|
23556
|
+
return {
|
|
23557
|
+
data: storyCache.data,
|
|
23558
|
+
cachedAt,
|
|
23559
|
+
};
|
|
23560
|
+
};
|
|
23561
|
+
|
|
23562
|
+
/* begin_public_function
|
|
23563
|
+
id: comment.soft_delete, comment.hard_delete
|
|
23564
|
+
*/
|
|
23343
23565
|
/**
|
|
23344
23566
|
* ```js
|
|
23345
|
-
* import {
|
|
23346
|
-
* const success = await
|
|
23567
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23568
|
+
* const success = await CommentRepository.deleteComment('foobar')
|
|
23347
23569
|
* ```
|
|
23348
23570
|
*
|
|
23349
|
-
* Deletes a {@link Amity.
|
|
23571
|
+
* Deletes a {@link Amity.Comment}
|
|
23350
23572
|
*
|
|
23351
|
-
* @param
|
|
23352
|
-
* @return A success boolean if the {@link Amity.
|
|
23573
|
+
* @param commentId The {@link Amity.Comment} ID to delete
|
|
23574
|
+
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
23353
23575
|
*
|
|
23354
|
-
* @
|
|
23576
|
+
* @category Comment API
|
|
23355
23577
|
* @async
|
|
23356
23578
|
*/
|
|
23357
|
-
const
|
|
23579
|
+
const deleteComment = async (commentId, permanent = false) => {
|
|
23358
23580
|
var _a;
|
|
23359
23581
|
const client = getActiveClient();
|
|
23360
|
-
const
|
|
23361
|
-
|
|
23582
|
+
const comment = await getComment$2(commentId);
|
|
23583
|
+
// API-FIX: This endpoint has not been implemented yet.
|
|
23584
|
+
await client.http.delete(`/api/v4/comments/${encodeURIComponent(commentId)}`, {
|
|
23362
23585
|
params: {
|
|
23363
|
-
|
|
23586
|
+
commentId,
|
|
23364
23587
|
permanent,
|
|
23365
23588
|
},
|
|
23366
23589
|
});
|
|
23367
|
-
//
|
|
23368
|
-
|
|
23369
|
-
|
|
23370
|
-
|
|
23371
|
-
|
|
23372
|
-
|
|
23373
|
-
const communityUsersCache = (_a = queryCache(['communityUsers', 'get'])) !== null && _a !== void 0 ? _a : [];
|
|
23374
|
-
const communityUsers = communityUsersCache
|
|
23375
|
-
.filter(({ key }) => {
|
|
23376
|
-
// cache key is ['communityUsers', 'get', `${communityId}#`${userId}`}]
|
|
23377
|
-
if (key[0] !== 'communityUsers')
|
|
23378
|
-
return false;
|
|
23379
|
-
if (key[1] !== 'get')
|
|
23380
|
-
return false;
|
|
23381
|
-
if (typeof key[2] === 'string')
|
|
23382
|
-
return key[2].includes(community.data.communityId);
|
|
23383
|
-
return false;
|
|
23384
|
-
})
|
|
23385
|
-
.map(({ data }) => data);
|
|
23386
|
-
fireEvent('community.updated', {
|
|
23387
|
-
communities: [community.data],
|
|
23590
|
+
// to support hard deletion
|
|
23591
|
+
const deleted = Object.assign(Object.assign({}, comment.data), { isDeleted: true });
|
|
23592
|
+
if (comment.data.referenceType === 'story') {
|
|
23593
|
+
const story = await getStoryByStoryId$1(comment.data.referenceId);
|
|
23594
|
+
fireEvent('local.story.updated', {
|
|
23595
|
+
stories: [story.data],
|
|
23388
23596
|
categories: [],
|
|
23389
|
-
|
|
23390
|
-
|
|
23597
|
+
comments: [],
|
|
23598
|
+
communities: [],
|
|
23599
|
+
communityUsers: [],
|
|
23391
23600
|
files: [],
|
|
23392
23601
|
users: [],
|
|
23393
23602
|
});
|
|
23394
23603
|
}
|
|
23395
|
-
// to support hard deletion
|
|
23396
|
-
const deleted = Object.assign(Object.assign({}, post.data), { isDeleted: true });
|
|
23397
|
-
if (permanent) {
|
|
23398
|
-
setTimeout(() => {
|
|
23399
|
-
pushToTombstone('post', postId);
|
|
23400
|
-
}, 0);
|
|
23401
|
-
}
|
|
23402
23604
|
else {
|
|
23403
|
-
|
|
23605
|
+
const post = (_a = pullFromCache(['post', 'get', comment.data.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
23606
|
+
if (post) {
|
|
23607
|
+
let removeCount;
|
|
23608
|
+
if (!deleted.parentId) {
|
|
23609
|
+
// NOTE: delete the parent comment will remove all children comments
|
|
23610
|
+
removeCount = deleted.childrenNumber + 1;
|
|
23611
|
+
}
|
|
23612
|
+
else
|
|
23613
|
+
removeCount = 1;
|
|
23614
|
+
post.commentsCount -= removeCount;
|
|
23615
|
+
fireEvent('local.post.updated', {
|
|
23616
|
+
posts: [post],
|
|
23617
|
+
categories: [],
|
|
23618
|
+
comments: [],
|
|
23619
|
+
communities: [],
|
|
23620
|
+
communityUsers: [],
|
|
23621
|
+
feeds: [],
|
|
23622
|
+
files: [],
|
|
23623
|
+
postChildren: [],
|
|
23624
|
+
users: [],
|
|
23625
|
+
videoStreamings: [],
|
|
23626
|
+
});
|
|
23627
|
+
}
|
|
23404
23628
|
}
|
|
23405
|
-
fireEvent('local.
|
|
23406
|
-
|
|
23407
|
-
|
|
23408
|
-
comments: [],
|
|
23409
|
-
communities: [],
|
|
23410
|
-
communityUsers: [],
|
|
23411
|
-
feeds: [],
|
|
23629
|
+
fireEvent('local.comment.deleted', {
|
|
23630
|
+
comments: [deleted],
|
|
23631
|
+
commentChildren: [],
|
|
23412
23632
|
files: [],
|
|
23413
|
-
postChildren: [],
|
|
23414
23633
|
users: [],
|
|
23415
|
-
|
|
23634
|
+
communityUsers: [],
|
|
23416
23635
|
});
|
|
23417
|
-
|
|
23636
|
+
if (permanent) {
|
|
23637
|
+
scheduleTask(() => pushToTombstone('comment', commentId));
|
|
23638
|
+
}
|
|
23639
|
+
else {
|
|
23640
|
+
upsertInCache(['comment', 'get', commentId], { isDeleted: true });
|
|
23641
|
+
}
|
|
23642
|
+
return deleted;
|
|
23418
23643
|
};
|
|
23644
|
+
/* end_public_function */
|
|
23419
23645
|
|
|
23420
23646
|
/* begin_public_function
|
|
23421
|
-
id:
|
|
23647
|
+
id: comment.soft_delete
|
|
23422
23648
|
*/
|
|
23423
23649
|
/**
|
|
23424
23650
|
* ```js
|
|
23425
|
-
* import {
|
|
23426
|
-
* const success = await
|
|
23651
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23652
|
+
* const success = await CommentRepository.softDeleteComment('foobar')
|
|
23427
23653
|
* ```
|
|
23428
23654
|
*
|
|
23429
|
-
*
|
|
23655
|
+
* Deletes a {@link Amity.Comment}
|
|
23430
23656
|
*
|
|
23431
|
-
* @param
|
|
23432
|
-
* @return A success boolean if the {@link Amity.
|
|
23657
|
+
* @param commentId The {@link Amity.Comment} ID to delete
|
|
23658
|
+
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
23433
23659
|
*
|
|
23434
|
-
* @category
|
|
23660
|
+
* @category Comment API
|
|
23435
23661
|
* @async
|
|
23436
23662
|
*/
|
|
23437
|
-
const
|
|
23663
|
+
const softDeleteComment = async (commentId) => {
|
|
23438
23664
|
const client = getActiveClient();
|
|
23439
|
-
client.log('
|
|
23440
|
-
const softDeleted =
|
|
23441
|
-
return
|
|
23665
|
+
client.log('comment/softDeleteComment', commentId);
|
|
23666
|
+
const softDeleted = deleteComment(commentId);
|
|
23667
|
+
return softDeleted;
|
|
23442
23668
|
};
|
|
23443
23669
|
/* end_public_function */
|
|
23444
23670
|
|
|
23445
23671
|
/* begin_public_function
|
|
23446
|
-
id:
|
|
23672
|
+
id: comment.hard_delete
|
|
23447
23673
|
*/
|
|
23448
23674
|
/**
|
|
23449
23675
|
* ```js
|
|
23450
|
-
* import {
|
|
23451
|
-
* const success = await
|
|
23676
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23677
|
+
* const success = await CommentRepository.hardDeleteComment('foobar')
|
|
23452
23678
|
* ```
|
|
23453
23679
|
*
|
|
23454
|
-
*
|
|
23680
|
+
* Deletes a {@link Amity.Comment}
|
|
23455
23681
|
*
|
|
23456
|
-
* @param
|
|
23457
|
-
* @return A success boolean if the {@link Amity.
|
|
23682
|
+
* @param commentId The {@link Amity.Comment} ID to delete
|
|
23683
|
+
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
23458
23684
|
*
|
|
23459
|
-
* @category
|
|
23685
|
+
* @category Comment API
|
|
23460
23686
|
* @async
|
|
23461
23687
|
*/
|
|
23462
|
-
const
|
|
23688
|
+
const hardDeleteComment = async (commentId) => {
|
|
23463
23689
|
const client = getActiveClient();
|
|
23464
|
-
client.log('
|
|
23465
|
-
const hardDeleted =
|
|
23466
|
-
return
|
|
23690
|
+
client.log('comment/hardDeleteComment', commentId);
|
|
23691
|
+
const hardDeleted = deleteComment(commentId, true);
|
|
23692
|
+
return hardDeleted;
|
|
23467
23693
|
};
|
|
23468
23694
|
/* end_public_function */
|
|
23469
23695
|
|
|
23470
23696
|
/* begin_public_function
|
|
23471
|
-
id:
|
|
23697
|
+
id: comment.flag
|
|
23472
23698
|
*/
|
|
23473
23699
|
/**
|
|
23474
23700
|
* ```js
|
|
23475
|
-
* import {
|
|
23476
|
-
*
|
|
23477
|
-
* const { data: post } = await approvePost('postId')
|
|
23701
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23702
|
+
* const flagged = await CommentRepository.flagComment(commentId, reason)
|
|
23478
23703
|
* ```
|
|
23479
23704
|
*
|
|
23480
|
-
*
|
|
23481
|
-
*
|
|
23482
|
-
* @
|
|
23483
|
-
* @return A {@link Amity.Post} that was approved
|
|
23705
|
+
* @param commentId The ID of the comment to flag
|
|
23706
|
+
* @param reason the reason to flag the comment
|
|
23707
|
+
* @returns the created report result
|
|
23484
23708
|
*
|
|
23485
|
-
* @category
|
|
23709
|
+
* @category Comment API
|
|
23486
23710
|
* @async
|
|
23487
|
-
*/
|
|
23488
|
-
const
|
|
23711
|
+
* */
|
|
23712
|
+
const flagComment = async (commentId, reason) => {
|
|
23489
23713
|
const client = getActiveClient();
|
|
23490
|
-
client.log('
|
|
23491
|
-
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/approve`);
|
|
23492
|
-
fireEvent('post.approved', payload);
|
|
23493
|
-
// fire virtual event for community update
|
|
23494
|
-
if (payload.posts[0].targetType === 'community') {
|
|
23495
|
-
fireEvent('community.updated', payload);
|
|
23496
|
-
}
|
|
23497
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23498
|
-
const cachedAt = client.cache && Date.now();
|
|
23499
|
-
if (client.cache)
|
|
23500
|
-
ingestInCache(data, { cachedAt });
|
|
23501
|
-
return {
|
|
23502
|
-
data: LinkedObject.post(data.posts.find(post => post.postId === postId)),
|
|
23503
|
-
cachedAt,
|
|
23504
|
-
};
|
|
23505
|
-
};
|
|
23506
|
-
/* end_public_function */
|
|
23507
|
-
|
|
23508
|
-
/* begin_public_function
|
|
23509
|
-
id: post.decline
|
|
23510
|
-
*/
|
|
23511
|
-
/**
|
|
23512
|
-
* ```js
|
|
23513
|
-
* import { declinePost } from '@amityco/ts-sdk'
|
|
23514
|
-
*
|
|
23515
|
-
* const {data: post} = await declinePost('postId')
|
|
23516
|
-
* ```
|
|
23517
|
-
*
|
|
23518
|
-
* Declines a {@link Amity.Post}
|
|
23519
|
-
*
|
|
23520
|
-
* @param postId The {@link Amity.Post} ID to be declined
|
|
23521
|
-
* @return A {@link Amity.Post} that was declined
|
|
23522
|
-
*
|
|
23523
|
-
* @category Post API
|
|
23524
|
-
* @async
|
|
23525
|
-
*/
|
|
23526
|
-
const declinePost = async (postId) => {
|
|
23527
|
-
const client = getActiveClient();
|
|
23528
|
-
client.log('post/declinePost', postId);
|
|
23529
|
-
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/decline`);
|
|
23530
|
-
// fire virtual event
|
|
23531
|
-
if (payload.posts[0].targetType === 'community') {
|
|
23532
|
-
fireEvent('community.updated', payload);
|
|
23533
|
-
}
|
|
23534
|
-
fireEvent('post.declined', payload);
|
|
23535
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23536
|
-
const cachedAt = client.cache && Date.now();
|
|
23537
|
-
if (client.cache)
|
|
23538
|
-
ingestInCache(data, { cachedAt });
|
|
23539
|
-
return {
|
|
23540
|
-
data: LinkedObject.post(payload.posts.find(post => post.postId === postId)),
|
|
23541
|
-
cachedAt,
|
|
23542
|
-
};
|
|
23543
|
-
};
|
|
23544
|
-
/* end_public_function */
|
|
23545
|
-
|
|
23546
|
-
/* begin_public_function
|
|
23547
|
-
id: post.flag
|
|
23548
|
-
*/
|
|
23549
|
-
/**
|
|
23550
|
-
* ```js
|
|
23551
|
-
* import { PostRepository } from '@amityco/ts-sdk'
|
|
23552
|
-
* const flagged = await PostRepository.flagPost(postId, reason)
|
|
23553
|
-
* ```
|
|
23554
|
-
*
|
|
23555
|
-
* @param postId of the post to flag
|
|
23556
|
-
* @param reason the reason to flag the post
|
|
23557
|
-
* @returns a boolean
|
|
23558
|
-
*
|
|
23559
|
-
* @category Post API
|
|
23560
|
-
* @async
|
|
23561
|
-
* */
|
|
23562
|
-
const flagPost = async (postId, reason) => {
|
|
23563
|
-
const client = getActiveClient();
|
|
23564
|
-
client.log('post/flagPost', postId);
|
|
23714
|
+
client.log('comment/flagComment', commentId);
|
|
23565
23715
|
const isPredefinedReason = reason &&
|
|
23566
23716
|
Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
|
|
23567
23717
|
const body = {
|
|
23568
23718
|
reason: reason && isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
|
|
23569
23719
|
detail: reason && !isPredefinedReason ? reason : '',
|
|
23570
23720
|
};
|
|
23571
|
-
const { data: payload } = await client.http.post(`/api/v3/
|
|
23721
|
+
const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
|
|
23572
23722
|
if (client.cache) {
|
|
23573
|
-
ingestInCache(
|
|
23723
|
+
ingestInCache(payload);
|
|
23574
23724
|
}
|
|
23575
|
-
fireEvent('
|
|
23725
|
+
fireEvent('comment.flagged', payload);
|
|
23576
23726
|
return !!payload;
|
|
23577
23727
|
};
|
|
23578
23728
|
/* end_public_function */
|
|
23579
23729
|
|
|
23580
23730
|
/* begin_public_function
|
|
23581
|
-
id:
|
|
23731
|
+
id: comment.unflag
|
|
23582
23732
|
*/
|
|
23583
23733
|
/**
|
|
23584
23734
|
* ```js
|
|
23585
|
-
* import {
|
|
23586
|
-
* const unflagged = await
|
|
23735
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23736
|
+
* const unflagged = await CommentRepository.unflagComment('commentId')
|
|
23587
23737
|
* ```
|
|
23588
23738
|
*
|
|
23589
|
-
* @param
|
|
23590
|
-
* @returns the
|
|
23739
|
+
* @param commentId The ID of comment to unflag
|
|
23740
|
+
* @returns the unflagged result
|
|
23591
23741
|
*
|
|
23592
|
-
* @category
|
|
23742
|
+
* @category Comment API
|
|
23593
23743
|
* @async
|
|
23594
23744
|
* */
|
|
23595
|
-
const
|
|
23745
|
+
const unflagComment = async (commentId) => {
|
|
23596
23746
|
const client = getActiveClient();
|
|
23597
|
-
client.log('
|
|
23598
|
-
const { data: payload } = await client.http.delete(`/api/v3/
|
|
23747
|
+
client.log('comment/unflagComment', commentId);
|
|
23748
|
+
const { data: payload } = await client.http.delete(`/api/v3/comments/${encodeURIComponent(commentId)}/unflag`);
|
|
23599
23749
|
if (client.cache) {
|
|
23600
|
-
ingestInCache(
|
|
23750
|
+
ingestInCache(payload);
|
|
23601
23751
|
}
|
|
23602
|
-
fireEvent('
|
|
23752
|
+
fireEvent('comment.unflagged', payload);
|
|
23603
23753
|
return !!payload;
|
|
23604
23754
|
};
|
|
23605
23755
|
/* end_public_function */
|
|
23606
23756
|
|
|
23607
23757
|
/* begin_public_function
|
|
23608
|
-
id:
|
|
23758
|
+
id: comment.check_flag_by_me
|
|
23609
23759
|
*/
|
|
23610
23760
|
/**
|
|
23611
23761
|
* ```js
|
|
23612
|
-
* import {
|
|
23613
|
-
* const isReported = await
|
|
23762
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23763
|
+
* const isReported = await CommentRepository.isCommentFlaggedByMe('commentId')
|
|
23614
23764
|
* ```
|
|
23615
23765
|
*
|
|
23616
|
-
* @param
|
|
23617
|
-
* @returns `true` if the
|
|
23766
|
+
* @param commentId The ID of the comment to check if flagged by current user
|
|
23767
|
+
* @returns `true` if the comment is flagged by me, `false` if doesn't.
|
|
23618
23768
|
*
|
|
23619
|
-
* @category
|
|
23769
|
+
* @category Comment API
|
|
23620
23770
|
* @async
|
|
23621
23771
|
* */
|
|
23622
|
-
const
|
|
23772
|
+
const isCommentFlaggedByMe = async (commentId) => {
|
|
23623
23773
|
const client = getActiveClient();
|
|
23624
|
-
client.log('
|
|
23625
|
-
const { data: { result }, } = await client.http.get(`/api/v3/
|
|
23774
|
+
client.log('comment/isCommentFlaggedByMe', commentId);
|
|
23775
|
+
const { data: { result }, } = await client.http.get(`/api/v3/comments/${commentId}/isflagbyme`);
|
|
23626
23776
|
return result;
|
|
23627
23777
|
};
|
|
23628
23778
|
/* end_public_function */
|
|
23629
23779
|
|
|
23630
|
-
|
|
23631
|
-
id: post.create.clip_post
|
|
23632
|
-
*/
|
|
23633
|
-
/**
|
|
23634
|
-
* ```js
|
|
23635
|
-
* import { PostRepository } from '@amityco/ts-sdk'
|
|
23636
|
-
* const created = await PostRepository.createClipPost({
|
|
23637
|
-
* targetType: 'user',
|
|
23638
|
-
* targetId: 'foobar',
|
|
23639
|
-
* dataType: 'clip',
|
|
23640
|
-
* data: { text: 'hello world' },
|
|
23641
|
-
* attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
|
|
23642
|
-
* }))
|
|
23643
|
-
* ```
|
|
23644
|
-
*
|
|
23645
|
-
* Creates an {@link Amity.Post}
|
|
23646
|
-
*
|
|
23647
|
-
* @param bundle The data necessary to create a new {@link Amity.Post}
|
|
23648
|
-
* @returns The newly created {@link Amity.Post}
|
|
23649
|
-
*
|
|
23650
|
-
* @category Post API
|
|
23651
|
-
* @async
|
|
23652
|
-
*/
|
|
23653
|
-
const createClipPost = async (bundle) => {
|
|
23654
|
-
const client = getActiveClient();
|
|
23655
|
-
client.log('post/createPost', bundle);
|
|
23656
|
-
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
23657
|
-
fireEvent('post.created', payload);
|
|
23658
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23659
|
-
const cachedAt = client.cache && Date.now();
|
|
23660
|
-
if (client.cache)
|
|
23661
|
-
ingestInCache(data, { cachedAt });
|
|
23662
|
-
const { posts } = data;
|
|
23663
|
-
return {
|
|
23664
|
-
data: LinkedObject.post(posts[0]),
|
|
23665
|
-
cachedAt,
|
|
23666
|
-
};
|
|
23667
|
-
};
|
|
23668
|
-
/* end_public_function */
|
|
23669
|
-
|
|
23670
|
-
/* begin_public_function
|
|
23671
|
-
id: comment.get_by_ids
|
|
23672
|
-
*/
|
|
23673
|
-
/**
|
|
23674
|
-
* ```js
|
|
23675
|
-
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23676
|
-
* const comments = await CommentRepository.getCommentByIds(['foo', 'bar'])
|
|
23677
|
-
* ```
|
|
23678
|
-
*
|
|
23679
|
-
* Fetches a collection of {@link Amity.Comment} objects
|
|
23680
|
-
*
|
|
23681
|
-
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
23682
|
-
* @returns the associated collection of {@link Amity.Comment} objects
|
|
23683
|
-
*
|
|
23684
|
-
* @category Comment API
|
|
23685
|
-
* @async
|
|
23686
|
-
*/
|
|
23687
|
-
const getCommentByIds = async (commentIds) => {
|
|
23780
|
+
const getComment$1 = async (commentId) => {
|
|
23688
23781
|
const client = getActiveClient();
|
|
23689
|
-
client.log('comment/
|
|
23690
|
-
|
|
23782
|
+
client.log('comment/getComment', commentId);
|
|
23783
|
+
isInTombstone('comment', commentId);
|
|
23691
23784
|
let data;
|
|
23692
23785
|
try {
|
|
23693
23786
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
23694
|
-
const response = await client.http.get(`/api/v3/comments
|
|
23695
|
-
params: { commentIds: encodedCommentIds },
|
|
23696
|
-
});
|
|
23787
|
+
const response = await client.http.get(`/api/v3/comments/${encodeURIComponent(commentId)}`);
|
|
23697
23788
|
data = response.data;
|
|
23698
23789
|
}
|
|
23699
23790
|
catch (error) {
|
|
23700
|
-
|
|
23701
|
-
|
|
23702
|
-
|
|
23703
|
-
}
|
|
23704
|
-
});
|
|
23791
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
23792
|
+
pushToTombstone('comment', commentId);
|
|
23793
|
+
}
|
|
23705
23794
|
throw error;
|
|
23706
23795
|
}
|
|
23707
23796
|
const cachedAt = client.cache && Date.now();
|
|
23708
23797
|
if (client.cache)
|
|
23709
23798
|
ingestInCache(data, { cachedAt });
|
|
23799
|
+
const { comments } = data;
|
|
23710
23800
|
return {
|
|
23711
|
-
data:
|
|
23801
|
+
data: comments.find(comment => comment.commentId === commentId),
|
|
23712
23802
|
cachedAt,
|
|
23713
23803
|
};
|
|
23714
23804
|
};
|
|
23715
|
-
|
|
23716
|
-
/**
|
|
23717
|
-
* ```js
|
|
23718
|
-
* import { getCommentByIds } from '@amityco/ts-sdk'
|
|
23719
|
-
* const comments = getCommentByIds.locally(['foo', 'bar'])
|
|
23720
|
-
* ```
|
|
23721
|
-
*
|
|
23722
|
-
* Fetches a collection of {@link Amity.Comment} objects from cache
|
|
23723
|
-
*
|
|
23724
|
-
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
23725
|
-
* @returns the associated collection of {@link Amity.Comment} objects
|
|
23726
|
-
*
|
|
23727
|
-
* @category Comment API
|
|
23728
|
-
*/
|
|
23729
|
-
getCommentByIds.locally = (commentIds) => {
|
|
23730
|
-
var _a;
|
|
23805
|
+
getComment$1.locally = (commentId) => {
|
|
23731
23806
|
const client = getActiveClient();
|
|
23732
|
-
client.log('comment/
|
|
23807
|
+
client.log('comment/getComment.locally', commentId);
|
|
23733
23808
|
if (!client.cache)
|
|
23734
23809
|
return;
|
|
23735
|
-
const cached =
|
|
23736
|
-
|
|
23737
|
-
.filter(Boolean);
|
|
23738
|
-
const comments = cached.map(({ data }) => data);
|
|
23739
|
-
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
23740
|
-
if ((cached === null || cached === void 0 ? void 0 : cached.length) < commentIds.length)
|
|
23810
|
+
const cached = pullFromCache(['comment', 'get', commentId]);
|
|
23811
|
+
if (!cached)
|
|
23741
23812
|
return;
|
|
23742
23813
|
return {
|
|
23743
|
-
data:
|
|
23744
|
-
cachedAt:
|
|
23814
|
+
data: cached.data,
|
|
23815
|
+
cachedAt: cached.cachedAt,
|
|
23745
23816
|
};
|
|
23746
23817
|
};
|
|
23747
23818
|
|
|
23748
|
-
/* begin_public_function
|
|
23749
|
-
id: comment.create
|
|
23750
|
-
*/
|
|
23751
23819
|
/**
|
|
23752
23820
|
* ```js
|
|
23753
|
-
* import {
|
|
23754
|
-
* const
|
|
23821
|
+
* import { onCommentDeleteLocal } from '@amityco/ts-sdk'
|
|
23822
|
+
* const dispose = onCommentDeleteLocal(comment => {
|
|
23823
|
+
* // ...
|
|
23824
|
+
* })
|
|
23755
23825
|
* ```
|
|
23756
23826
|
*
|
|
23757
|
-
*
|
|
23827
|
+
* Fired when a {@link Amity.InternalComment} has been deleted
|
|
23758
23828
|
*
|
|
23759
|
-
* @param
|
|
23760
|
-
* @returns
|
|
23829
|
+
* @param callback The function to call when the event was fired
|
|
23830
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
23761
23831
|
*
|
|
23762
|
-
* @category Comment
|
|
23763
|
-
* @async
|
|
23832
|
+
* @category Comment Events
|
|
23764
23833
|
*/
|
|
23765
|
-
const
|
|
23766
|
-
var _a;
|
|
23767
|
-
const client = getActiveClient();
|
|
23768
|
-
client.log('comment/createComment', bundle);
|
|
23769
|
-
const { data } = await client.http.post('/api/v3/comments', bundle);
|
|
23770
|
-
const { comments } = data;
|
|
23771
|
-
// BE always returns an array of comments If it got record 0 from BE it might have a problem on creation logic
|
|
23772
|
-
if (comments.length === 0)
|
|
23773
|
-
throw new Error('Comment not created');
|
|
23774
|
-
const cachedAt = client.cache && Date.now();
|
|
23775
|
-
if (client.cache)
|
|
23776
|
-
ingestInCache(data, { cachedAt });
|
|
23777
|
-
if (['post', 'content'].includes(bundle.referenceType)) {
|
|
23778
|
-
const post = (_a = pullFromCache(['post', 'get', bundle.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
23779
|
-
if (post) {
|
|
23780
|
-
post.commentsCount += 1;
|
|
23781
|
-
fireEvent('local.post.updated', {
|
|
23782
|
-
posts: [post],
|
|
23783
|
-
categories: [],
|
|
23784
|
-
comments: [],
|
|
23785
|
-
communities: [],
|
|
23786
|
-
communityUsers: data.communityUsers,
|
|
23787
|
-
feeds: [],
|
|
23788
|
-
files: data.files,
|
|
23789
|
-
postChildren: [],
|
|
23790
|
-
users: data.users,
|
|
23791
|
-
videoStreamings: [],
|
|
23792
|
-
});
|
|
23793
|
-
}
|
|
23794
|
-
}
|
|
23795
|
-
else if (bundle.referenceType === 'story') {
|
|
23796
|
-
const storyIndex = pullFromCache([
|
|
23797
|
-
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
23798
|
-
bundle.referenceId,
|
|
23799
|
-
]);
|
|
23800
|
-
if (storyIndex === null || storyIndex === void 0 ? void 0 : storyIndex.data) {
|
|
23801
|
-
const cacheStory = pullFromCache([
|
|
23802
|
-
"story" /* STORY_KEY_CACHE.STORY */,
|
|
23803
|
-
'get',
|
|
23804
|
-
storyIndex.data,
|
|
23805
|
-
]);
|
|
23806
|
-
if (cacheStory === null || cacheStory === void 0 ? void 0 : cacheStory.data) {
|
|
23807
|
-
fireEvent('story.updated', {
|
|
23808
|
-
stories: [
|
|
23809
|
-
Object.assign(Object.assign({}, cacheStory.data), { commentsCount: cacheStory.data.commentsCount + 1, comments: [...new Set([...cacheStory.data.comments, comments[0].commentId])] }),
|
|
23810
|
-
],
|
|
23811
|
-
categories: [],
|
|
23812
|
-
comments,
|
|
23813
|
-
communities: [],
|
|
23814
|
-
communityUsers: data.communityUsers,
|
|
23815
|
-
files: data.files,
|
|
23816
|
-
users: data.users,
|
|
23817
|
-
});
|
|
23818
|
-
}
|
|
23819
|
-
}
|
|
23820
|
-
}
|
|
23821
|
-
fireEvent('local.comment.created', data);
|
|
23822
|
-
return {
|
|
23823
|
-
data: LinkedObject.comment(comments[0]),
|
|
23824
|
-
cachedAt,
|
|
23825
|
-
};
|
|
23826
|
-
};
|
|
23827
|
-
/* end_public_function */
|
|
23834
|
+
const onCommentDeleteLocal = (callback) => createLocalCommentEventSubscriber('local.comment.deleted', callback);
|
|
23828
23835
|
|
|
23829
|
-
/* begin_public_function
|
|
23830
|
-
id: comment.update_comment
|
|
23831
|
-
*/
|
|
23832
23836
|
/**
|
|
23833
23837
|
* ```js
|
|
23834
|
-
* import {
|
|
23835
|
-
* const
|
|
23836
|
-
*
|
|
23838
|
+
* import { onLocalCommentReactionAdded } from '@amityco/ts-sdk'
|
|
23839
|
+
* const dispose = onLocalCommentReactionAdded(comment => {
|
|
23840
|
+
* // ...
|
|
23837
23841
|
* })
|
|
23838
23842
|
* ```
|
|
23839
23843
|
*
|
|
23840
|
-
*
|
|
23844
|
+
* Fired when a {@link Amity.InternalComment} has been reacted
|
|
23841
23845
|
*
|
|
23842
|
-
* @param
|
|
23843
|
-
* @
|
|
23844
|
-
* @returns the updated {@link Amity.Comment} object
|
|
23846
|
+
* @param callback The function to call when the event was fired
|
|
23847
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
23845
23848
|
*
|
|
23846
|
-
* @category Comment
|
|
23847
|
-
* @async
|
|
23849
|
+
* @category Comment Events
|
|
23848
23850
|
*/
|
|
23849
|
-
const
|
|
23850
|
-
const client = getActiveClient();
|
|
23851
|
-
client.log('user/updateComment', patch);
|
|
23852
|
-
const { data } = await client.http.put(`/api/v3/comments/${encodeURIComponent(commentId)}`, patch);
|
|
23853
|
-
const cachedAt = client.cache && Date.now();
|
|
23854
|
-
if (client.cache)
|
|
23855
|
-
ingestInCache(data, { cachedAt });
|
|
23856
|
-
fireEvent('comment.updated', data);
|
|
23857
|
-
const { comments } = data;
|
|
23858
|
-
return {
|
|
23859
|
-
data: LinkedObject.comment(comments.find(comment => comment.commentId === commentId)),
|
|
23860
|
-
cachedAt,
|
|
23861
|
-
};
|
|
23862
|
-
};
|
|
23863
|
-
/* end_public_function */
|
|
23864
|
-
|
|
23865
|
-
// Due to we have optimistic logic, we will use referenceId as a id in SDK instead of storyId
|
|
23866
|
-
const applyMissingField = (rawData, isCreated = false) => {
|
|
23867
|
-
const { storyId, referenceId } = rawData;
|
|
23868
|
-
if (!isCreated) {
|
|
23869
|
-
if (referenceId)
|
|
23870
|
-
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */ });
|
|
23871
|
-
}
|
|
23872
|
-
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */, referenceId: storyId });
|
|
23873
|
-
};
|
|
23874
|
-
const convertRawStoryToInternal = (data, isCreated = false) => {
|
|
23875
|
-
const { stories } = data;
|
|
23876
|
-
const storiesData = stories.map(story => applyMissingField(story, isCreated));
|
|
23877
|
-
return Object.assign(Object.assign({}, data), { stories: storiesData });
|
|
23878
|
-
};
|
|
23879
|
-
|
|
23880
|
-
const getStoryByStoryId$1 = async (storyId) => {
|
|
23851
|
+
const onLocalCommentReactionAdded = (callback) => {
|
|
23881
23852
|
const client = getActiveClient();
|
|
23882
|
-
|
|
23883
|
-
|
|
23884
|
-
|
|
23885
|
-
|
|
23886
|
-
|
|
23887
|
-
|
|
23888
|
-
|
|
23889
|
-
const { data: referenceId } = cacheReferenceId;
|
|
23890
|
-
isInTombstone('story', referenceId);
|
|
23891
|
-
}
|
|
23892
|
-
let data;
|
|
23893
|
-
try {
|
|
23894
|
-
const response = await client.http.get(`/api/v4/stories/${storyId}`);
|
|
23895
|
-
data = convertRawStoryToInternal(response.data);
|
|
23896
|
-
}
|
|
23897
|
-
catch (error) {
|
|
23898
|
-
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
23899
|
-
pushToTombstone('story', storyId);
|
|
23853
|
+
const filter = ({ comment }) => {
|
|
23854
|
+
if (!client.cache) {
|
|
23855
|
+
callback(comment);
|
|
23856
|
+
}
|
|
23857
|
+
else {
|
|
23858
|
+
upsertInCache(['comment', 'get', comment.commentId], comment);
|
|
23859
|
+
callback(commentLinkedObject(comment));
|
|
23900
23860
|
}
|
|
23901
|
-
throw error;
|
|
23902
|
-
}
|
|
23903
|
-
const cachedAt = client.cache && Date.now();
|
|
23904
|
-
if (client.cache) {
|
|
23905
|
-
ingestInCache(data, { cachedAt });
|
|
23906
|
-
}
|
|
23907
|
-
return {
|
|
23908
|
-
data: data.stories[0],
|
|
23909
|
-
cachedAt,
|
|
23910
|
-
};
|
|
23911
|
-
};
|
|
23912
|
-
getStoryByStoryId$1.locally = (storyId) => {
|
|
23913
|
-
const client = getActiveClient();
|
|
23914
|
-
client.log('story/getStorybyStoryId', storyId);
|
|
23915
|
-
// Get story referenceId from cache
|
|
23916
|
-
const cacheReferenceId = pullFromCache([
|
|
23917
|
-
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
23918
|
-
storyId,
|
|
23919
|
-
]);
|
|
23920
|
-
if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
|
|
23921
|
-
const { data: referenceId } = cacheReferenceId;
|
|
23922
|
-
isInTombstone('story', referenceId);
|
|
23923
|
-
}
|
|
23924
|
-
const cachedAt = client.cache && Date.now();
|
|
23925
|
-
const storyCache = pullFromCache(['story', 'get', storyId]);
|
|
23926
|
-
if (!storyCache)
|
|
23927
|
-
return;
|
|
23928
|
-
return {
|
|
23929
|
-
data: storyCache.data,
|
|
23930
|
-
cachedAt,
|
|
23931
23861
|
};
|
|
23862
|
+
return createEventSubscriber(client, 'local.comment.addReaction', 'local.comment.addReaction', filter);
|
|
23932
23863
|
};
|
|
23933
23864
|
|
|
23934
|
-
/* begin_public_function
|
|
23935
|
-
id: comment.soft_delete, comment.hard_delete
|
|
23936
|
-
*/
|
|
23937
23865
|
/**
|
|
23938
23866
|
* ```js
|
|
23939
|
-
* import {
|
|
23940
|
-
* const
|
|
23867
|
+
* import { onLocalCommentReactionRemoved } from '@amityco/ts-sdk'
|
|
23868
|
+
* const dispose = onLocalCommentReactionRemoved(comment => {
|
|
23869
|
+
* // ...
|
|
23870
|
+
* })
|
|
23941
23871
|
* ```
|
|
23942
23872
|
*
|
|
23943
|
-
*
|
|
23873
|
+
* Fired when a {@link Amity.InternalComment} has been reacted
|
|
23944
23874
|
*
|
|
23945
|
-
* @param
|
|
23946
|
-
* @
|
|
23875
|
+
* @param callback The function to call when the event was fired
|
|
23876
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
23947
23877
|
*
|
|
23948
|
-
* @category Comment
|
|
23949
|
-
* @async
|
|
23878
|
+
* @category Comment Events
|
|
23950
23879
|
*/
|
|
23951
|
-
const
|
|
23952
|
-
var _a;
|
|
23880
|
+
const onLocalCommentReactionRemoved = (callback) => {
|
|
23953
23881
|
const client = getActiveClient();
|
|
23954
|
-
const
|
|
23955
|
-
|
|
23956
|
-
|
|
23957
|
-
params: {
|
|
23958
|
-
commentId,
|
|
23959
|
-
permanent,
|
|
23960
|
-
},
|
|
23961
|
-
});
|
|
23962
|
-
// to support hard deletion
|
|
23963
|
-
const deleted = Object.assign(Object.assign({}, comment.data), { isDeleted: true });
|
|
23964
|
-
if (comment.data.referenceType === 'story') {
|
|
23965
|
-
const story = await getStoryByStoryId$1(comment.data.referenceId);
|
|
23966
|
-
fireEvent('local.story.updated', {
|
|
23967
|
-
stories: [story.data],
|
|
23968
|
-
categories: [],
|
|
23969
|
-
comments: [],
|
|
23970
|
-
communities: [],
|
|
23971
|
-
communityUsers: [],
|
|
23972
|
-
files: [],
|
|
23973
|
-
users: [],
|
|
23974
|
-
});
|
|
23975
|
-
}
|
|
23976
|
-
else {
|
|
23977
|
-
const post = (_a = pullFromCache(['post', 'get', comment.data.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
23978
|
-
if (post) {
|
|
23979
|
-
let removeCount;
|
|
23980
|
-
if (!deleted.parentId) {
|
|
23981
|
-
// NOTE: delete the parent comment will remove all children comments
|
|
23982
|
-
removeCount = deleted.childrenNumber + 1;
|
|
23983
|
-
}
|
|
23984
|
-
else
|
|
23985
|
-
removeCount = 1;
|
|
23986
|
-
post.commentsCount -= removeCount;
|
|
23987
|
-
fireEvent('local.post.updated', {
|
|
23988
|
-
posts: [post],
|
|
23989
|
-
categories: [],
|
|
23990
|
-
comments: [],
|
|
23991
|
-
communities: [],
|
|
23992
|
-
communityUsers: [],
|
|
23993
|
-
feeds: [],
|
|
23994
|
-
files: [],
|
|
23995
|
-
postChildren: [],
|
|
23996
|
-
users: [],
|
|
23997
|
-
videoStreamings: [],
|
|
23998
|
-
});
|
|
23882
|
+
const filter = ({ comment }) => {
|
|
23883
|
+
if (!client.cache) {
|
|
23884
|
+
callback(comment);
|
|
23999
23885
|
}
|
|
24000
|
-
|
|
24001
|
-
|
|
24002
|
-
|
|
24003
|
-
|
|
24004
|
-
|
|
24005
|
-
|
|
24006
|
-
communityUsers: [],
|
|
24007
|
-
});
|
|
24008
|
-
if (permanent) {
|
|
24009
|
-
scheduleTask(() => pushToTombstone('comment', commentId));
|
|
24010
|
-
}
|
|
24011
|
-
else {
|
|
24012
|
-
upsertInCache(['comment', 'get', commentId], { isDeleted: true });
|
|
24013
|
-
}
|
|
24014
|
-
return deleted;
|
|
23886
|
+
else {
|
|
23887
|
+
upsertInCache(['comment', 'get', comment.commentId], comment);
|
|
23888
|
+
callback(commentLinkedObject(comment));
|
|
23889
|
+
}
|
|
23890
|
+
};
|
|
23891
|
+
return createEventSubscriber(client, 'local.comment.removeReaction', 'local.comment.removeReaction', filter);
|
|
24015
23892
|
};
|
|
24016
|
-
/* end_public_function */
|
|
24017
23893
|
|
|
24018
23894
|
/* begin_public_function
|
|
24019
|
-
id: comment.
|
|
23895
|
+
id: comment.get
|
|
24020
23896
|
*/
|
|
24021
23897
|
/**
|
|
24022
23898
|
* ```js
|
|
24023
|
-
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
24024
|
-
* const success = await CommentRepository.softDeleteComment('foobar')
|
|
24025
|
-
* ```
|
|
24026
|
-
*
|
|
24027
|
-
* Deletes a {@link Amity.Comment}
|
|
23899
|
+
* import { CommentRepository } from '@amityco/ts-sdk';
|
|
24028
23900
|
*
|
|
24029
|
-
*
|
|
24030
|
-
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
24031
|
-
*
|
|
24032
|
-
* @category Comment API
|
|
24033
|
-
* @async
|
|
24034
|
-
*/
|
|
24035
|
-
const softDeleteComment = async (commentId) => {
|
|
24036
|
-
const client = getActiveClient();
|
|
24037
|
-
client.log('comment/softDeleteComment', commentId);
|
|
24038
|
-
const softDeleted = deleteComment(commentId);
|
|
24039
|
-
return softDeleted;
|
|
24040
|
-
};
|
|
24041
|
-
/* end_public_function */
|
|
24042
|
-
|
|
24043
|
-
/* begin_public_function
|
|
24044
|
-
id: comment.hard_delete
|
|
24045
|
-
*/
|
|
24046
|
-
/**
|
|
24047
|
-
* ```js
|
|
24048
|
-
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
24049
|
-
* const success = await CommentRepository.hardDeleteComment('foobar')
|
|
24050
|
-
* ```
|
|
24051
|
-
*
|
|
24052
|
-
* Deletes a {@link Amity.Comment}
|
|
24053
|
-
*
|
|
24054
|
-
* @param commentId The {@link Amity.Comment} ID to delete
|
|
24055
|
-
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
24056
|
-
*
|
|
24057
|
-
* @category Comment API
|
|
24058
|
-
* @async
|
|
24059
|
-
*/
|
|
24060
|
-
const hardDeleteComment = async (commentId) => {
|
|
24061
|
-
const client = getActiveClient();
|
|
24062
|
-
client.log('comment/hardDeleteComment', commentId);
|
|
24063
|
-
const hardDeleted = deleteComment(commentId, true);
|
|
24064
|
-
return hardDeleted;
|
|
24065
|
-
};
|
|
24066
|
-
/* end_public_function */
|
|
24067
|
-
|
|
24068
|
-
/* begin_public_function
|
|
24069
|
-
id: comment.flag
|
|
24070
|
-
*/
|
|
24071
|
-
/**
|
|
24072
|
-
* ```js
|
|
24073
|
-
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
24074
|
-
* const flagged = await CommentRepository.flagComment(commentId, reason)
|
|
24075
|
-
* ```
|
|
24076
|
-
*
|
|
24077
|
-
* @param commentId The ID of the comment to flag
|
|
24078
|
-
* @param reason the reason to flag the comment
|
|
24079
|
-
* @returns the created report result
|
|
24080
|
-
*
|
|
24081
|
-
* @category Comment API
|
|
24082
|
-
* @async
|
|
24083
|
-
* */
|
|
24084
|
-
const flagComment = async (commentId, reason) => {
|
|
24085
|
-
const client = getActiveClient();
|
|
24086
|
-
client.log('comment/flagComment', commentId);
|
|
24087
|
-
const isPredefinedReason = reason &&
|
|
24088
|
-
Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
|
|
24089
|
-
const body = {
|
|
24090
|
-
reason: reason && isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
|
|
24091
|
-
detail: reason && !isPredefinedReason ? reason : '',
|
|
24092
|
-
};
|
|
24093
|
-
const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
|
|
24094
|
-
if (client.cache) {
|
|
24095
|
-
ingestInCache(payload);
|
|
24096
|
-
}
|
|
24097
|
-
fireEvent('comment.flagged', payload);
|
|
24098
|
-
return !!payload;
|
|
24099
|
-
};
|
|
24100
|
-
/* end_public_function */
|
|
24101
|
-
|
|
24102
|
-
/* begin_public_function
|
|
24103
|
-
id: comment.unflag
|
|
24104
|
-
*/
|
|
24105
|
-
/**
|
|
24106
|
-
* ```js
|
|
24107
|
-
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
24108
|
-
* const unflagged = await CommentRepository.unflagComment('commentId')
|
|
24109
|
-
* ```
|
|
24110
|
-
*
|
|
24111
|
-
* @param commentId The ID of comment to unflag
|
|
24112
|
-
* @returns the unflagged result
|
|
24113
|
-
*
|
|
24114
|
-
* @category Comment API
|
|
24115
|
-
* @async
|
|
24116
|
-
* */
|
|
24117
|
-
const unflagComment = async (commentId) => {
|
|
24118
|
-
const client = getActiveClient();
|
|
24119
|
-
client.log('comment/unflagComment', commentId);
|
|
24120
|
-
const { data: payload } = await client.http.delete(`/api/v3/comments/${encodeURIComponent(commentId)}/unflag`);
|
|
24121
|
-
if (client.cache) {
|
|
24122
|
-
ingestInCache(payload);
|
|
24123
|
-
}
|
|
24124
|
-
fireEvent('comment.unflagged', payload);
|
|
24125
|
-
return !!payload;
|
|
24126
|
-
};
|
|
24127
|
-
/* end_public_function */
|
|
24128
|
-
|
|
24129
|
-
/* begin_public_function
|
|
24130
|
-
id: comment.check_flag_by_me
|
|
24131
|
-
*/
|
|
24132
|
-
/**
|
|
24133
|
-
* ```js
|
|
24134
|
-
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
24135
|
-
* const isReported = await CommentRepository.isCommentFlaggedByMe('commentId')
|
|
24136
|
-
* ```
|
|
24137
|
-
*
|
|
24138
|
-
* @param commentId The ID of the comment to check if flagged by current user
|
|
24139
|
-
* @returns `true` if the comment is flagged by me, `false` if doesn't.
|
|
24140
|
-
*
|
|
24141
|
-
* @category Comment API
|
|
24142
|
-
* @async
|
|
24143
|
-
* */
|
|
24144
|
-
const isCommentFlaggedByMe = async (commentId) => {
|
|
24145
|
-
const client = getActiveClient();
|
|
24146
|
-
client.log('comment/isCommentFlaggedByMe', commentId);
|
|
24147
|
-
const { data: { result }, } = await client.http.get(`/api/v3/comments/${commentId}/isflagbyme`);
|
|
24148
|
-
return result;
|
|
24149
|
-
};
|
|
24150
|
-
/* end_public_function */
|
|
24151
|
-
|
|
24152
|
-
const getComment$1 = async (commentId) => {
|
|
24153
|
-
const client = getActiveClient();
|
|
24154
|
-
client.log('comment/getComment', commentId);
|
|
24155
|
-
isInTombstone('comment', commentId);
|
|
24156
|
-
let data;
|
|
24157
|
-
try {
|
|
24158
|
-
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
24159
|
-
const response = await client.http.get(`/api/v3/comments/${encodeURIComponent(commentId)}`);
|
|
24160
|
-
data = response.data;
|
|
24161
|
-
}
|
|
24162
|
-
catch (error) {
|
|
24163
|
-
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
24164
|
-
pushToTombstone('comment', commentId);
|
|
24165
|
-
}
|
|
24166
|
-
throw error;
|
|
24167
|
-
}
|
|
24168
|
-
const cachedAt = client.cache && Date.now();
|
|
24169
|
-
if (client.cache)
|
|
24170
|
-
ingestInCache(data, { cachedAt });
|
|
24171
|
-
const { comments } = data;
|
|
24172
|
-
return {
|
|
24173
|
-
data: comments.find(comment => comment.commentId === commentId),
|
|
24174
|
-
cachedAt,
|
|
24175
|
-
};
|
|
24176
|
-
};
|
|
24177
|
-
getComment$1.locally = (commentId) => {
|
|
24178
|
-
const client = getActiveClient();
|
|
24179
|
-
client.log('comment/getComment.locally', commentId);
|
|
24180
|
-
if (!client.cache)
|
|
24181
|
-
return;
|
|
24182
|
-
const cached = pullFromCache(['comment', 'get', commentId]);
|
|
24183
|
-
if (!cached)
|
|
24184
|
-
return;
|
|
24185
|
-
return {
|
|
24186
|
-
data: cached.data,
|
|
24187
|
-
cachedAt: cached.cachedAt,
|
|
24188
|
-
};
|
|
24189
|
-
};
|
|
24190
|
-
|
|
24191
|
-
/**
|
|
24192
|
-
* ```js
|
|
24193
|
-
* import { onCommentDeleteLocal } from '@amityco/ts-sdk'
|
|
24194
|
-
* const dispose = onCommentDeleteLocal(comment => {
|
|
24195
|
-
* // ...
|
|
24196
|
-
* })
|
|
24197
|
-
* ```
|
|
24198
|
-
*
|
|
24199
|
-
* Fired when a {@link Amity.InternalComment} has been deleted
|
|
24200
|
-
*
|
|
24201
|
-
* @param callback The function to call when the event was fired
|
|
24202
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24203
|
-
*
|
|
24204
|
-
* @category Comment Events
|
|
24205
|
-
*/
|
|
24206
|
-
const onCommentDeleteLocal = (callback) => createLocalCommentEventSubscriber('local.comment.deleted', callback);
|
|
24207
|
-
|
|
24208
|
-
/**
|
|
24209
|
-
* ```js
|
|
24210
|
-
* import { onLocalCommentReactionAdded } from '@amityco/ts-sdk'
|
|
24211
|
-
* const dispose = onLocalCommentReactionAdded(comment => {
|
|
24212
|
-
* // ...
|
|
24213
|
-
* })
|
|
24214
|
-
* ```
|
|
24215
|
-
*
|
|
24216
|
-
* Fired when a {@link Amity.InternalComment} has been reacted
|
|
24217
|
-
*
|
|
24218
|
-
* @param callback The function to call when the event was fired
|
|
24219
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24220
|
-
*
|
|
24221
|
-
* @category Comment Events
|
|
24222
|
-
*/
|
|
24223
|
-
const onLocalCommentReactionAdded = (callback) => {
|
|
24224
|
-
const client = getActiveClient();
|
|
24225
|
-
const filter = ({ comment }) => {
|
|
24226
|
-
if (!client.cache) {
|
|
24227
|
-
callback(comment);
|
|
24228
|
-
}
|
|
24229
|
-
else {
|
|
24230
|
-
upsertInCache(['comment', 'get', comment.commentId], comment);
|
|
24231
|
-
callback(commentLinkedObject(comment));
|
|
24232
|
-
}
|
|
24233
|
-
};
|
|
24234
|
-
return createEventSubscriber(client, 'local.comment.addReaction', 'local.comment.addReaction', filter);
|
|
24235
|
-
};
|
|
24236
|
-
|
|
24237
|
-
/**
|
|
24238
|
-
* ```js
|
|
24239
|
-
* import { onLocalCommentReactionRemoved } from '@amityco/ts-sdk'
|
|
24240
|
-
* const dispose = onLocalCommentReactionRemoved(comment => {
|
|
24241
|
-
* // ...
|
|
24242
|
-
* })
|
|
24243
|
-
* ```
|
|
24244
|
-
*
|
|
24245
|
-
* Fired when a {@link Amity.InternalComment} has been reacted
|
|
24246
|
-
*
|
|
24247
|
-
* @param callback The function to call when the event was fired
|
|
24248
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24249
|
-
*
|
|
24250
|
-
* @category Comment Events
|
|
24251
|
-
*/
|
|
24252
|
-
const onLocalCommentReactionRemoved = (callback) => {
|
|
24253
|
-
const client = getActiveClient();
|
|
24254
|
-
const filter = ({ comment }) => {
|
|
24255
|
-
if (!client.cache) {
|
|
24256
|
-
callback(comment);
|
|
24257
|
-
}
|
|
24258
|
-
else {
|
|
24259
|
-
upsertInCache(['comment', 'get', comment.commentId], comment);
|
|
24260
|
-
callback(commentLinkedObject(comment));
|
|
24261
|
-
}
|
|
24262
|
-
};
|
|
24263
|
-
return createEventSubscriber(client, 'local.comment.removeReaction', 'local.comment.removeReaction', filter);
|
|
24264
|
-
};
|
|
24265
|
-
|
|
24266
|
-
/* begin_public_function
|
|
24267
|
-
id: comment.get
|
|
24268
|
-
*/
|
|
24269
|
-
/**
|
|
24270
|
-
* ```js
|
|
24271
|
-
* import { CommentRepository } from '@amityco/ts-sdk';
|
|
24272
|
-
*
|
|
24273
|
-
* let comment;
|
|
23901
|
+
* let comment;
|
|
24274
23902
|
*
|
|
24275
23903
|
* const unsub = CommentRepository.getComment(commentId, response => {
|
|
24276
23904
|
* comment = response.data;
|
|
@@ -24545,7 +24173,7 @@ const getComments = (params, callback, config) => {
|
|
|
24545
24173
|
};
|
|
24546
24174
|
/* end_public_function */
|
|
24547
24175
|
|
|
24548
|
-
var index$
|
|
24176
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
24549
24177
|
__proto__: null,
|
|
24550
24178
|
getCommentByIds: getCommentByIds,
|
|
24551
24179
|
createComment: createComment,
|
|
@@ -24567,97 +24195,783 @@ var index$9 = /*#__PURE__*/Object.freeze({
|
|
|
24567
24195
|
getComments: getComments
|
|
24568
24196
|
});
|
|
24569
24197
|
|
|
24198
|
+
const getPost$1 = async (postId) => {
|
|
24199
|
+
const client = getActiveClient();
|
|
24200
|
+
client.log('post/getPost', postId);
|
|
24201
|
+
isInTombstone('post', postId);
|
|
24202
|
+
let payload;
|
|
24203
|
+
try {
|
|
24204
|
+
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
24205
|
+
const response = await client.http.get(`/api/v3/posts/${encodeURIComponent(postId)}`);
|
|
24206
|
+
payload = response.data;
|
|
24207
|
+
}
|
|
24208
|
+
catch (error) {
|
|
24209
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
24210
|
+
pushToTombstone('post', postId);
|
|
24211
|
+
}
|
|
24212
|
+
throw error;
|
|
24213
|
+
}
|
|
24214
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
24215
|
+
const cachedAt = client.cache && Date.now();
|
|
24216
|
+
if (client.cache)
|
|
24217
|
+
ingestInCache(data, { cachedAt });
|
|
24218
|
+
const { posts } = data;
|
|
24219
|
+
const result = posts.find(post => post.postId === postId);
|
|
24220
|
+
return {
|
|
24221
|
+
data: result,
|
|
24222
|
+
cachedAt,
|
|
24223
|
+
};
|
|
24224
|
+
};
|
|
24225
|
+
getPost$1.locally = (postId) => {
|
|
24226
|
+
const client = getActiveClient();
|
|
24227
|
+
client.log('post/getPost.locally', postId);
|
|
24228
|
+
if (!client.cache)
|
|
24229
|
+
return;
|
|
24230
|
+
const cached = pullFromCache(['post', 'get', postId]);
|
|
24231
|
+
if (!cached)
|
|
24232
|
+
return;
|
|
24233
|
+
return {
|
|
24234
|
+
data: cached.data,
|
|
24235
|
+
cachedAt: cached.cachedAt,
|
|
24236
|
+
};
|
|
24237
|
+
};
|
|
24238
|
+
|
|
24239
|
+
/**
|
|
24240
|
+
* ```js
|
|
24241
|
+
* import { onPostUpdatedLocal } from '@amityco/ts-sdk'
|
|
24242
|
+
* const dispose = onPostUpdatedLocal(post => {
|
|
24243
|
+
* // ...
|
|
24244
|
+
* })
|
|
24245
|
+
* ```
|
|
24246
|
+
*
|
|
24247
|
+
* Fired when a {@link Amity.InternalPost} has been updated
|
|
24248
|
+
*
|
|
24249
|
+
* @param callback The function to call when the event was fired
|
|
24250
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24251
|
+
*
|
|
24252
|
+
* @category Post Events
|
|
24253
|
+
*/
|
|
24254
|
+
const onPostUpdatedLocal = (callback) => createLocalPostEventSubscriber('local.post.updated', callback);
|
|
24255
|
+
|
|
24256
|
+
/**
|
|
24257
|
+
* ```js
|
|
24258
|
+
* import { onLocalPostReactionAdded } from '@amityco/ts-sdk'
|
|
24259
|
+
* const dispose = onPostReactionAdded(post => {
|
|
24260
|
+
* // ...
|
|
24261
|
+
* })
|
|
24262
|
+
* ```
|
|
24263
|
+
*
|
|
24264
|
+
* Fired when a {@link Amity.InternalPost} has been reacted
|
|
24265
|
+
*
|
|
24266
|
+
* @param callback The function to call when the event was fired
|
|
24267
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24268
|
+
*
|
|
24269
|
+
* @category Post Events
|
|
24270
|
+
*/
|
|
24271
|
+
const onLocalPostReactionAdded = (callback) => {
|
|
24272
|
+
const client = getActiveClient();
|
|
24273
|
+
const filter = ({ post }) => {
|
|
24274
|
+
if (!client.cache) {
|
|
24275
|
+
callback(post);
|
|
24276
|
+
}
|
|
24277
|
+
else {
|
|
24278
|
+
upsertInCache(['post', 'get', post.postId], post);
|
|
24279
|
+
callback(post);
|
|
24280
|
+
}
|
|
24281
|
+
};
|
|
24282
|
+
return createEventSubscriber(client, 'local.post.addReaction', 'local.post.addReaction', filter);
|
|
24283
|
+
};
|
|
24284
|
+
|
|
24285
|
+
/**
|
|
24286
|
+
* ```js
|
|
24287
|
+
* import { onLocalPostReactionRemoved } from '@amityco/ts-sdk'
|
|
24288
|
+
* const dispose = onPostReactionRemoved(post => {
|
|
24289
|
+
* // ...
|
|
24290
|
+
* })
|
|
24291
|
+
* ```
|
|
24292
|
+
*
|
|
24293
|
+
* Fired when a {@link Amity.InternalPost} has been reacted
|
|
24294
|
+
*
|
|
24295
|
+
* @param callback The function to call when the event was fired
|
|
24296
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24297
|
+
*
|
|
24298
|
+
* @category Post Events
|
|
24299
|
+
*/
|
|
24300
|
+
const onLocalPostReactionRemoved = (callback) => {
|
|
24301
|
+
const client = getActiveClient();
|
|
24302
|
+
const filter = ({ post }) => {
|
|
24303
|
+
if (!client.cache) {
|
|
24304
|
+
callback(post);
|
|
24305
|
+
}
|
|
24306
|
+
else {
|
|
24307
|
+
upsertInCache(['post', 'get', post.postId], post);
|
|
24308
|
+
callback(post);
|
|
24309
|
+
}
|
|
24310
|
+
};
|
|
24311
|
+
return createEventSubscriber(client, 'local.post.removeReaction', 'local.post.removeReaction', filter);
|
|
24312
|
+
};
|
|
24313
|
+
|
|
24314
|
+
/**
|
|
24315
|
+
* ```js
|
|
24316
|
+
* import { onLocalPostDeleted } from '@amityco/ts-sdk'
|
|
24317
|
+
* const dispose = onLocalPostDeleted(post => {
|
|
24318
|
+
* // ...
|
|
24319
|
+
* })
|
|
24320
|
+
* ```
|
|
24321
|
+
*
|
|
24322
|
+
* Fired when a {@link Amity.InternalPost} has been deleted
|
|
24323
|
+
*
|
|
24324
|
+
* @param callback The function to call when the event was fired
|
|
24325
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24326
|
+
*
|
|
24327
|
+
* @category Post Events
|
|
24328
|
+
*/
|
|
24329
|
+
const onLocalPostDeleted = (callback) => createLocalPostEventSubscriber('local.post.deleted', callback);
|
|
24330
|
+
|
|
24331
|
+
class UserFeedLiveCollectionController extends LiveCollectionController {
|
|
24332
|
+
constructor(query, callback) {
|
|
24333
|
+
const queryStreamId = hash__default["default"](query);
|
|
24334
|
+
const cacheKey = ['userFeed', 'collection', queryStreamId];
|
|
24335
|
+
const paginationController = new UserFeedPaginationController(query);
|
|
24336
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
24337
|
+
this.query = query;
|
|
24338
|
+
this.queryStreamController = new UserFeedQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
24339
|
+
this.callback = callback.bind(this);
|
|
24340
|
+
this.loadPage({ initial: true });
|
|
24341
|
+
}
|
|
24342
|
+
setup() {
|
|
24343
|
+
var _a;
|
|
24344
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24345
|
+
if (!collection) {
|
|
24346
|
+
pushToCache(this.cacheKey, {
|
|
24347
|
+
data: [],
|
|
24348
|
+
params: {},
|
|
24349
|
+
});
|
|
24350
|
+
}
|
|
24351
|
+
}
|
|
24352
|
+
async persistModel(queryPayload) {
|
|
24353
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
24354
|
+
}
|
|
24355
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
24356
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
24357
|
+
}
|
|
24358
|
+
startSubscription() {
|
|
24359
|
+
return this.queryStreamController.subscribeRTE([
|
|
24360
|
+
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
24361
|
+
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
24362
|
+
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
24363
|
+
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
24364
|
+
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
24365
|
+
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
24366
|
+
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
24367
|
+
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
24368
|
+
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
24369
|
+
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
24370
|
+
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
24371
|
+
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
24372
|
+
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
24373
|
+
{
|
|
24374
|
+
fn: convertEventPayload((callback) => {
|
|
24375
|
+
return onCommentCreated(async (comment) => {
|
|
24376
|
+
var _a;
|
|
24377
|
+
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24378
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
24379
|
+
return;
|
|
24380
|
+
await getPost$1(comment.referenceId);
|
|
24381
|
+
callback(comment);
|
|
24382
|
+
});
|
|
24383
|
+
}, 'referenceId', 'post'),
|
|
24384
|
+
action: EnumPostActions.OnPostUpdated,
|
|
24385
|
+
},
|
|
24386
|
+
{
|
|
24387
|
+
fn: convertEventPayload((callback) => {
|
|
24388
|
+
return onCommentDeleted(async (comment) => {
|
|
24389
|
+
var _a;
|
|
24390
|
+
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24391
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
24392
|
+
return;
|
|
24393
|
+
await getPost$1(comment.referenceId);
|
|
24394
|
+
callback(comment);
|
|
24395
|
+
});
|
|
24396
|
+
}, 'referenceId', 'post'),
|
|
24397
|
+
action: EnumPostActions.OnPostUpdated,
|
|
24398
|
+
},
|
|
24399
|
+
]);
|
|
24400
|
+
}
|
|
24401
|
+
notifyChange({ origin, loading, error }) {
|
|
24402
|
+
var _a, _b;
|
|
24403
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24404
|
+
if (!collection)
|
|
24405
|
+
return;
|
|
24406
|
+
const data = this.applyFilter((_b = collection.data
|
|
24407
|
+
.map(id => pullFromCache(['post', 'get', id]))
|
|
24408
|
+
.filter(isNonNullable)
|
|
24409
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
24410
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
24411
|
+
return;
|
|
24412
|
+
this.callback({
|
|
24413
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
24414
|
+
data,
|
|
24415
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
24416
|
+
loading,
|
|
24417
|
+
error,
|
|
24418
|
+
});
|
|
24419
|
+
}
|
|
24420
|
+
applyFilter(data) {
|
|
24421
|
+
var _a;
|
|
24422
|
+
let posts = data;
|
|
24423
|
+
if (!this.query.includeDeleted) {
|
|
24424
|
+
posts = filterByPropEquality(posts, 'isDeleted', false);
|
|
24425
|
+
}
|
|
24426
|
+
if ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.length) {
|
|
24427
|
+
posts = filterByPostDataTypes(posts, this.query.dataTypes);
|
|
24428
|
+
}
|
|
24429
|
+
switch (this.query.sortBy) {
|
|
24430
|
+
case 'firstCreated':
|
|
24431
|
+
posts = posts.sort(sortByFirstCreated);
|
|
24432
|
+
break;
|
|
24433
|
+
case 'lastCreated':
|
|
24434
|
+
default:
|
|
24435
|
+
posts = posts.sort(sortByLastCreated);
|
|
24436
|
+
break;
|
|
24437
|
+
}
|
|
24438
|
+
return posts;
|
|
24439
|
+
}
|
|
24440
|
+
}
|
|
24441
|
+
|
|
24442
|
+
/* begin_public_function
|
|
24443
|
+
id: feed.query.user_feed
|
|
24444
|
+
*/
|
|
24445
|
+
/**
|
|
24446
|
+
* ```js
|
|
24447
|
+
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
24448
|
+
*
|
|
24449
|
+
* let posts = []
|
|
24450
|
+
* const unsubscribe = FeedRepository.getUserFeed({
|
|
24451
|
+
* userId: string,
|
|
24452
|
+
* feedSources: ['user', 'community'],
|
|
24453
|
+
* }, response => response => processResponse(response))
|
|
24454
|
+
* ```
|
|
24455
|
+
*
|
|
24456
|
+
* Observe all mutations on a list of {@link Amity.Post} for a given user and feedSources
|
|
24457
|
+
*
|
|
24458
|
+
* @param params.userId the ID of the user
|
|
24459
|
+
* @param params.feedSources the sources of the feed
|
|
24460
|
+
* @param callback the function to call when new data are available
|
|
24461
|
+
* @param config
|
|
24462
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
24463
|
+
*
|
|
24464
|
+
* @category Posts Live Collection
|
|
24465
|
+
*/
|
|
24466
|
+
const getUserFeed = (params, callback, config) => {
|
|
24467
|
+
const { log, cache } = getActiveClient();
|
|
24468
|
+
if (!cache) {
|
|
24469
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
24470
|
+
}
|
|
24471
|
+
const timestamp = Date.now();
|
|
24472
|
+
log(`getUserFeed(tmpid: ${timestamp}) > listen`);
|
|
24473
|
+
const userFeedLiveCollection = new UserFeedLiveCollectionController(params, callback);
|
|
24474
|
+
const disposers = userFeedLiveCollection.startSubscription();
|
|
24475
|
+
const cacheKey = userFeedLiveCollection.getCacheKey();
|
|
24476
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
24477
|
+
return () => {
|
|
24478
|
+
log(`getUserFeed(tmpid: ${timestamp}) > dispose`);
|
|
24479
|
+
disposers.forEach(fn => fn());
|
|
24480
|
+
};
|
|
24481
|
+
};
|
|
24482
|
+
/* end_public_function */
|
|
24483
|
+
|
|
24484
|
+
var index$9 = /*#__PURE__*/Object.freeze({
|
|
24485
|
+
__proto__: null,
|
|
24486
|
+
queryGlobalFeed: queryGlobalFeed,
|
|
24487
|
+
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
|
|
24488
|
+
getUserFeed: getUserFeed
|
|
24489
|
+
});
|
|
24490
|
+
|
|
24491
|
+
/* begin_public_function
|
|
24492
|
+
id: post.get_by_ids
|
|
24493
|
+
*/
|
|
24494
|
+
/**
|
|
24495
|
+
* ```js
|
|
24496
|
+
* import { getPostByIds } from '@amityco/ts-sdk'
|
|
24497
|
+
* const { data: posts } = await getPostByIds(['foo', 'bar'])
|
|
24498
|
+
* ```
|
|
24499
|
+
*
|
|
24500
|
+
* Fetches a collection of {@link Amity.Post} objects
|
|
24501
|
+
*
|
|
24502
|
+
* @param postIds the IDs of the {@link Amity.Post} to fetch
|
|
24503
|
+
* @returns the associated collection of {@link Amity.Post} objects
|
|
24504
|
+
*
|
|
24505
|
+
* @category Post API
|
|
24506
|
+
* @async
|
|
24507
|
+
*/
|
|
24508
|
+
const getPostByIds = async (postIds) => {
|
|
24509
|
+
const client = getActiveClient();
|
|
24510
|
+
client.log('post/getPostByIds', postIds);
|
|
24511
|
+
const encodedPostIds = postIds.map(postId => encodeURIComponent(postId));
|
|
24512
|
+
let payload;
|
|
24513
|
+
try {
|
|
24514
|
+
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
24515
|
+
const response = await client.http.get(`/api/v3/posts/list`, {
|
|
24516
|
+
params: { postIds: encodedPostIds },
|
|
24517
|
+
});
|
|
24518
|
+
payload = response.data;
|
|
24519
|
+
}
|
|
24520
|
+
catch (error) {
|
|
24521
|
+
postIds.forEach(postId => {
|
|
24522
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
24523
|
+
pushToTombstone('post', postId);
|
|
24524
|
+
}
|
|
24525
|
+
});
|
|
24526
|
+
throw error;
|
|
24527
|
+
}
|
|
24528
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
24529
|
+
const cachedAt = client.cache && Date.now();
|
|
24530
|
+
if (client.cache)
|
|
24531
|
+
ingestInCache(data, { cachedAt });
|
|
24532
|
+
return {
|
|
24533
|
+
data: data.posts.map(LinkedObject.post),
|
|
24534
|
+
cachedAt,
|
|
24535
|
+
};
|
|
24536
|
+
};
|
|
24537
|
+
/* end_public_function */
|
|
24538
|
+
/**
|
|
24539
|
+
* ```js
|
|
24540
|
+
* import { getPostByIds } from '@amityco/ts-sdk'
|
|
24541
|
+
* const { data: posts } = getPostByIds.locally(['foo', 'bar'])
|
|
24542
|
+
* ```
|
|
24543
|
+
*
|
|
24544
|
+
* Fetches a collection of {@link Amity.Post} objects from cache
|
|
24545
|
+
*
|
|
24546
|
+
* @param postIds the IDs of the {@link Amity.Post} to fetch
|
|
24547
|
+
* @returns the associated collection of {@link Amity.Post} objects
|
|
24548
|
+
*
|
|
24549
|
+
* @category Post API
|
|
24550
|
+
*/
|
|
24551
|
+
getPostByIds.locally = (postIds) => {
|
|
24552
|
+
var _a;
|
|
24553
|
+
const client = getActiveClient();
|
|
24554
|
+
client.log('post/getPostByIds.locally', postIds);
|
|
24555
|
+
if (!client.cache)
|
|
24556
|
+
return;
|
|
24557
|
+
const cached = postIds
|
|
24558
|
+
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
24559
|
+
.filter(Boolean);
|
|
24560
|
+
const posts = cached.map(({ data }) => data);
|
|
24561
|
+
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
24562
|
+
if ((cached === null || cached === void 0 ? void 0 : cached.length) < postIds.length)
|
|
24563
|
+
return;
|
|
24564
|
+
return {
|
|
24565
|
+
data: posts.map(LinkedObject.post),
|
|
24566
|
+
cachedAt: oldest.cachedAt,
|
|
24567
|
+
};
|
|
24568
|
+
};
|
|
24569
|
+
|
|
24570
|
+
/* begin_public_function
|
|
24571
|
+
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
|
|
24572
|
+
*/
|
|
24573
|
+
/**
|
|
24574
|
+
* ```js
|
|
24575
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
24576
|
+
* const created = await PostRepository.createPost({
|
|
24577
|
+
* targetType: 'user',
|
|
24578
|
+
* targetId: 'foobar',
|
|
24579
|
+
* data: { text: 'hello world' }
|
|
24580
|
+
* }))
|
|
24581
|
+
* ```
|
|
24582
|
+
*
|
|
24583
|
+
* Creates an {@link Amity.Post}
|
|
24584
|
+
*
|
|
24585
|
+
* @param bundle The data necessary to create a new {@link Amity.Post}
|
|
24586
|
+
* @returns The newly created {@link Amity.Post}
|
|
24587
|
+
*
|
|
24588
|
+
* @category Post API
|
|
24589
|
+
* @async
|
|
24590
|
+
*/
|
|
24591
|
+
const createPost = async (bundle) => {
|
|
24592
|
+
const client = getActiveClient();
|
|
24593
|
+
client.log('post/createPost', bundle);
|
|
24594
|
+
if (!bundle.dataType || ['text', 'image', 'file', 'video'].includes(bundle.dataType)) {
|
|
24595
|
+
// eslint-disable-next-line no-param-reassign
|
|
24596
|
+
delete bundle.dataType;
|
|
24597
|
+
}
|
|
24598
|
+
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
24599
|
+
fireEvent('post.created', payload);
|
|
24600
|
+
const data = preparePostPayload(payload);
|
|
24601
|
+
const cachedAt = client.cache && Date.now();
|
|
24602
|
+
if (client.cache)
|
|
24603
|
+
ingestInCache(data, { cachedAt });
|
|
24604
|
+
const { posts } = data;
|
|
24605
|
+
return {
|
|
24606
|
+
data: LinkedObject.post(posts[0]),
|
|
24607
|
+
cachedAt,
|
|
24608
|
+
};
|
|
24609
|
+
};
|
|
24610
|
+
/* end_public_function */
|
|
24611
|
+
|
|
24612
|
+
/* begin_public_function
|
|
24613
|
+
id: post.edit, post.edit.custom_post
|
|
24614
|
+
*/
|
|
24615
|
+
/**
|
|
24616
|
+
* ```js
|
|
24617
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
24618
|
+
* const updated = await PostRepository.editPost(postId, {
|
|
24619
|
+
* data: { text: 'hello world' }
|
|
24620
|
+
* })
|
|
24621
|
+
* ```
|
|
24622
|
+
*
|
|
24623
|
+
* Updates an {@link Amity.Post}
|
|
24624
|
+
*
|
|
24625
|
+
* @param postId The ID of the {@link Amity.Post} to edit
|
|
24626
|
+
* @param patch The patch data to apply
|
|
24627
|
+
* @returns the updated {@link Amity.Post} object
|
|
24628
|
+
*
|
|
24629
|
+
* @category Post API
|
|
24630
|
+
* @async
|
|
24631
|
+
*/
|
|
24632
|
+
const editPost = async (postId, patch) => {
|
|
24633
|
+
const client = getActiveClient();
|
|
24634
|
+
client.log('user/editPost', patch);
|
|
24635
|
+
const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
|
|
24636
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
24637
|
+
const cachedAt = client.cache && Date.now();
|
|
24638
|
+
if (client.cache)
|
|
24639
|
+
ingestInCache(data, { cachedAt });
|
|
24640
|
+
fireEvent('local.post.updated', data);
|
|
24641
|
+
const { posts } = data;
|
|
24642
|
+
return {
|
|
24643
|
+
data: LinkedObject.post(posts.find(post => post.postId === postId)),
|
|
24644
|
+
cachedAt,
|
|
24645
|
+
};
|
|
24646
|
+
};
|
|
24647
|
+
/* end_public_function */
|
|
24648
|
+
|
|
24649
|
+
/**
|
|
24650
|
+
* ```js
|
|
24651
|
+
* import { deletePost } from '@amityco/ts-sdk'
|
|
24652
|
+
* const success = await deletePost('foobar')
|
|
24653
|
+
* ```
|
|
24654
|
+
*
|
|
24655
|
+
* Deletes a {@link Amity.Post}
|
|
24656
|
+
*
|
|
24657
|
+
* @param postId The {@link Amity.Post} ID to delete
|
|
24658
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
24659
|
+
*
|
|
24660
|
+
* @private
|
|
24661
|
+
* @async
|
|
24662
|
+
*/
|
|
24663
|
+
const deletePost = async (postId, permanent = false) => {
|
|
24664
|
+
var _a;
|
|
24665
|
+
const client = getActiveClient();
|
|
24666
|
+
const post = await getPost$2(postId);
|
|
24667
|
+
await client.http.delete(`/api/v4/posts/${encodeURIComponent(postId)}`, {
|
|
24668
|
+
params: {
|
|
24669
|
+
postId,
|
|
24670
|
+
permanent,
|
|
24671
|
+
},
|
|
24672
|
+
});
|
|
24673
|
+
// there is currently a limitation which doesn't allow us to fire event to tell that community
|
|
24674
|
+
// has been updated. reason is that, when the object is deleted, we don't have its `communityId`
|
|
24675
|
+
// and so we cannot refetch the community or advertise on events. hopefully this should be solved
|
|
24676
|
+
// later when realtime events covers that for us.
|
|
24677
|
+
if (post.data.targetType === 'community') {
|
|
24678
|
+
const community = await getCommunity$1(post.data.targetId);
|
|
24679
|
+
const communityUsersCache = (_a = queryCache(['communityUsers', 'get'])) !== null && _a !== void 0 ? _a : [];
|
|
24680
|
+
const communityUsers = communityUsersCache
|
|
24681
|
+
.filter(({ key }) => {
|
|
24682
|
+
// cache key is ['communityUsers', 'get', `${communityId}#`${userId}`}]
|
|
24683
|
+
if (key[0] !== 'communityUsers')
|
|
24684
|
+
return false;
|
|
24685
|
+
if (key[1] !== 'get')
|
|
24686
|
+
return false;
|
|
24687
|
+
if (typeof key[2] === 'string')
|
|
24688
|
+
return key[2].includes(community.data.communityId);
|
|
24689
|
+
return false;
|
|
24690
|
+
})
|
|
24691
|
+
.map(({ data }) => data);
|
|
24692
|
+
fireEvent('community.updated', {
|
|
24693
|
+
communities: [community.data],
|
|
24694
|
+
categories: [],
|
|
24695
|
+
communityUsers,
|
|
24696
|
+
feeds: [],
|
|
24697
|
+
files: [],
|
|
24698
|
+
users: [],
|
|
24699
|
+
});
|
|
24700
|
+
}
|
|
24701
|
+
// to support hard deletion
|
|
24702
|
+
const deleted = Object.assign(Object.assign({}, post.data), { isDeleted: true });
|
|
24703
|
+
if (permanent) {
|
|
24704
|
+
setTimeout(() => {
|
|
24705
|
+
pushToTombstone('post', postId);
|
|
24706
|
+
}, 0);
|
|
24707
|
+
}
|
|
24708
|
+
else {
|
|
24709
|
+
upsertInCache(['post', 'get', postId], { isDeleted: true });
|
|
24710
|
+
}
|
|
24711
|
+
fireEvent('local.post.deleted', {
|
|
24712
|
+
posts: [deleted],
|
|
24713
|
+
categories: [],
|
|
24714
|
+
comments: [],
|
|
24715
|
+
communities: [],
|
|
24716
|
+
communityUsers: [],
|
|
24717
|
+
feeds: [],
|
|
24718
|
+
files: [],
|
|
24719
|
+
postChildren: [],
|
|
24720
|
+
users: [],
|
|
24721
|
+
videoStreamings: [],
|
|
24722
|
+
});
|
|
24723
|
+
return LinkedObject.post(deleted);
|
|
24724
|
+
};
|
|
24725
|
+
|
|
24726
|
+
/* begin_public_function
|
|
24727
|
+
id: post.soft_delete
|
|
24728
|
+
*/
|
|
24729
|
+
/**
|
|
24730
|
+
* ```js
|
|
24731
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
24732
|
+
* const success = await PostRepository.softDeletePost('foobar')
|
|
24733
|
+
* ```
|
|
24734
|
+
*
|
|
24735
|
+
* Soft deletes a {@link Amity.Post}
|
|
24736
|
+
*
|
|
24737
|
+
* @param postId The {@link Amity.Post} ID to soft delete
|
|
24738
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
24739
|
+
*
|
|
24740
|
+
* @category Post API
|
|
24741
|
+
* @async
|
|
24742
|
+
*/
|
|
24743
|
+
const softDeletePost = async (postId) => {
|
|
24744
|
+
const client = getActiveClient();
|
|
24745
|
+
client.log('post/softDeletePost', postId);
|
|
24746
|
+
const softDeleted = await deletePost(postId, false);
|
|
24747
|
+
return LinkedObject.post(softDeleted);
|
|
24748
|
+
};
|
|
24749
|
+
/* end_public_function */
|
|
24750
|
+
|
|
24751
|
+
/* begin_public_function
|
|
24752
|
+
id: post.hard_delete
|
|
24753
|
+
*/
|
|
24754
|
+
/**
|
|
24755
|
+
* ```js
|
|
24756
|
+
* import { hardDeletePost } from '@amityco/ts-sdk'
|
|
24757
|
+
* const success = await hardDeletePost('foobar')
|
|
24758
|
+
* ```
|
|
24759
|
+
*
|
|
24760
|
+
* Hard deletes a {@link Amity.Post}
|
|
24761
|
+
*
|
|
24762
|
+
* @param postId The {@link Amity.Post} ID to be hard delete
|
|
24763
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
24764
|
+
*
|
|
24765
|
+
* @category Post API
|
|
24766
|
+
* @async
|
|
24767
|
+
*/
|
|
24768
|
+
const hardDeletePost = async (postId) => {
|
|
24769
|
+
const client = getActiveClient();
|
|
24770
|
+
client.log('post/hardDeletePost', postId);
|
|
24771
|
+
const hardDeleted = await deletePost(postId, true);
|
|
24772
|
+
return LinkedObject.post(hardDeleted);
|
|
24773
|
+
};
|
|
24774
|
+
/* end_public_function */
|
|
24775
|
+
|
|
24776
|
+
/* begin_public_function
|
|
24777
|
+
id: post.approve
|
|
24778
|
+
*/
|
|
24779
|
+
/**
|
|
24780
|
+
* ```js
|
|
24781
|
+
* import { approvePost } from '@amityco/ts-sdk'
|
|
24782
|
+
*
|
|
24783
|
+
* const { data: post } = await approvePost('postId')
|
|
24784
|
+
* ```
|
|
24785
|
+
*
|
|
24786
|
+
* Approves a {@link Amity.Post}
|
|
24787
|
+
*
|
|
24788
|
+
* @param postId The {@link Amity.Post} ID to be approved
|
|
24789
|
+
* @return A {@link Amity.Post} that was approved
|
|
24790
|
+
*
|
|
24791
|
+
* @category Post API
|
|
24792
|
+
* @async
|
|
24793
|
+
*/
|
|
24794
|
+
const approvePost = async (postId) => {
|
|
24795
|
+
const client = getActiveClient();
|
|
24796
|
+
client.log('post/approvePost', postId);
|
|
24797
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/approve`);
|
|
24798
|
+
fireEvent('post.approved', payload);
|
|
24799
|
+
// fire virtual event for community update
|
|
24800
|
+
if (payload.posts[0].targetType === 'community') {
|
|
24801
|
+
fireEvent('community.updated', payload);
|
|
24802
|
+
}
|
|
24803
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
24804
|
+
const cachedAt = client.cache && Date.now();
|
|
24805
|
+
if (client.cache)
|
|
24806
|
+
ingestInCache(data, { cachedAt });
|
|
24807
|
+
return {
|
|
24808
|
+
data: LinkedObject.post(data.posts.find(post => post.postId === postId)),
|
|
24809
|
+
cachedAt,
|
|
24810
|
+
};
|
|
24811
|
+
};
|
|
24812
|
+
/* end_public_function */
|
|
24813
|
+
|
|
24814
|
+
/* begin_public_function
|
|
24815
|
+
id: post.decline
|
|
24816
|
+
*/
|
|
24570
24817
|
/**
|
|
24571
24818
|
* ```js
|
|
24572
|
-
* import {
|
|
24573
|
-
*
|
|
24574
|
-
*
|
|
24575
|
-
* })
|
|
24819
|
+
* import { declinePost } from '@amityco/ts-sdk'
|
|
24820
|
+
*
|
|
24821
|
+
* const {data: post} = await declinePost('postId')
|
|
24576
24822
|
* ```
|
|
24577
24823
|
*
|
|
24578
|
-
*
|
|
24824
|
+
* Declines a {@link Amity.Post}
|
|
24579
24825
|
*
|
|
24580
|
-
* @param
|
|
24581
|
-
* @
|
|
24826
|
+
* @param postId The {@link Amity.Post} ID to be declined
|
|
24827
|
+
* @return A {@link Amity.Post} that was declined
|
|
24582
24828
|
*
|
|
24583
|
-
* @category Post
|
|
24829
|
+
* @category Post API
|
|
24830
|
+
* @async
|
|
24584
24831
|
*/
|
|
24585
|
-
const
|
|
24832
|
+
const declinePost = async (postId) => {
|
|
24833
|
+
const client = getActiveClient();
|
|
24834
|
+
client.log('post/declinePost', postId);
|
|
24835
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/decline`);
|
|
24836
|
+
// fire virtual event
|
|
24837
|
+
if (payload.posts[0].targetType === 'community') {
|
|
24838
|
+
fireEvent('community.updated', payload);
|
|
24839
|
+
}
|
|
24840
|
+
fireEvent('post.declined', payload);
|
|
24841
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
24842
|
+
const cachedAt = client.cache && Date.now();
|
|
24843
|
+
if (client.cache)
|
|
24844
|
+
ingestInCache(data, { cachedAt });
|
|
24845
|
+
return {
|
|
24846
|
+
data: LinkedObject.post(payload.posts.find(post => post.postId === postId)),
|
|
24847
|
+
cachedAt,
|
|
24848
|
+
};
|
|
24849
|
+
};
|
|
24850
|
+
/* end_public_function */
|
|
24586
24851
|
|
|
24852
|
+
/* begin_public_function
|
|
24853
|
+
id: post.flag
|
|
24854
|
+
*/
|
|
24587
24855
|
/**
|
|
24588
24856
|
* ```js
|
|
24589
|
-
* import {
|
|
24590
|
-
* const
|
|
24591
|
-
* // ...
|
|
24592
|
-
* })
|
|
24857
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
24858
|
+
* const flagged = await PostRepository.flagPost(postId, reason)
|
|
24593
24859
|
* ```
|
|
24594
24860
|
*
|
|
24595
|
-
*
|
|
24596
|
-
*
|
|
24597
|
-
* @
|
|
24598
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24861
|
+
* @param postId of the post to flag
|
|
24862
|
+
* @param reason the reason to flag the post
|
|
24863
|
+
* @returns a boolean
|
|
24599
24864
|
*
|
|
24600
|
-
* @category Post
|
|
24601
|
-
|
|
24602
|
-
|
|
24865
|
+
* @category Post API
|
|
24866
|
+
* @async
|
|
24867
|
+
* */
|
|
24868
|
+
const flagPost = async (postId, reason) => {
|
|
24603
24869
|
const client = getActiveClient();
|
|
24604
|
-
|
|
24605
|
-
|
|
24606
|
-
|
|
24607
|
-
|
|
24608
|
-
|
|
24609
|
-
|
|
24610
|
-
callback(post);
|
|
24611
|
-
}
|
|
24870
|
+
client.log('post/flagPost', postId);
|
|
24871
|
+
const isPredefinedReason = reason &&
|
|
24872
|
+
Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
|
|
24873
|
+
const body = {
|
|
24874
|
+
reason: reason && isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
|
|
24875
|
+
detail: reason && !isPredefinedReason ? reason : '',
|
|
24612
24876
|
};
|
|
24613
|
-
|
|
24877
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
|
|
24878
|
+
if (client.cache) {
|
|
24879
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
24880
|
+
}
|
|
24881
|
+
fireEvent('post.flagged', payload);
|
|
24882
|
+
return !!payload;
|
|
24614
24883
|
};
|
|
24884
|
+
/* end_public_function */
|
|
24615
24885
|
|
|
24886
|
+
/* begin_public_function
|
|
24887
|
+
id: post.unflag
|
|
24888
|
+
*/
|
|
24616
24889
|
/**
|
|
24617
24890
|
* ```js
|
|
24618
|
-
* import {
|
|
24619
|
-
* const
|
|
24620
|
-
* // ...
|
|
24621
|
-
* })
|
|
24891
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
24892
|
+
* const unflagged = await PostRepository.unflagPost(postId)
|
|
24622
24893
|
* ```
|
|
24623
24894
|
*
|
|
24624
|
-
*
|
|
24895
|
+
* @param postId of the post to unflag
|
|
24896
|
+
* @returns the unflag post result
|
|
24625
24897
|
*
|
|
24626
|
-
* @
|
|
24627
|
-
* @
|
|
24898
|
+
* @category Post API
|
|
24899
|
+
* @async
|
|
24900
|
+
* */
|
|
24901
|
+
const unflagPost = async (postId) => {
|
|
24902
|
+
const client = getActiveClient();
|
|
24903
|
+
client.log('post/unflagPost', postId);
|
|
24904
|
+
const { data: payload } = await client.http.delete(`/api/v3/posts/${encodeURIComponent(postId)}/unflag`);
|
|
24905
|
+
if (client.cache) {
|
|
24906
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
24907
|
+
}
|
|
24908
|
+
fireEvent('post.unflagged', payload);
|
|
24909
|
+
return !!payload;
|
|
24910
|
+
};
|
|
24911
|
+
/* end_public_function */
|
|
24912
|
+
|
|
24913
|
+
/* begin_public_function
|
|
24914
|
+
id: post.check_flag_by_me
|
|
24915
|
+
*/
|
|
24916
|
+
/**
|
|
24917
|
+
* ```js
|
|
24918
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
24919
|
+
* const isReported = await PostRepository.isPostFlaggedByMe('post', postId)
|
|
24920
|
+
* ```
|
|
24628
24921
|
*
|
|
24629
|
-
* @
|
|
24630
|
-
|
|
24631
|
-
|
|
24922
|
+
* @param postId of the post to check if flagged by current user
|
|
24923
|
+
* @returns `true` if the post is flagged by me, `false` if doesn't.
|
|
24924
|
+
*
|
|
24925
|
+
* @category Post API
|
|
24926
|
+
* @async
|
|
24927
|
+
* */
|
|
24928
|
+
const isPostFlaggedByMe = async (postId) => {
|
|
24632
24929
|
const client = getActiveClient();
|
|
24633
|
-
|
|
24634
|
-
|
|
24635
|
-
|
|
24636
|
-
}
|
|
24637
|
-
else {
|
|
24638
|
-
upsertInCache(['post', 'get', post.postId], post);
|
|
24639
|
-
callback(post);
|
|
24640
|
-
}
|
|
24641
|
-
};
|
|
24642
|
-
return createEventSubscriber(client, 'local.post.removeReaction', 'local.post.removeReaction', filter);
|
|
24930
|
+
client.log('post/isPostFlaggedByMe', postId);
|
|
24931
|
+
const { data: { result }, } = await client.http.get(`/api/v3/posts/${postId}/isflagbyme`);
|
|
24932
|
+
return result;
|
|
24643
24933
|
};
|
|
24934
|
+
/* end_public_function */
|
|
24644
24935
|
|
|
24936
|
+
/* begin_public_function
|
|
24937
|
+
id: post.create.clip_post
|
|
24938
|
+
*/
|
|
24645
24939
|
/**
|
|
24646
24940
|
* ```js
|
|
24647
|
-
* import {
|
|
24648
|
-
* const
|
|
24649
|
-
*
|
|
24650
|
-
*
|
|
24941
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
24942
|
+
* const created = await PostRepository.createClipPost({
|
|
24943
|
+
* targetType: 'user',
|
|
24944
|
+
* targetId: 'foobar',
|
|
24945
|
+
* dataType: 'clip',
|
|
24946
|
+
* data: { text: 'hello world' },
|
|
24947
|
+
* attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
|
|
24948
|
+
* }))
|
|
24651
24949
|
* ```
|
|
24652
24950
|
*
|
|
24653
|
-
*
|
|
24951
|
+
* Creates an {@link Amity.Post}
|
|
24654
24952
|
*
|
|
24655
|
-
* @param
|
|
24656
|
-
* @returns
|
|
24953
|
+
* @param bundle The data necessary to create a new {@link Amity.Post}
|
|
24954
|
+
* @returns The newly created {@link Amity.Post}
|
|
24657
24955
|
*
|
|
24658
|
-
* @category Post
|
|
24956
|
+
* @category Post API
|
|
24957
|
+
* @async
|
|
24659
24958
|
*/
|
|
24660
|
-
const
|
|
24959
|
+
const createClipPost = async (bundle) => {
|
|
24960
|
+
const client = getActiveClient();
|
|
24961
|
+
client.log('post/createPost', bundle);
|
|
24962
|
+
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
24963
|
+
fireEvent('post.created', payload);
|
|
24964
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
24965
|
+
const cachedAt = client.cache && Date.now();
|
|
24966
|
+
if (client.cache)
|
|
24967
|
+
ingestInCache(data, { cachedAt });
|
|
24968
|
+
const { posts } = data;
|
|
24969
|
+
return {
|
|
24970
|
+
data: LinkedObject.post(posts[0]),
|
|
24971
|
+
cachedAt,
|
|
24972
|
+
};
|
|
24973
|
+
};
|
|
24974
|
+
/* end_public_function */
|
|
24661
24975
|
|
|
24662
24976
|
/* begin_public_function
|
|
24663
24977
|
id: post.get
|
|
@@ -24681,7 +24995,7 @@ const onLocalPostDeleted = (callback) => createLocalPostEventSubscriber('local.p
|
|
|
24681
24995
|
*
|
|
24682
24996
|
* @category Post Live Object
|
|
24683
24997
|
*/
|
|
24684
|
-
const getPost
|
|
24998
|
+
const getPost = (postId, callback) => {
|
|
24685
24999
|
const responder = (snapshot) => {
|
|
24686
25000
|
const { data } = snapshot;
|
|
24687
25001
|
callback(Object.assign(Object.assign({}, snapshot), { data: data ? LinkedObject.post(snapshot.data) : data }));
|
|
@@ -24770,19 +25084,6 @@ class PostPaginationController extends PaginationController {
|
|
|
24770
25084
|
}
|
|
24771
25085
|
}
|
|
24772
25086
|
|
|
24773
|
-
var EnumPostActions;
|
|
24774
|
-
(function (EnumPostActions) {
|
|
24775
|
-
EnumPostActions["OnPostCreated"] = "onPostCreated";
|
|
24776
|
-
EnumPostActions["OnPostUpdated"] = "onPostUpdated";
|
|
24777
|
-
EnumPostActions["OnPostDeleted"] = "onPostDeleted";
|
|
24778
|
-
EnumPostActions["OnPostFlagged"] = "onPostFlagged";
|
|
24779
|
-
EnumPostActions["OnPostUnflagged"] = "onPostUnflagged";
|
|
24780
|
-
EnumPostActions["OnPostReactionAdded"] = "onPostReactionAdded";
|
|
24781
|
-
EnumPostActions["OnPostReactionRemoved"] = "onPostReactionRemoved";
|
|
24782
|
-
EnumPostActions["OnPostApproved"] = "onPostApproved";
|
|
24783
|
-
EnumPostActions["OnPostDeclined"] = "onPostDeclined";
|
|
24784
|
-
})(EnumPostActions || (EnumPostActions = {}));
|
|
24785
|
-
|
|
24786
25087
|
class PostQueryStreamController extends QueryStreamController {
|
|
24787
25088
|
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
24788
25089
|
super(query, cacheKey);
|
|
@@ -24848,47 +25149,6 @@ class PostQueryStreamController extends QueryStreamController {
|
|
|
24848
25149
|
}
|
|
24849
25150
|
}
|
|
24850
25151
|
|
|
24851
|
-
const getPost = async (postId) => {
|
|
24852
|
-
const client = getActiveClient();
|
|
24853
|
-
client.log('post/getPost', postId);
|
|
24854
|
-
isInTombstone('post', postId);
|
|
24855
|
-
let payload;
|
|
24856
|
-
try {
|
|
24857
|
-
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
24858
|
-
const response = await client.http.get(`/api/v3/posts/${encodeURIComponent(postId)}`);
|
|
24859
|
-
payload = response.data;
|
|
24860
|
-
}
|
|
24861
|
-
catch (error) {
|
|
24862
|
-
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
24863
|
-
pushToTombstone('post', postId);
|
|
24864
|
-
}
|
|
24865
|
-
throw error;
|
|
24866
|
-
}
|
|
24867
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
24868
|
-
const cachedAt = client.cache && Date.now();
|
|
24869
|
-
if (client.cache)
|
|
24870
|
-
ingestInCache(data, { cachedAt });
|
|
24871
|
-
const { posts } = data;
|
|
24872
|
-
const result = posts.find(post => post.postId === postId);
|
|
24873
|
-
return {
|
|
24874
|
-
data: result,
|
|
24875
|
-
cachedAt,
|
|
24876
|
-
};
|
|
24877
|
-
};
|
|
24878
|
-
getPost.locally = (postId) => {
|
|
24879
|
-
const client = getActiveClient();
|
|
24880
|
-
client.log('post/getPost.locally', postId);
|
|
24881
|
-
if (!client.cache)
|
|
24882
|
-
return;
|
|
24883
|
-
const cached = pullFromCache(['post', 'get', postId]);
|
|
24884
|
-
if (!cached)
|
|
24885
|
-
return;
|
|
24886
|
-
return {
|
|
24887
|
-
data: cached.data,
|
|
24888
|
-
cachedAt: cached.cachedAt,
|
|
24889
|
-
};
|
|
24890
|
-
};
|
|
24891
|
-
|
|
24892
25152
|
class PostLiveCollectionController extends LiveCollectionController {
|
|
24893
25153
|
constructor(query, callback) {
|
|
24894
25154
|
const queryStreamId = hash__default["default"](query);
|
|
@@ -24938,7 +25198,7 @@ class PostLiveCollectionController extends LiveCollectionController {
|
|
|
24938
25198
|
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24939
25199
|
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
24940
25200
|
return;
|
|
24941
|
-
await getPost(comment.referenceId);
|
|
25201
|
+
await getPost$1(comment.referenceId);
|
|
24942
25202
|
callback(comment);
|
|
24943
25203
|
});
|
|
24944
25204
|
}, 'referenceId', 'post'),
|
|
@@ -24951,7 +25211,7 @@ class PostLiveCollectionController extends LiveCollectionController {
|
|
|
24951
25211
|
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24952
25212
|
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
24953
25213
|
return;
|
|
24954
|
-
await getPost(comment.referenceId);
|
|
25214
|
+
await getPost$1(comment.referenceId);
|
|
24955
25215
|
callback(comment);
|
|
24956
25216
|
});
|
|
24957
25217
|
}, 'referenceId', 'post'),
|
|
@@ -25577,7 +25837,7 @@ var index$8 = /*#__PURE__*/Object.freeze({
|
|
|
25577
25837
|
onPostUnflagged: onPostUnflagged,
|
|
25578
25838
|
onPostReactionAdded: onPostReactionAdded,
|
|
25579
25839
|
onPostReactionRemoved: onPostReactionRemoved,
|
|
25580
|
-
getPost: getPost
|
|
25840
|
+
getPost: getPost,
|
|
25581
25841
|
getPosts: getPosts,
|
|
25582
25842
|
getPinnedPosts: getPinnedPosts,
|
|
25583
25843
|
getGlobalPinnedPosts: getGlobalPinnedPosts,
|
|
@@ -26460,7 +26720,7 @@ var index$6 = /*#__PURE__*/Object.freeze({
|
|
|
26460
26720
|
getPoll: getPoll
|
|
26461
26721
|
});
|
|
26462
26722
|
|
|
26463
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
26723
|
+
const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDAARz+hmBgi8pJ\nQb8LeY41gtHhk+ACMwRfhsn7GqpqRQNG2qU0755mzZuVDUqjQMGSo8THJB7O+OJs\nflbZRkFXlFoFOVNw1UpNOgwEQZ6wB9oRwzepTJAfF1sVhm/o/ixvXh1zDFNDy6yZ\npXyiiJHUVxqyjllZhxnwdvjoVtDs6hW6awG09bB9nh/TTejlUKXoAgzqVwu/1QMu\nUVViET495elEe19aUarEy+oL2iKeXCEvqda/pWNBdbieFyJvvZ08HN8dPuT88wq2\njZLEAth1vrwQ2IAa4ktaLcBQdLJgIkrbDvAiVZ8lQAjS/bq5vXQikTGvoPlC5bbn\nvuOM/3eLAgMBAAECggEAVZ+peHAghq2QVj71nX5lxsNCKaCyYwixSJBpfouTt7Rz\nE6PpzMOXFi1W1o+I22jDakuSM2SOQKqI/u0QefB0r0O/KVk5NrZHXk0mkrdYtxOp\nUgaGyf8UvmjB+8VqHrNKyZdk9qtmbnNj01kTTcAtmE4H39zPR7eR/8Rul94vaZbs\nwCnKJS3mLT3JxyGug6lxanveKkjG+CKC1nJQYWaxCJxaFSzbwXQPvDhB+TvrIbee\npd5v4EAyEJohpr+T9oDGGJkb/KARBZCtwLyB976PKJwwBA8MRVL1i5QwawuMiMq5\nUtnOnbGKtCeFzaLbNU0Qi8bqyims84EQxC6DOu1fkQKBgQDdvsoBsEhsOXV7hlIJ\naEd0eSJZVkdqimxH8uGoMM2FeNaOrcB6yBXqTSP0R3OIyf8eaY6yjRvP30ZNXcll\n/gD3O1Mu6YmWQdt1W2WA6pKOsUuPXasf0pdOF7IiFZKlSabz5YHXFqwVuqm8loaj\nsXel3YWqPVdHiankE7tz+3ssnQKBgQDdqi4TNdD1MdEpihx19jr0QjUiXW3939FK\nqp30HESPEGDGQzXdmJgif9HhZb+cJSuWaHEbjgBrYahvgCF+y6LbEpOD+D/dmT+s\nDEAQaR84sah6dokwPjV8fjBSrcVFjCS+doxv0d3p/9OUEeyUhFrY03nxtIEYkLIE\n/Zvn37b4RwKBgQCLENVFe9XfsaVhQ5r9dV2iyTlmh7qgMZG5CbTFs12hQGhm8McO\n+Z7s41YSJCFr/yq1WwP4LJDtrBw99vyQr1zRsG35tNLp3gGRNzGQSQyC2uQFVHw2\np+7mNewsfhUK/gbrXNsyFnDz6635rPlhfbII3sWuP2wWXFqkxE9CbMwR7QKBgQC6\nawDMzxmo2/iYArrkyevSuEuPVxvFwpF1RgAI6C0QVCnPE38dmdN4UB7mfHekje4W\nVEercMURidPp0cxZolCYBQtilUjAyL0vqC3In1/Ogjq6oy3FEMxSop1pKxMY5j+Q\nnoqFD+6deLUrddeNH7J3X4LSr4dSbX4JjG+tlgt+yQKBgQCuwTL4hA6KqeInQ0Ta\n9VQX5Qr8hFlqJz1gpymi/k63tW/Ob8yedbg3WWNWyShwRMFYyY9S81ITFWM95uL6\nvF3x9rmRjwElJw9PMwVu6dmf/CO0Z1wzXSp2VVD12gbrUD/0/d7MUoJ9LgC8X8f/\nn0txLHYGHbx+nf95+JUg6lV3hg==\n-----END PRIVATE KEY-----";
|
|
26464
26724
|
/*
|
|
26465
26725
|
* The crypto algorithm used for importing key and signing string
|
|
26466
26726
|
*/
|
|
@@ -28780,13 +29040,13 @@ exports.AdRepository = index$3;
|
|
|
28780
29040
|
exports.CategoryRepository = index$b;
|
|
28781
29041
|
exports.ChannelRepository = index$f;
|
|
28782
29042
|
exports.Client = index$o;
|
|
28783
|
-
exports.CommentRepository = index$
|
|
29043
|
+
exports.CommentRepository = index$a;
|
|
28784
29044
|
exports.CommunityPostSettingMaps = CommunityPostSettingMaps;
|
|
28785
29045
|
exports.CommunityPostSettings = CommunityPostSettings;
|
|
28786
29046
|
exports.CommunityRepository = index$c;
|
|
28787
29047
|
exports.ContentFeedType = ContentFeedType;
|
|
28788
29048
|
exports.DefaultCommunityPostSetting = DefaultCommunityPostSetting;
|
|
28789
|
-
exports.FeedRepository = index$
|
|
29049
|
+
exports.FeedRepository = index$9;
|
|
28790
29050
|
exports.FileRepository = index$l;
|
|
28791
29051
|
exports.FileType = FileType;
|
|
28792
29052
|
exports.InvitationRepository = index$1;
|