@amityco/ts-sdk 6.2.0 → 6.2.1-0cf9bee.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/README.md +0 -4
- package/dist/@types/core/events.d.ts +1 -0
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +4 -0
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +5 -1
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/marker.d.ts +2 -1
- package/dist/@types/domains/marker.d.ts.map +1 -1
- package/dist/channelRepsitory/api/createChannel.d.ts +1 -1
- package/dist/channelRepsitory/api/markAsRead.d.ts +1 -1
- package/dist/channelRepsitory/api/muteChannel.d.ts.map +1 -1
- package/dist/client/utils/markerSyncEngine.d.ts.map +1 -1
- package/dist/communityRepository/{communityModeration → communityMembership}/api/addMembers.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/api/index.d.ts +3 -0
- package/dist/communityRepository/communityMembership/api/index.d.ts.map +1 -0
- package/dist/communityRepository/{communityModeration → communityMembership}/api/removeMembers.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/api/tests/addMembers.test.d.ts.map +1 -0
- package/dist/communityRepository/communityMembership/api/tests/removeMembers.test.d.ts.map +1 -0
- package/dist/communityRepository/communityMembership/index.d.ts +1 -0
- package/dist/communityRepository/communityMembership/index.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/getMembers.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/banMembers.d.ts +16 -0
- package/dist/communityRepository/communityModeration/api/banMembers.d.ts.map +1 -0
- package/dist/communityRepository/communityModeration/api/index.d.ts +2 -2
- package/dist/communityRepository/communityModeration/api/index.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/test/banMembers.test.d.ts +2 -0
- package/dist/communityRepository/communityModeration/api/test/banMembers.test.d.ts.map +1 -0
- package/dist/communityRepository/communityModeration/api/test/unbanMembers.test.d.ts +2 -0
- package/dist/communityRepository/communityModeration/api/test/unbanMembers.test.d.ts.map +1 -0
- package/dist/communityRepository/communityModeration/api/unbanMembers.d.ts +16 -0
- package/dist/communityRepository/communityModeration/api/unbanMembers.d.ts.map +1 -0
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/query/filtering.d.ts +1 -0
- package/dist/core/query/filtering.d.ts.map +1 -1
- package/dist/core/query/sorting.d.ts.map +1 -1
- package/dist/core/transports/mqtt.d.ts +1 -1
- package/dist/core/transports/mqtt.d.ts.map +1 -1
- package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts +36 -0
- package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +1 -0
- package/dist/feedRepository/api/index.d.ts +1 -0
- package/dist/feedRepository/api/index.d.ts.map +1 -1
- package/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
- package/dist/feedRepository/api/test/getCustomRankingGlobalFeed.test.d.ts +2 -0
- package/dist/feedRepository/api/test/getCustomRankingGlobalFeed.test.d.ts.map +1 -0
- package/dist/fileRepository/api/index.d.ts +3 -3
- package/dist/fileRepository/api/test/uploadFile.test.d.ts +2 -0
- package/dist/fileRepository/api/test/uploadFile.test.d.ts.map +1 -0
- package/dist/fileRepository/api/test/uploadImage.test.d.ts +2 -0
- package/dist/fileRepository/api/test/uploadImage.test.d.ts.map +1 -0
- package/dist/fileRepository/api/test/uploadVideo.test.d.ts +2 -0
- package/dist/fileRepository/api/test/uploadVideo.test.d.ts.map +1 -0
- package/dist/fileRepository/api/{createFile.d.ts → uploadFile.d.ts} +4 -4
- package/dist/fileRepository/api/uploadFile.d.ts.map +1 -0
- package/dist/fileRepository/api/{createImage.d.ts → uploadImage.d.ts} +4 -4
- package/dist/fileRepository/api/uploadImage.d.ts.map +1 -0
- package/dist/fileRepository/api/{createVideo.d.ts → uploadVideo.d.ts} +5 -5
- package/dist/fileRepository/api/uploadVideo.d.ts.map +1 -0
- package/dist/index.cjs.js +795 -193
- package/dist/index.esm.js +794 -194
- package/dist/index.umd.js +4 -4
- package/dist/marker/events/index.d.ts +1 -0
- package/dist/marker/events/index.d.ts.map +1 -1
- package/dist/marker/events/onFeedlMarkerUpdated.d.ts +17 -0
- package/dist/marker/events/onFeedlMarkerUpdated.d.ts.map +1 -0
- package/dist/messageRepository/api/createMessage.d.ts +1 -1
- package/dist/messageRepository/api/editMessage.d.ts +38 -0
- package/dist/messageRepository/api/editMessage.d.ts.map +1 -0
- package/dist/messageRepository/api/flagMessage.d.ts +14 -0
- package/dist/messageRepository/api/flagMessage.d.ts.map +1 -0
- package/dist/messageRepository/api/index.d.ts +5 -1
- package/dist/messageRepository/api/index.d.ts.map +1 -1
- package/dist/messageRepository/api/isMessageFlaggedByMe.d.ts +14 -0
- package/dist/messageRepository/api/isMessageFlaggedByMe.d.ts.map +1 -0
- package/dist/messageRepository/api/markAsDelivered.d.ts +2 -2
- package/dist/messageRepository/api/{deleteMessage.d.ts → softDeleteMessage.d.ts} +6 -6
- package/dist/messageRepository/api/softDeleteMessage.d.ts.map +1 -0
- package/dist/messageRepository/api/tests/editMessage.test.d.ts +2 -0
- package/dist/messageRepository/api/tests/editMessage.test.d.ts.map +1 -0
- package/dist/messageRepository/api/tests/flagMessage.test.d.ts +2 -0
- package/dist/messageRepository/api/tests/flagMessage.test.d.ts.map +1 -0
- package/dist/messageRepository/api/tests/unflagMessage.test.d.ts +2 -0
- package/dist/messageRepository/api/tests/unflagMessage.test.d.ts.map +1 -0
- package/dist/messageRepository/api/unflagMessage.d.ts +14 -0
- package/dist/messageRepository/api/unflagMessage.d.ts.map +1 -0
- package/dist/messageRepository/api/updateMessage.d.ts.map +1 -1
- package/dist/postRepository/api/deletePost.d.ts +1 -1
- package/dist/postRepository/api/deletePost.d.ts.map +1 -1
- package/dist/postRepository/api/editPost.d.ts +24 -0
- package/dist/postRepository/api/editPost.d.ts.map +1 -0
- package/dist/postRepository/api/flagPost.d.ts +14 -0
- package/dist/postRepository/api/flagPost.d.ts.map +1 -0
- package/dist/postRepository/api/hardDeletePost.d.ts +16 -0
- package/dist/postRepository/api/hardDeletePost.d.ts.map +1 -0
- package/dist/postRepository/api/index.d.ts +6 -0
- package/dist/postRepository/api/index.d.ts.map +1 -1
- package/dist/postRepository/api/isPostFlaggedByMe.d.ts +14 -0
- package/dist/postRepository/api/isPostFlaggedByMe.d.ts.map +1 -0
- package/dist/postRepository/api/softDeletePost.d.ts +16 -0
- package/dist/postRepository/api/softDeletePost.d.ts.map +1 -0
- package/dist/postRepository/api/unflagPost.d.ts +14 -0
- package/dist/postRepository/api/unflagPost.d.ts.map +1 -0
- package/dist/postRepository/api/updatePost.d.ts.map +1 -1
- package/dist/subChannelRepository/api/startReadingAPI.d.ts.map +1 -1
- package/dist/subChannelRepository/api/stopReadingAPI.d.ts.map +1 -1
- package/dist/userRepository/api/flagUser.d.ts +14 -0
- package/dist/userRepository/api/flagUser.d.ts.map +1 -0
- package/dist/userRepository/api/index.d.ts +3 -0
- package/dist/userRepository/api/index.d.ts.map +1 -1
- package/dist/userRepository/api/isUserFlaggedByMe.d.ts +14 -0
- package/dist/userRepository/api/isUserFlaggedByMe.d.ts.map +1 -0
- package/dist/userRepository/{relationship/block/api → api}/queryBlockedUsers.d.ts +2 -2
- package/dist/userRepository/api/queryBlockedUsers.d.ts.map +1 -0
- package/dist/userRepository/api/tests/flagUser.test.d.ts +2 -0
- package/dist/userRepository/api/tests/flagUser.test.d.ts.map +1 -0
- package/dist/userRepository/api/tests/queryBlockedUsers.test.d.ts.map +1 -0
- package/dist/userRepository/api/tests/unflagUser.test.d.ts +2 -0
- package/dist/userRepository/api/tests/unflagUser.test.d.ts.map +1 -0
- package/dist/userRepository/api/unflagUser.d.ts +14 -0
- package/dist/userRepository/api/unflagUser.d.ts.map +1 -0
- package/dist/userRepository/observers/getBlockedUsers.d.ts +2 -0
- package/dist/userRepository/observers/getBlockedUsers.d.ts.map +1 -0
- package/dist/userRepository/observers/index.d.ts +1 -0
- package/dist/userRepository/observers/index.d.ts.map +1 -1
- package/dist/userRepository/relationship/block/observers/getBlockedUsers.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/events.ts +1 -0
- package/src/@types/core/payload.ts +5 -0
- package/src/@types/domains/channel.ts +7 -2
- package/src/@types/domains/marker.ts +1 -0
- package/src/categoryRepository/observers/getCategories.ts +4 -4
- package/src/channelRepsitory/api/markAsRead.ts +1 -1
- package/src/channelRepsitory/api/muteChannel.ts +8 -0
- package/src/channelRepsitory/api/tests/muteChannel.test.ts +12 -0
- package/src/channelRepsitory/channelMembership/observers/getMembers.ts +6 -6
- package/src/channelRepsitory/observers/getChannels.ts +5 -5
- package/src/channelRepsitory/observers/tests/getChannels.test.ts +3 -9
- package/src/client/utils/markerSyncEngine.ts +2 -14
- package/src/commentRepository/observers/getComments.ts +5 -5
- package/src/communityRepository/communityMembership/api/index.ts +2 -0
- package/src/communityRepository/{communityModeration/api/test → communityMembership/api/tests}/addMembers.test.ts +1 -1
- package/src/communityRepository/{communityModeration/api/test → communityMembership/api/tests}/removeMembers.test.ts +1 -1
- package/src/communityRepository/communityMembership/index.ts +1 -0
- package/src/communityRepository/communityMembership/observers/getMembers.ts +6 -8
- package/src/communityRepository/communityModeration/api/banMembers.ts +50 -0
- package/src/communityRepository/communityModeration/api/index.ts +3 -2
- package/src/communityRepository/communityModeration/api/test/banMembers.test.ts +70 -0
- package/src/communityRepository/communityModeration/api/test/unbanMembers.test.ts +70 -0
- package/src/communityRepository/communityModeration/api/unbanMembers.ts +50 -0
- package/src/communityRepository/observers/getCommunities.ts +5 -5
- package/src/core/query/filtering.ts +22 -2
- package/src/core/query/sorting.ts +2 -4
- package/src/core/query/tests/filtering.test.ts +6 -0
- package/src/core/query/tests/runQuery.test.ts +3 -3
- package/src/core/transports/mqtt.ts +3 -2
- package/src/feedRepository/api/getCustomRankingGlobalFeed.ts +117 -0
- package/src/feedRepository/api/index.ts +1 -0
- package/src/feedRepository/api/queryGlobalFeed.ts +12 -4
- package/src/feedRepository/api/test/getCustomRankingGlobalFeed.test.ts +130 -0
- package/src/feedRepository/api/test/queryGlobalFeed.test.ts +1 -15
- package/src/fileRepository/api/index.ts +3 -3
- package/src/fileRepository/api/test/uploadFile.test.ts +69 -0
- package/src/fileRepository/api/test/{createImage.test.ts → uploadImage.test.ts} +7 -7
- package/src/fileRepository/api/test/{createVideo.test.ts → uploadVideo.test.ts} +8 -8
- package/src/fileRepository/api/{createFile.ts → uploadFile.ts} +4 -6
- package/src/fileRepository/api/{createImage.ts → uploadImage.ts} +4 -6
- package/src/fileRepository/api/{createVideo.ts → uploadVideo.ts} +5 -7
- package/src/marker/events/index.ts +1 -0
- package/src/marker/events/onFeedlMarkerUpdated.ts +34 -0
- package/src/messageRepository/api/editMessage.ts +100 -0
- package/src/messageRepository/api/flagMessage.ts +40 -0
- package/src/messageRepository/api/index.ts +7 -1
- package/src/messageRepository/api/isMessageFlaggedByMe.ts +30 -0
- package/src/messageRepository/api/markAsDelivered.ts +2 -2
- package/src/messageRepository/api/{deleteMessage.ts → softDeleteMessage.ts} +8 -8
- package/src/messageRepository/api/tests/deleteMessage.test.ts +11 -11
- package/src/messageRepository/api/tests/{updateMessage.test.ts → editMessage.test.ts} +10 -10
- package/src/messageRepository/api/tests/flagMessage.test.ts +87 -0
- package/src/messageRepository/api/tests/unflagMessage.test.ts +87 -0
- package/src/messageRepository/api/unflagMessage.ts +40 -0
- package/src/messageRepository/api/updateMessage.ts +4 -0
- package/src/messageRepository/events/onMessageDeleted.ts +1 -1
- package/src/messageRepository/observers/getMessages.ts +5 -5
- package/src/postRepository/api/deletePost.ts +1 -7
- package/src/postRepository/api/editPost.ts +58 -0
- package/src/postRepository/api/flagPost.ts +38 -0
- package/src/postRepository/api/hardDeletePost.ts +30 -0
- package/src/postRepository/api/index.ts +8 -0
- package/src/postRepository/api/isPostFlaggedByMe.ts +33 -0
- package/src/postRepository/api/softDeletePost.ts +30 -0
- package/src/postRepository/api/unflagPost.ts +39 -0
- package/src/postRepository/api/updatePost.ts +4 -0
- package/src/postRepository/observers/getPosts.ts +5 -5
- package/src/reactionRepository/observers/getReactions.ts +4 -4
- package/src/report/api/createReport.ts +1 -1
- package/src/report/api/tests/createReport.test.ts +2 -62
- package/src/report/api/tests/deleteReport.test.ts +2 -62
- package/src/subChannelRepository/api/startReadingAPI.ts +13 -0
- package/src/subChannelRepository/api/stopReadingAPI.ts +13 -0
- package/src/userRepository/api/flagUser.ts +37 -0
- package/src/userRepository/api/index.ts +4 -0
- package/src/userRepository/api/isUserFlaggedByMe.ts +33 -0
- package/src/userRepository/{relationship/block/api → api}/queryBlockedUsers.ts +3 -2
- package/src/userRepository/api/tests/flagUser.test.ts +81 -0
- package/src/userRepository/{relationship/block/api → api}/tests/queryBlockedUsers.test.ts +1 -1
- package/src/userRepository/api/tests/unflagUser.test.ts +80 -0
- package/src/userRepository/api/unflagUser.ts +37 -0
- package/src/userRepository/observers/getBlockedUsers.ts +104 -0
- package/src/userRepository/observers/getUsers.ts +4 -4
- package/src/userRepository/observers/index.ts +1 -0
- package/src/userRepository/observers/tests/getUsers.test.ts +3 -9
- package/src/userRepository/relationship/block/observers/getBlockedUsers.ts +5 -96
- package/src/userRepository/relationship/follow/observers/getFollowers.ts +4 -4
- package/src/userRepository/relationship/follow/observers/getFollowings.ts +4 -4
- package/dist/communityRepository/communityModeration/api/test/addMembers.test.d.ts.map +0 -1
- package/dist/communityRepository/communityModeration/api/test/removeMembers.test.d.ts.map +0 -1
- package/dist/fileRepository/api/createFile.d.ts.map +0 -1
- package/dist/fileRepository/api/createImage.d.ts.map +0 -1
- package/dist/fileRepository/api/createVideo.d.ts.map +0 -1
- package/dist/fileRepository/api/test/createImage.test.d.ts +0 -2
- package/dist/fileRepository/api/test/createImage.test.d.ts.map +0 -1
- package/dist/fileRepository/api/test/createVideo.test.d.ts +0 -2
- package/dist/fileRepository/api/test/createVideo.test.d.ts.map +0 -1
- package/dist/messageRepository/api/deleteMessage.d.ts.map +0 -1
- package/dist/messageRepository/api/tests/updateMessage.test.d.ts +0 -2
- package/dist/messageRepository/api/tests/updateMessage.test.d.ts.map +0 -1
- package/dist/userRepository/relationship/block/api/queryBlockedUsers.d.ts.map +0 -1
- package/dist/userRepository/relationship/block/api/tests/queryBlockedUsers.test.d.ts.map +0 -1
- /package/dist/communityRepository/{communityModeration → communityMembership}/api/addMembers.d.ts +0 -0
- /package/dist/communityRepository/{communityModeration → communityMembership}/api/removeMembers.d.ts +0 -0
- /package/dist/communityRepository/{communityModeration/api/test → communityMembership/api/tests}/addMembers.test.d.ts +0 -0
- /package/dist/communityRepository/{communityModeration/api/test → communityMembership/api/tests}/removeMembers.test.d.ts +0 -0
- /package/dist/userRepository/{relationship/block/api → api}/tests/queryBlockedUsers.test.d.ts +0 -0
- /package/src/communityRepository/{communityModeration → communityMembership}/api/addMembers.ts +0 -0
- /package/src/communityRepository/{communityModeration → communityMembership}/api/removeMembers.ts +0 -0
package/dist/index.esm.js
CHANGED
|
@@ -1067,8 +1067,15 @@ const dropFromCache = (key, exact = false) => {
|
|
|
1067
1067
|
*
|
|
1068
1068
|
* @hidden
|
|
1069
1069
|
*/
|
|
1070
|
-
const filterByPropEquality = (collection, key, value) =>
|
|
1070
|
+
const filterByPropEquality = (collection, key, value) => value !== undefined
|
|
1071
|
+
? collection.filter(item => JSON.stringify(item[key]) === JSON.stringify(value))
|
|
1072
|
+
: collection;
|
|
1071
1073
|
const filterByPropInclusion = (collection, key, value) => (value !== undefined ? collection.filter(item => value.includes(item[key])) : collection);
|
|
1074
|
+
const filterByPropIntersection = (collection, key, values) => {
|
|
1075
|
+
if (!(values === null || values === void 0 ? void 0 : values.length))
|
|
1076
|
+
return collection;
|
|
1077
|
+
return collection.filter(item => Array.isArray(item[key]) && values.some(value => item[key].includes(value)));
|
|
1078
|
+
};
|
|
1072
1079
|
/**
|
|
1073
1080
|
* Filter a channel collection by membership of the userId
|
|
1074
1081
|
*
|
|
@@ -1202,7 +1209,11 @@ const filterByPostDataTypes = (collection, dataTypes) => {
|
|
|
1202
1209
|
* @hidden
|
|
1203
1210
|
*/
|
|
1204
1211
|
const filterBySearchTerm = (collection, searchTerm) => {
|
|
1205
|
-
|
|
1212
|
+
/*
|
|
1213
|
+
* Search term should match regardless of the case.
|
|
1214
|
+
* Hence, the flag "i", is passed to the created regex
|
|
1215
|
+
*/
|
|
1216
|
+
const containsMatcher = new RegExp(searchTerm, 'i');
|
|
1206
1217
|
return collection.filter(m => {
|
|
1207
1218
|
var _a;
|
|
1208
1219
|
if (m.userId.match(containsMatcher))
|
|
@@ -1225,11 +1236,7 @@ const sortByDisplayName = ({ displayName: a }, { displayName: b }) => {
|
|
|
1225
1236
|
/**
|
|
1226
1237
|
* Alphabetic sorting of objects having a name
|
|
1227
1238
|
*/
|
|
1228
|
-
const sortByName = ({ name: a }, { name: b }) =>
|
|
1229
|
-
if (a === b)
|
|
1230
|
-
return 0;
|
|
1231
|
-
return a < b ? -1 : 1;
|
|
1232
|
-
};
|
|
1239
|
+
const sortByName = ({ name: a }, { name: b }) => a.localeCompare(b);
|
|
1233
1240
|
/**
|
|
1234
1241
|
* Sorting a collection by their apparition order (oldest first)
|
|
1235
1242
|
*/
|
|
@@ -20490,7 +20497,8 @@ const createMqttTransport = (endpoint) => {
|
|
|
20490
20497
|
? new ASCError(error.message, 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */)
|
|
20491
20498
|
: // TODO throw the actual error, once BE can tell us the actual error code
|
|
20492
20499
|
new ASCUnknownError(800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
20493
|
-
|
|
20500
|
+
// Use warning lv instead of error lv to prevent misunderstanding of user
|
|
20501
|
+
console.warn(`Failed to subscribe to topic ${topic}`, ascError);
|
|
20494
20502
|
callback === null || callback === void 0 ? void 0 : callback(ascError);
|
|
20495
20503
|
}
|
|
20496
20504
|
else {
|
|
@@ -21875,6 +21883,29 @@ const onFeedMarkerFetched = (callback) => {
|
|
|
21875
21883
|
return createEventSubscriber(client, 'feedMarker/onFeedMarkerFetched', 'local.feedMarker.fetched', filter);
|
|
21876
21884
|
};
|
|
21877
21885
|
|
|
21886
|
+
/**
|
|
21887
|
+
* ```js
|
|
21888
|
+
* import { onFeedMarkerUpdated } from '@amityco/ts-sdk'
|
|
21889
|
+
* const dispose = onFeedMarkerUpdated(feedMarker => {
|
|
21890
|
+
* // ...
|
|
21891
|
+
* })
|
|
21892
|
+
* ```
|
|
21893
|
+
*
|
|
21894
|
+
* Fired when an {@link Amity.FeedMarker} has been updated
|
|
21895
|
+
*
|
|
21896
|
+
* @param callback The function to call when the event was fired
|
|
21897
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
21898
|
+
*
|
|
21899
|
+
* @category FeedMarker Events
|
|
21900
|
+
*/
|
|
21901
|
+
const onFeedMarkerUpdated = (callback) => {
|
|
21902
|
+
const client = getActiveClient();
|
|
21903
|
+
const filter = (payload) => {
|
|
21904
|
+
callback(payload.feedMarkers[0]);
|
|
21905
|
+
};
|
|
21906
|
+
return createEventSubscriber(client, 'feedMarker/onFeedMarkerUpdated', 'marker.feed-updated', filter);
|
|
21907
|
+
};
|
|
21908
|
+
|
|
21878
21909
|
/**
|
|
21879
21910
|
* ```js
|
|
21880
21911
|
* import { onUserMarkerFetched } from '@amityco/ts-sdk'
|
|
@@ -22234,7 +22265,7 @@ const onMessageDeleted = (callback) => {
|
|
|
22234
22265
|
};
|
|
22235
22266
|
const disposers = [
|
|
22236
22267
|
createEventSubscriber(client, 'message/onMessageDeleted', 'message.deleted', filter),
|
|
22237
|
-
createEventSubscriber(client, '
|
|
22268
|
+
createEventSubscriber(client, 'message/onMessageDeleted', 'local.message.deleted', payload => callback(payload.messages[0])),
|
|
22238
22269
|
];
|
|
22239
22270
|
return () => {
|
|
22240
22271
|
disposers.forEach(fn => fn());
|
|
@@ -22569,9 +22600,14 @@ const startReadingAPI = async (messageFeedId) => {
|
|
|
22569
22600
|
const client = getActiveClient();
|
|
22570
22601
|
client.log('channel/startReadingAPI', messageFeedId);
|
|
22571
22602
|
const { data: payload } = await client.http.post(`/api/v1/markers/message-feeds/${messageFeedId}/start-reading`);
|
|
22603
|
+
const { userEntityMarkers, userFeedMarkers, feedMarkers, userMarkers } = payload;
|
|
22572
22604
|
const cachedAt = client.cache && Date.now();
|
|
22573
22605
|
if (client.cache)
|
|
22574
22606
|
ingestInCache(payload, { cachedAt });
|
|
22607
|
+
feedMarkerReducer('local.feedMarker.fetched', feedMarkers);
|
|
22608
|
+
channelMarkerReducer('local.channelMarker.fetched', userEntityMarkers);
|
|
22609
|
+
subChannelMarkerReducer('local.subChannelMarker.fetched', userFeedMarkers);
|
|
22610
|
+
userMarkerReducer('local.userMarker.fetched', userMarkers);
|
|
22575
22611
|
return true;
|
|
22576
22612
|
};
|
|
22577
22613
|
|
|
@@ -22594,9 +22630,14 @@ const stopReadingAPI = async (messageFeedId) => {
|
|
|
22594
22630
|
const client = getActiveClient();
|
|
22595
22631
|
client.log('channel/stopReadingAPI', messageFeedId);
|
|
22596
22632
|
const { data: payload } = await client.http.post(`/api/v1/markers/message-feeds/${messageFeedId}/stop-reading`);
|
|
22633
|
+
const { userEntityMarkers, userFeedMarkers, feedMarkers, userMarkers } = payload;
|
|
22597
22634
|
const cachedAt = client.cache && Date.now();
|
|
22598
22635
|
if (client.cache)
|
|
22599
22636
|
ingestInCache(payload, { cachedAt });
|
|
22637
|
+
feedMarkerReducer('local.feedMarker.fetched', feedMarkers);
|
|
22638
|
+
channelMarkerReducer('local.channelMarker.fetched', userEntityMarkers);
|
|
22639
|
+
subChannelMarkerReducer('local.subChannelMarker.fetched', userFeedMarkers);
|
|
22640
|
+
userMarkerReducer('local.userMarker.fetched', userMarkers);
|
|
22600
22641
|
return true;
|
|
22601
22642
|
};
|
|
22602
22643
|
|
|
@@ -22797,7 +22838,6 @@ const onSubChannelDeleted = (callback) => {
|
|
|
22797
22838
|
};
|
|
22798
22839
|
};
|
|
22799
22840
|
|
|
22800
|
-
const FORCE_SYNC_INTERVAL_TIME = 8000;
|
|
22801
22841
|
const SYNC_TRIGGER_INTERVAL_TIME = 2000;
|
|
22802
22842
|
let clearSyncTrigger;
|
|
22803
22843
|
let disposers = [];
|
|
@@ -22876,19 +22916,7 @@ const registerEventListeners = () => {
|
|
|
22876
22916
|
},
|
|
22877
22917
|
// only trigger sync from remote events to prevent an unread count equal `-1`
|
|
22878
22918
|
// when an optimistic message creation is performed.
|
|
22879
|
-
false), onSubChannelCreated(() => events.push("subchannel is created" /* Amity.MarkerSyncEvent.SUB_CHANNEL_CREATED */)), onSubChannelDeleted(() => events.push("subchannel is deleted" /* Amity.MarkerSyncEvent.SUBCHANNEL_IS_DELETED */)),
|
|
22880
|
-
// In real-world use, we've encountered some cases where BE returns empty result
|
|
22881
|
-
// even if a marker changes in the database, causing the SDK to mistakenly believe that
|
|
22882
|
-
// no changes have been made in the database and end the sync prematurely.
|
|
22883
|
-
// Did miss update the unread count
|
|
22884
|
-
//
|
|
22885
|
-
// We found that some time BE loads were too high, causing the calculation
|
|
22886
|
-
// marker not to finish within the sync time, so it returned an empty value.
|
|
22887
|
-
//
|
|
22888
|
-
// Therefore, solve this problem by creating a second interval loop that
|
|
22889
|
-
// runs every 8 seconds regardless of whether an event occurs or not so that
|
|
22890
|
-
// the unread count is always updated in case of an error like the above.
|
|
22891
|
-
setIntervalTask(() => events.push("force sync" /* Amity.MarkerSyncEvent.FORCE_SYNC */), FORCE_SYNC_INTERVAL_TIME));
|
|
22919
|
+
false), onSubChannelCreated(() => events.push("subchannel is created" /* Amity.MarkerSyncEvent.SUB_CHANNEL_CREATED */)), onSubChannelDeleted(() => events.push("subchannel is deleted" /* Amity.MarkerSyncEvent.SUBCHANNEL_IS_DELETED */)), onFeedMarkerUpdated(() => events.push("feed marker updated" /* Amity.MarkerSyncEvent.MARKER_UPDATED */)));
|
|
22892
22920
|
};
|
|
22893
22921
|
const unRegisterEventListeners = () => {
|
|
22894
22922
|
disposers.forEach(fn => fn());
|
|
@@ -22994,8 +23022,8 @@ const unBlockUser = async (userId) => {
|
|
|
22994
23022
|
|
|
22995
23023
|
/**
|
|
22996
23024
|
* ```js
|
|
22997
|
-
* import {
|
|
22998
|
-
* const { data: users, prevPage, nextPage, total } = await queryBlockedUsers({ page: Amity.PageRaw, limit: number })
|
|
23025
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
23026
|
+
* const { data: users, prevPage, nextPage, total } = await UserRepository.queryBlockedUsers({ page: Amity.PageRaw, limit: number })
|
|
22999
23027
|
* ```
|
|
23000
23028
|
*
|
|
23001
23029
|
* @param query The query parameters
|
|
@@ -23070,7 +23098,7 @@ queryBlockedUsers.locally = (query = {}) => {
|
|
|
23070
23098
|
};
|
|
23071
23099
|
|
|
23072
23100
|
/* eslint-disable no-use-before-define */
|
|
23073
|
-
const getBlockedUsers = (params, callback, config) => {
|
|
23101
|
+
const getBlockedUsers$1 = (params, callback, config) => {
|
|
23074
23102
|
const { log, cache } = getActiveClient();
|
|
23075
23103
|
if (!cache) {
|
|
23076
23104
|
console.log(ENABLE_CACHE_MESSAGE);
|
|
@@ -23102,15 +23130,15 @@ const getBlockedUsers = (params, callback, config) => {
|
|
|
23102
23130
|
* observers
|
|
23103
23131
|
*};
|
|
23104
23132
|
*/
|
|
23105
|
-
const onFetch = () => {
|
|
23133
|
+
const onFetch = (initial = false) => {
|
|
23106
23134
|
var _a, _b;
|
|
23107
23135
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
23108
23136
|
const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
23109
|
-
if (users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
23137
|
+
if (!initial && users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
23110
23138
|
return;
|
|
23111
23139
|
const query = createQuery(queryBlockedUsers, {
|
|
23112
23140
|
limit,
|
|
23113
|
-
token: toToken(collection === null || collection === void 0 ? void 0 : collection.params.page, 'afterbeforeraw'),
|
|
23141
|
+
token: toToken(!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined, 'afterbeforeraw'),
|
|
23114
23142
|
});
|
|
23115
23143
|
runQuery(query,
|
|
23116
23144
|
// @ts-ignore
|
|
@@ -23131,7 +23159,7 @@ const getBlockedUsers = (params, callback, config) => {
|
|
|
23131
23159
|
disposers.push(() => {
|
|
23132
23160
|
// @TODO -> update once observers added
|
|
23133
23161
|
});
|
|
23134
|
-
onFetch();
|
|
23162
|
+
onFetch(true);
|
|
23135
23163
|
return () => {
|
|
23136
23164
|
log(`getCategories(tmpid: ${timestamp}) > dispose`);
|
|
23137
23165
|
disposers.forEach(fn => fn());
|
|
@@ -23139,6 +23167,12 @@ const getBlockedUsers = (params, callback, config) => {
|
|
|
23139
23167
|
};
|
|
23140
23168
|
};
|
|
23141
23169
|
|
|
23170
|
+
/* eslint-disable no-use-before-define */
|
|
23171
|
+
const getBlockedUsers = (params, callback, config) => {
|
|
23172
|
+
console.log('Deprecation Notice: UserRepository.Relationship.getBlockedUsers will be deprecated on 9th June 2023, please use UserRepository.getBlockedUsers instead.');
|
|
23173
|
+
return getBlockedUsers$1(params, callback, config);
|
|
23174
|
+
};
|
|
23175
|
+
|
|
23142
23176
|
/* begin_public_function
|
|
23143
23177
|
id: user.relationship.follow
|
|
23144
23178
|
*/
|
|
@@ -23766,13 +23800,13 @@ const getFollowers = (params, callback, config) => {
|
|
|
23766
23800
|
pushToCache(cacheKey, collection);
|
|
23767
23801
|
responder(collection);
|
|
23768
23802
|
};
|
|
23769
|
-
const onFetch = () => {
|
|
23770
|
-
var _a, _b, _c, _d
|
|
23803
|
+
const onFetch = (initial = false) => {
|
|
23804
|
+
var _a, _b, _c, _d;
|
|
23771
23805
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
23772
23806
|
const followers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
23773
|
-
if (followers.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
23807
|
+
if (!initial && followers.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
23774
23808
|
return;
|
|
23775
|
-
const query = createQuery(queryFollowers, Object.assign(Object.assign({}, queryParams), { page: (
|
|
23809
|
+
const query = createQuery(queryFollowers, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
|
|
23776
23810
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
23777
23811
|
const data = {
|
|
23778
23812
|
loading,
|
|
@@ -23788,7 +23822,7 @@ const getFollowers = (params, callback, config) => {
|
|
|
23788
23822
|
}, queryOptions(policy));
|
|
23789
23823
|
};
|
|
23790
23824
|
disposers.push(onFollowerRequested(realtimeRouter('onRequested')), onFollowRequestAccepted(realtimeRouter('onAccepted')), onFollowRequestDeclined(realtimeRouter('onDeclined')), onFollowRequestCanceled(realtimeRouter('onCanceled')), onUserFollowed(realtimeRouter('onFollowed')), onUserUnfollowed(realtimeRouter('onUnfollowed')), onFollowerDeleted(realtimeRouter('onDeleted')));
|
|
23791
|
-
onFetch();
|
|
23825
|
+
onFetch(true);
|
|
23792
23826
|
return () => {
|
|
23793
23827
|
log(`getFollowers(tmpid: ${timestamp}) > dispose`);
|
|
23794
23828
|
disposers.forEach(fn => fn());
|
|
@@ -23890,13 +23924,13 @@ const getFollowings = (params, callback, config) => {
|
|
|
23890
23924
|
pushToCache(cacheKey, collection);
|
|
23891
23925
|
responder(collection);
|
|
23892
23926
|
};
|
|
23893
|
-
const onFetch = () => {
|
|
23894
|
-
var _a, _b, _c, _d
|
|
23927
|
+
const onFetch = (initial = false) => {
|
|
23928
|
+
var _a, _b, _c, _d;
|
|
23895
23929
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
23896
23930
|
const followings = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
23897
|
-
if (followings.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
23931
|
+
if (!initial && followings.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
23898
23932
|
return;
|
|
23899
|
-
const query = createQuery(queryFollowings, Object.assign(Object.assign({}, queryParams), { page: (
|
|
23933
|
+
const query = createQuery(queryFollowings, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
|
|
23900
23934
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
23901
23935
|
const data = {
|
|
23902
23936
|
loading,
|
|
@@ -23912,7 +23946,7 @@ const getFollowings = (params, callback, config) => {
|
|
|
23912
23946
|
}, queryOptions(policy));
|
|
23913
23947
|
};
|
|
23914
23948
|
disposers.push(onFollowerRequested(realtimeRouter('onRequested')), onFollowRequestAccepted(realtimeRouter('onAccepted')), onFollowRequestDeclined(realtimeRouter('onDeclined')), onFollowRequestCanceled(realtimeRouter('onCanceled')), onUserFollowed(realtimeRouter('onFollowed')), onUserUnfollowed(realtimeRouter('onUnfollowed')), onFollowerDeleted(realtimeRouter('onDeleted')));
|
|
23915
|
-
onFetch();
|
|
23949
|
+
onFetch(true);
|
|
23916
23950
|
return () => {
|
|
23917
23951
|
log(`getFollowings(tmpid: ${timestamp}) > dispose`);
|
|
23918
23952
|
disposers.forEach(fn => fn());
|
|
@@ -24078,6 +24112,86 @@ const updateUser = async (userId, patch) => {
|
|
|
24078
24112
|
};
|
|
24079
24113
|
/* end_public_function */
|
|
24080
24114
|
|
|
24115
|
+
/* begin_public_function
|
|
24116
|
+
id: user.flag
|
|
24117
|
+
*/
|
|
24118
|
+
/**
|
|
24119
|
+
* ```js
|
|
24120
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
24121
|
+
* const flagged = await UserRepository.flagUser('userId')
|
|
24122
|
+
* ```
|
|
24123
|
+
*
|
|
24124
|
+
* @param userId The ID of the user to add a be flagged
|
|
24125
|
+
* @returns the created report result
|
|
24126
|
+
*
|
|
24127
|
+
* @category User API
|
|
24128
|
+
* @async
|
|
24129
|
+
* */
|
|
24130
|
+
const flagUser = async (userId) => {
|
|
24131
|
+
const client = getActiveClient();
|
|
24132
|
+
client.log('user/flagUser', userId);
|
|
24133
|
+
const { data: payload } = await client.http.post(`api/v4/me/flags/${encodeURIComponent(userId)}`);
|
|
24134
|
+
if (client.cache) {
|
|
24135
|
+
ingestInCache(payload);
|
|
24136
|
+
}
|
|
24137
|
+
fireEvent('user.flagged', payload);
|
|
24138
|
+
return !!payload;
|
|
24139
|
+
};
|
|
24140
|
+
/* end_public_function */
|
|
24141
|
+
|
|
24142
|
+
/* begin_public_function
|
|
24143
|
+
id: user.unflag
|
|
24144
|
+
*/
|
|
24145
|
+
/**
|
|
24146
|
+
* ```js
|
|
24147
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
24148
|
+
* const unflagged = await UserRepository.unflagUser('post', postId)
|
|
24149
|
+
* ```
|
|
24150
|
+
*
|
|
24151
|
+
* @param userId The ID of the user to unflag
|
|
24152
|
+
* @returns the deleted report result
|
|
24153
|
+
*
|
|
24154
|
+
* @category User API
|
|
24155
|
+
* @async
|
|
24156
|
+
* */
|
|
24157
|
+
const unflagUser = async (userId) => {
|
|
24158
|
+
const client = getActiveClient();
|
|
24159
|
+
client.log('user/unflag', userId);
|
|
24160
|
+
const { data: payload } = await client.http.delete(`/api/v4/me/flags/${encodeURIComponent(userId)}`);
|
|
24161
|
+
if (client.cache) {
|
|
24162
|
+
ingestInCache(payload);
|
|
24163
|
+
}
|
|
24164
|
+
fireEvent('user.unflagged', payload);
|
|
24165
|
+
return !!payload;
|
|
24166
|
+
};
|
|
24167
|
+
/* end_public_function */
|
|
24168
|
+
|
|
24169
|
+
/* begin_public_function
|
|
24170
|
+
id: user.check_flag_by_me
|
|
24171
|
+
*/
|
|
24172
|
+
/**
|
|
24173
|
+
* ```js
|
|
24174
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
24175
|
+
* const isFlagged = await UserRepository.isUserFlaggedByMe('post', postId)
|
|
24176
|
+
* ```
|
|
24177
|
+
*
|
|
24178
|
+
* @param userId The ID of the thing to check a report to.
|
|
24179
|
+
* @returns `true` if the report is created by me, `false` if doesn't.
|
|
24180
|
+
*
|
|
24181
|
+
* @category Report API
|
|
24182
|
+
* @async
|
|
24183
|
+
* */
|
|
24184
|
+
const isUserFlaggedByMe = async (userId) => {
|
|
24185
|
+
var _a, _b;
|
|
24186
|
+
const client = getActiveClient();
|
|
24187
|
+
client.log('user/isUserFlaggedByMe', userId);
|
|
24188
|
+
const { result, isFlagByMe } = (_a = (await synchronousWSCall(client, 'user.isFlagByMe', {
|
|
24189
|
+
userId,
|
|
24190
|
+
}))) !== null && _a !== void 0 ? _a : {};
|
|
24191
|
+
return (_b = result !== null && result !== void 0 ? result : isFlagByMe) !== null && _b !== void 0 ? _b : false;
|
|
24192
|
+
};
|
|
24193
|
+
/* end_public_function */
|
|
24194
|
+
|
|
24081
24195
|
/**
|
|
24082
24196
|
* ```js
|
|
24083
24197
|
* import { onUserUpdated } from '@amityco/ts-sdk'
|
|
@@ -24402,13 +24516,13 @@ const getUsers = (params, callback, config) => {
|
|
|
24402
24516
|
pushToCache(cacheKey, collection);
|
|
24403
24517
|
responder(collection);
|
|
24404
24518
|
};
|
|
24405
|
-
const onFetch = () => {
|
|
24519
|
+
const onFetch = (initial = false) => {
|
|
24406
24520
|
var _a, _b, _c;
|
|
24407
24521
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24408
24522
|
const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
24409
|
-
if (users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
24523
|
+
if (!initial && users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
24410
24524
|
return;
|
|
24411
|
-
const query = createQuery(queryUsers, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
24525
|
+
const query = createQuery(queryUsers, Object.assign(Object.assign({}, queryParams), { page: (_c = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _c !== void 0 ? _c : { limit } }));
|
|
24412
24526
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
24413
24527
|
const data = {
|
|
24414
24528
|
loading,
|
|
@@ -24424,7 +24538,7 @@ const getUsers = (params, callback, config) => {
|
|
|
24424
24538
|
}, queryOptions(policy));
|
|
24425
24539
|
};
|
|
24426
24540
|
disposers.push(onUserUpdated(realtimeRouter()), onUserDeleted(realtimeRouter()), onUserFlagged(realtimeRouter()), onUserUnflagged(realtimeRouter()), onUserFlagCleared(realtimeRouter()));
|
|
24427
|
-
onFetch();
|
|
24541
|
+
onFetch(true);
|
|
24428
24542
|
return () => {
|
|
24429
24543
|
log(`liveUsers(tmpid: ${timestamp}) > dispose`);
|
|
24430
24544
|
disposers.forEach(fn => fn());
|
|
@@ -24477,6 +24591,9 @@ var index$g = /*#__PURE__*/Object.freeze({
|
|
|
24477
24591
|
Relationship: index$h,
|
|
24478
24592
|
getUserByIds: getUserByIds,
|
|
24479
24593
|
updateUser: updateUser,
|
|
24594
|
+
flagUser: flagUser,
|
|
24595
|
+
unflagUser: unflagUser,
|
|
24596
|
+
isUserFlaggedByMe: isUserFlaggedByMe,
|
|
24480
24597
|
onUserUpdated: onUserUpdated,
|
|
24481
24598
|
onUserDeleted: onUserDeleted,
|
|
24482
24599
|
onUserFlagged: onUserFlagged,
|
|
@@ -24484,7 +24601,8 @@ var index$g = /*#__PURE__*/Object.freeze({
|
|
|
24484
24601
|
onUserFlagCleared: onUserFlagCleared,
|
|
24485
24602
|
getUser: getUser,
|
|
24486
24603
|
getUsers: getUsers,
|
|
24487
|
-
observeUser: observeUser
|
|
24604
|
+
observeUser: observeUser,
|
|
24605
|
+
getBlockedUsers: getBlockedUsers$1
|
|
24488
24606
|
});
|
|
24489
24607
|
|
|
24490
24608
|
/* begin_public_function
|
|
@@ -24551,8 +24669,8 @@ getFile.locally = (fileId) => {
|
|
|
24551
24669
|
*/
|
|
24552
24670
|
/**
|
|
24553
24671
|
* ```js
|
|
24554
|
-
* import {
|
|
24555
|
-
* const created = await
|
|
24672
|
+
* import { FileRepository } from '@amityco/ts-sdk'
|
|
24673
|
+
* const created = await FileRepository.uploadFile(formData)
|
|
24556
24674
|
* ```
|
|
24557
24675
|
*
|
|
24558
24676
|
* Creates an {@link Amity.File}
|
|
@@ -24564,9 +24682,9 @@ getFile.locally = (fileId) => {
|
|
|
24564
24682
|
* @category File API
|
|
24565
24683
|
* @async
|
|
24566
24684
|
*/
|
|
24567
|
-
const
|
|
24685
|
+
const uploadFile = async (formData, onProgress) => {
|
|
24568
24686
|
const client = getActiveClient();
|
|
24569
|
-
client.log('file/
|
|
24687
|
+
client.log('file/uploadFile', formData);
|
|
24570
24688
|
if (!formData.getAll('files').length)
|
|
24571
24689
|
throw new Error('The formData object must have a `files` key.');
|
|
24572
24690
|
const headers = 'getHeaders' in formData
|
|
@@ -24588,8 +24706,7 @@ const createFile = async (formData, onProgress) => {
|
|
|
24588
24706
|
cachedAt,
|
|
24589
24707
|
};
|
|
24590
24708
|
};
|
|
24591
|
-
/* end_public_function */
|
|
24592
|
-
// TODO: consider doing local creation with URL.createObjectURL()
|
|
24709
|
+
/* end_public_function */
|
|
24593
24710
|
|
|
24594
24711
|
/* begin_public_function
|
|
24595
24712
|
id: file.delete
|
|
@@ -24634,8 +24751,8 @@ const fileUrlWithSize = (fileUrl, size) => {
|
|
|
24634
24751
|
*/
|
|
24635
24752
|
/**
|
|
24636
24753
|
* ```js
|
|
24637
|
-
* import {
|
|
24638
|
-
* const created = await
|
|
24754
|
+
* import { FileRepository } from '@amityco/ts-sdk'
|
|
24755
|
+
* const created = await FileRepository.uploadVideo(formData)
|
|
24639
24756
|
* ```
|
|
24640
24757
|
*
|
|
24641
24758
|
* Creates an {@link Amity.File<'video'>}
|
|
@@ -24643,14 +24760,14 @@ const fileUrlWithSize = (fileUrl, size) => {
|
|
|
24643
24760
|
* @param formData The data necessary to create a new {@link Amity.File<'video'>}
|
|
24644
24761
|
* @param feedType The {@link Amity.File<'video'>} feed type
|
|
24645
24762
|
* @param onProgress The callback to track the upload progress
|
|
24646
|
-
* @returns The newly
|
|
24763
|
+
* @returns The newly uploaded {@link Amity.File<'video'>}
|
|
24647
24764
|
*
|
|
24648
24765
|
* @category File API
|
|
24649
24766
|
* @async
|
|
24650
24767
|
*/
|
|
24651
|
-
const
|
|
24768
|
+
const uploadVideo = async (formData, feedType, onProgress) => {
|
|
24652
24769
|
const client = getActiveClient();
|
|
24653
|
-
client.log('file/
|
|
24770
|
+
client.log('file/uploadVideo', formData);
|
|
24654
24771
|
if (!formData.getAll('files').length)
|
|
24655
24772
|
throw new Error('The formData object must have a `files` key.');
|
|
24656
24773
|
if (feedType) {
|
|
@@ -24675,16 +24792,15 @@ const createVideo = async (formData, feedType, onProgress) => {
|
|
|
24675
24792
|
cachedAt,
|
|
24676
24793
|
};
|
|
24677
24794
|
};
|
|
24678
|
-
/* end_public_function */
|
|
24679
|
-
// TODO: consider doing local creation with URL.createObjectURL()
|
|
24795
|
+
/* end_public_function */
|
|
24680
24796
|
|
|
24681
24797
|
/* begin_public_function
|
|
24682
24798
|
id: file.upload.image
|
|
24683
24799
|
*/
|
|
24684
24800
|
/**
|
|
24685
24801
|
* ```js
|
|
24686
|
-
* import {
|
|
24687
|
-
* const created = await
|
|
24802
|
+
* import { FileRepository } from '@amityco/ts-sdk'
|
|
24803
|
+
* const created = await FileRepository.uploadImage(formData)
|
|
24688
24804
|
* ```
|
|
24689
24805
|
*
|
|
24690
24806
|
* Creates an {@link Amity.File<'image'>}
|
|
@@ -24696,9 +24812,9 @@ const createVideo = async (formData, feedType, onProgress) => {
|
|
|
24696
24812
|
* @category File API
|
|
24697
24813
|
* @async
|
|
24698
24814
|
*/
|
|
24699
|
-
const
|
|
24815
|
+
const uploadImage = async (formData, onProgress) => {
|
|
24700
24816
|
const client = getActiveClient();
|
|
24701
|
-
client.log('file/
|
|
24817
|
+
client.log('file/uploadImage', formData);
|
|
24702
24818
|
if (!formData.getAll('files').length)
|
|
24703
24819
|
throw new Error('The formData object must have a `files` key.');
|
|
24704
24820
|
const headers = 'getHeaders' in formData
|
|
@@ -24720,8 +24836,7 @@ const createImage = async (formData, onProgress) => {
|
|
|
24720
24836
|
cachedAt,
|
|
24721
24837
|
};
|
|
24722
24838
|
};
|
|
24723
|
-
/* end_public_function */
|
|
24724
|
-
// TODO: consider doing local creation with URL.createObjectURL()
|
|
24839
|
+
/* end_public_function */
|
|
24725
24840
|
|
|
24726
24841
|
/**
|
|
24727
24842
|
* ```js
|
|
@@ -24764,11 +24879,11 @@ const observeFile = (fileId, callback) => {
|
|
|
24764
24879
|
var index$f = /*#__PURE__*/Object.freeze({
|
|
24765
24880
|
__proto__: null,
|
|
24766
24881
|
getFile: getFile,
|
|
24767
|
-
|
|
24882
|
+
uploadFile: uploadFile,
|
|
24768
24883
|
deleteFile: deleteFile,
|
|
24769
24884
|
fileUrlWithSize: fileUrlWithSize,
|
|
24770
|
-
|
|
24771
|
-
|
|
24885
|
+
uploadVideo: uploadVideo,
|
|
24886
|
+
uploadImage: uploadImage,
|
|
24772
24887
|
observeFile: observeFile
|
|
24773
24888
|
});
|
|
24774
24889
|
|
|
@@ -26033,13 +26148,13 @@ const getReactions = (params, callback, config) => {
|
|
|
26033
26148
|
pushToCache(cacheKey, collection);
|
|
26034
26149
|
responder(collection);
|
|
26035
26150
|
};
|
|
26036
|
-
const onFetch = () => {
|
|
26037
|
-
var _a, _b, _c, _d
|
|
26151
|
+
const onFetch = (initial = false) => {
|
|
26152
|
+
var _a, _b, _c, _d;
|
|
26038
26153
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26039
26154
|
const reactions = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
26040
|
-
if (reactions.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
26155
|
+
if (!initial && reactions.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
26041
26156
|
return;
|
|
26042
|
-
const query = createQuery(queryReactions, Object.assign(Object.assign({}, queryParams), { page: (
|
|
26157
|
+
const query = createQuery(queryReactions, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
|
|
26043
26158
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
26044
26159
|
const data = {
|
|
26045
26160
|
loading,
|
|
@@ -26057,7 +26172,7 @@ const getReactions = (params, callback, config) => {
|
|
|
26057
26172
|
}, queryOptions(policy));
|
|
26058
26173
|
};
|
|
26059
26174
|
disposers.push(onReactorAdded(queryParams.referenceType, queryParams.referenceId, realtimeRouter('onAdded')), onReactorRemoved(queryParams.referenceType, queryParams.referenceId, realtimeRouter('onRemoved')));
|
|
26060
|
-
onFetch();
|
|
26175
|
+
onFetch(true);
|
|
26061
26176
|
return () => {
|
|
26062
26177
|
log(`liveReactions(tmpid: ${timestamp}) > dispose`);
|
|
26063
26178
|
disposers.forEach(fn => fn());
|
|
@@ -26100,7 +26215,7 @@ var REFERENCE_TYPES = {
|
|
|
26100
26215
|
};
|
|
26101
26216
|
|
|
26102
26217
|
/* begin_public_function
|
|
26103
|
-
id:
|
|
26218
|
+
id: message.flag, post.flag, comment.flag
|
|
26104
26219
|
*/
|
|
26105
26220
|
/**
|
|
26106
26221
|
* ```js
|
|
@@ -26542,6 +26657,8 @@ const MUTE_FOREVER = -1;
|
|
|
26542
26657
|
const muteChannel = async (channelId, mutePeriod = MUTE_FOREVER) => {
|
|
26543
26658
|
const client = getActiveClient();
|
|
26544
26659
|
client.log('channel/muteChannel', channelId);
|
|
26660
|
+
if (mutePeriod !== MUTE_FOREVER && mutePeriod < 0)
|
|
26661
|
+
throw new ASCError(`Mute Period can only be positive numbers or ${MUTE_FOREVER}(mute forever)`, 800110 /* Amity.ClientError.INVALID_PARAMETERS */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
26545
26662
|
const { data } = await client.http.put(`/api/v2/channel/${encodeURIComponent(channelId)}/mute`, { mutePeriod });
|
|
26546
26663
|
const { success } = data;
|
|
26547
26664
|
return success;
|
|
@@ -26581,7 +26698,7 @@ const unmuteChannel = async (channelId) => {
|
|
|
26581
26698
|
|
|
26582
26699
|
/**
|
|
26583
26700
|
* ```js
|
|
26584
|
-
* import {
|
|
26701
|
+
* import { ChannelRepository } from '@amityco/ts-sdk'
|
|
26585
26702
|
* const success = await ChannelRepository.markAsRead('channelId')
|
|
26586
26703
|
* ```
|
|
26587
26704
|
*
|
|
@@ -27101,13 +27218,13 @@ const getChannels = (params, callback, config) => {
|
|
|
27101
27218
|
pushToCache(cacheKey, collection);
|
|
27102
27219
|
responder(collection);
|
|
27103
27220
|
};
|
|
27104
|
-
const onFetch = () => {
|
|
27221
|
+
const onFetch = (initial = false) => {
|
|
27105
27222
|
var _a, _b, _c;
|
|
27106
27223
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
27107
27224
|
const channels = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
27108
|
-
if (channels.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27225
|
+
if (!initial && channels.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27109
27226
|
return;
|
|
27110
|
-
const query = createQuery(queryChannels, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
27227
|
+
const query = createQuery(queryChannels, Object.assign(Object.assign({}, queryParams), { page: (_c = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _c !== void 0 ? _c : { limit } }));
|
|
27111
27228
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
27112
27229
|
const data = {
|
|
27113
27230
|
loading,
|
|
@@ -27123,11 +27240,11 @@ const getChannels = (params, callback, config) => {
|
|
|
27123
27240
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
27124
27241
|
};
|
|
27125
27242
|
disposers.push(onChannelCreated(realtimeRouter()), onChannelDeleted(realtimeRouter()), onChannelUpdated(realtimeRouter()), onChannelMuted(realtimeRouter()), onChannelJoined(realtimeRouter()), onChannelLeft(realtimeRouter()), onChannelMemberAdded(realtimeRouter()), onChannelMemberRemoved(realtimeRouter()), onMessageCreated(() => null));
|
|
27126
|
-
onFetch();
|
|
27243
|
+
onFetch(true);
|
|
27244
|
+
dropFromCache(cacheKey);
|
|
27127
27245
|
return () => {
|
|
27128
27246
|
log(`getChannels(tmpid: ${timestamp}) > dispose`);
|
|
27129
27247
|
disposers.forEach(fn => fn());
|
|
27130
|
-
dropFromCache(cacheKey);
|
|
27131
27248
|
};
|
|
27132
27249
|
};
|
|
27133
27250
|
/* end_public_function */
|
|
@@ -27327,7 +27444,7 @@ const getMembers$1 = (params, callback, config) => {
|
|
|
27327
27444
|
.map(id => pullFromCache(['channelUsers', 'get', id]))
|
|
27328
27445
|
.filter(Boolean)
|
|
27329
27446
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
27330
|
-
channelMembers =
|
|
27447
|
+
channelMembers = filterByPropIntersection(channelMembers, 'roles', params.roles);
|
|
27331
27448
|
if (params.memberships) {
|
|
27332
27449
|
/*
|
|
27333
27450
|
* even though membership includes muted as a possible value
|
|
@@ -27379,13 +27496,13 @@ const getMembers$1 = (params, callback, config) => {
|
|
|
27379
27496
|
pushToCache(cacheKey, collection);
|
|
27380
27497
|
responder(collection);
|
|
27381
27498
|
};
|
|
27382
|
-
const onFetch = () => {
|
|
27499
|
+
const onFetch = (initial = false) => {
|
|
27383
27500
|
var _a, _b, _c;
|
|
27384
27501
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
27385
27502
|
const channelMembers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
27386
|
-
if (channelMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27503
|
+
if (!initial && channelMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27387
27504
|
return;
|
|
27388
|
-
const query = createQuery(queryChannelMembers, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
27505
|
+
const query = createQuery(queryChannelMembers, Object.assign(Object.assign({}, queryParams), { page: (_c = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _c !== void 0 ? _c : { limit } }));
|
|
27389
27506
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
27390
27507
|
const data = {
|
|
27391
27508
|
loading,
|
|
@@ -27401,7 +27518,7 @@ const getMembers$1 = (params, callback, config) => {
|
|
|
27401
27518
|
}, queryOptions(policy));
|
|
27402
27519
|
};
|
|
27403
27520
|
disposers.push(onChannelJoined(realtimeRouter()), onChannelLeft(realtimeRouter()), onChannelMemberAdded(realtimeRouter()), onChannelMemberRemoved(realtimeRouter()), onChannelMemberBanned(realtimeRouter()), onChannelMemberUnbanned(realtimeRouter()));
|
|
27404
|
-
onFetch();
|
|
27521
|
+
onFetch(true);
|
|
27405
27522
|
return () => {
|
|
27406
27523
|
log(`getMembers(tmpid: ${timestamp}) > dispose`);
|
|
27407
27524
|
disposers.forEach(fn => fn());
|
|
@@ -27495,7 +27612,7 @@ const removeRole = async (channelId, roleId, userIds) => {
|
|
|
27495
27612
|
* @category Channel API
|
|
27496
27613
|
* @async
|
|
27497
27614
|
* */
|
|
27498
|
-
const banMembers = async (channelId, userIds) => {
|
|
27615
|
+
const banMembers$1 = async (channelId, userIds) => {
|
|
27499
27616
|
const client = getActiveClient();
|
|
27500
27617
|
client.log('channel/banMembers', { userIds, channelId });
|
|
27501
27618
|
const { data: payload } = await client.http.put(`/api/v3/channels/${channelId}/users/ban`, {
|
|
@@ -27530,7 +27647,7 @@ const banMembers = async (channelId, userIds) => {
|
|
|
27530
27647
|
* @category Channel API
|
|
27531
27648
|
* @async
|
|
27532
27649
|
* */
|
|
27533
|
-
const unbanMembers = async (channelId, userIds) => {
|
|
27650
|
+
const unbanMembers$1 = async (channelId, userIds) => {
|
|
27534
27651
|
const client = getActiveClient();
|
|
27535
27652
|
client.log('channel/unbanMembers', { userIds, channelId });
|
|
27536
27653
|
const { data: payload } = await client.http.put(`/api/v3/channels/${encodeURIComponent(channelId)}/users/unban`, {
|
|
@@ -27552,8 +27669,8 @@ var index$c = /*#__PURE__*/Object.freeze({
|
|
|
27552
27669
|
__proto__: null,
|
|
27553
27670
|
addRole: addRole,
|
|
27554
27671
|
removeRole: removeRole,
|
|
27555
|
-
banMembers: banMembers,
|
|
27556
|
-
unbanMembers: unbanMembers
|
|
27672
|
+
banMembers: banMembers$1,
|
|
27673
|
+
unbanMembers: unbanMembers$1
|
|
27557
27674
|
});
|
|
27558
27675
|
|
|
27559
27676
|
var index$b = /*#__PURE__*/Object.freeze({
|
|
@@ -27780,6 +27897,7 @@ createMessage.optimistically = (_a) => {
|
|
|
27780
27897
|
const updateMessage = async (messageId, patch) => {
|
|
27781
27898
|
const client = getActiveClient();
|
|
27782
27899
|
client.log('message/updateMessage', patch);
|
|
27900
|
+
console.warn('MessageRepository.updateMessage will be replaced with MessageRepository.editMessage');
|
|
27783
27901
|
const { data: payload } = await client.http.put(`/api/v5/messages/${encodeURIComponent(messageId)}`, convertParams(patch));
|
|
27784
27902
|
const data = await prepareMessagePayload(payload);
|
|
27785
27903
|
const cachedAt = client.cache && Date.now();
|
|
@@ -27827,13 +27945,83 @@ updateMessage.optimistically = (messageId, patch) => {
|
|
|
27827
27945
|
};
|
|
27828
27946
|
/* end_public_function */
|
|
27829
27947
|
|
|
27948
|
+
/* begin_public_function
|
|
27949
|
+
id: message.edit
|
|
27950
|
+
*/
|
|
27951
|
+
/**
|
|
27952
|
+
* ```js
|
|
27953
|
+
* import { MessageRepository } from '@amityco/ts-sdk'
|
|
27954
|
+
* const updated = await MessageRepository.editMessage(messageId, {
|
|
27955
|
+
* data: { text: 'hello world' }
|
|
27956
|
+
* })
|
|
27957
|
+
* ```
|
|
27958
|
+
*
|
|
27959
|
+
* Updates an {@link Amity.Message}
|
|
27960
|
+
*
|
|
27961
|
+
* @param messageId The ID of the {@link Amity.Message} to edit
|
|
27962
|
+
* @param patch The patch data to apply
|
|
27963
|
+
* @returns the updated {@link Amity.Message} object
|
|
27964
|
+
*
|
|
27965
|
+
* @category Message API
|
|
27966
|
+
* @async
|
|
27967
|
+
*/
|
|
27968
|
+
const editMessage = async (messageId, patch) => {
|
|
27969
|
+
const client = getActiveClient();
|
|
27970
|
+
client.log('message/editMessage', patch);
|
|
27971
|
+
const { data: payload } = await client.http.put(`/api/v5/messages/${encodeURIComponent(messageId)}`, convertParams(patch));
|
|
27972
|
+
const data = await prepareMessagePayload(payload);
|
|
27973
|
+
const cachedAt = client.cache && Date.now();
|
|
27974
|
+
if (client.cache)
|
|
27975
|
+
ingestInCache(data, { cachedAt });
|
|
27976
|
+
const { messages } = data;
|
|
27977
|
+
fireEvent('local.message.updated', { messages });
|
|
27978
|
+
return {
|
|
27979
|
+
data: messages.find(message => message.messageId === messageId),
|
|
27980
|
+
cachedAt,
|
|
27981
|
+
};
|
|
27982
|
+
};
|
|
27983
|
+
/**
|
|
27984
|
+
* ```js
|
|
27985
|
+
* import { editMessage } from '@amityco/ts-sdk'
|
|
27986
|
+
* const updated = editMessage.optimistically('foobar', {
|
|
27987
|
+
* data: { text: 'hello world' }
|
|
27988
|
+
* })
|
|
27989
|
+
* ```
|
|
27990
|
+
*
|
|
27991
|
+
* Updates an {@link Amity.Message} in cache
|
|
27992
|
+
*
|
|
27993
|
+
* @param messageId The ID of the {@link Amity.Message} to edit
|
|
27994
|
+
* @param patch The patch data to apply
|
|
27995
|
+
* @returns the updated {@link Amity.Message} object
|
|
27996
|
+
*
|
|
27997
|
+
* @category Message API
|
|
27998
|
+
*/
|
|
27999
|
+
editMessage.optimistically = (messageId, patch) => {
|
|
28000
|
+
const client = getActiveClient();
|
|
28001
|
+
client.log('message/editMessage.optimistically', patch);
|
|
28002
|
+
if (!client.cache)
|
|
28003
|
+
return;
|
|
28004
|
+
const message = pullFromCache(['message', 'get', messageId]);
|
|
28005
|
+
if (!message)
|
|
28006
|
+
return;
|
|
28007
|
+
const cachedAt = -1;
|
|
28008
|
+
const edited = Object.assign(Object.assign(Object.assign({}, message.data), patch), { updatedAt: new Date().toISOString() });
|
|
28009
|
+
upsertInCache(['message', 'get', messageId], edited, { cachedAt });
|
|
28010
|
+
fireEvent('local.message.updated', { messages: [edited] });
|
|
28011
|
+
return {
|
|
28012
|
+
data: edited,
|
|
28013
|
+
cachedAt,
|
|
28014
|
+
};
|
|
28015
|
+
};
|
|
28016
|
+
/* end_public_function */
|
|
28017
|
+
|
|
27830
28018
|
/* begin_public_function
|
|
27831
28019
|
id: message.soft_delete
|
|
27832
28020
|
*/
|
|
27833
28021
|
/**
|
|
27834
28022
|
* ```js
|
|
27835
|
-
* import {
|
|
27836
|
-
* const success = await
|
|
28023
|
+
* import { softDeleteMessage } from '@amityco/ts-sdk'
|
|
28024
|
+
* const success = await softDeleteMessage('foobar')
|
|
27837
28025
|
* ```
|
|
27838
28026
|
*
|
|
27839
28027
|
* Delete a {@link Amity.Message}
|
|
@@ -27844,9 +28032,9 @@ updateMessage.optimistically = (messageId, patch) => {
|
|
|
27844
28032
|
* @category Message API
|
|
27845
28033
|
* @async
|
|
27846
28034
|
*/
|
|
27847
|
-
const
|
|
28035
|
+
const softDeleteMessage = async (messageId) => {
|
|
27848
28036
|
const client = getActiveClient();
|
|
27849
|
-
client.log('message/
|
|
28037
|
+
client.log('message/softDeleteMessage', messageId);
|
|
27850
28038
|
// API-FIX: This endpoint has not been implemented yet.
|
|
27851
28039
|
await client.http.delete(`/api/v5/messages/${encodeURIComponent(messageId)}`);
|
|
27852
28040
|
const deleted = await getMessage$1(messageId);
|
|
@@ -27855,8 +28043,8 @@ const deleteMessage = async (messageId) => {
|
|
|
27855
28043
|
};
|
|
27856
28044
|
/**
|
|
27857
28045
|
* ```js
|
|
27858
|
-
* import {
|
|
27859
|
-
* const success =
|
|
28046
|
+
* import { softDeleteMessage } from '@amityco/ts-sdk'
|
|
28047
|
+
* const success = softDeleteMessage.optimistically('foobar')
|
|
27860
28048
|
* ```
|
|
27861
28049
|
*
|
|
27862
28050
|
* Deletes a {@link Amity.Message}
|
|
@@ -27866,9 +28054,9 @@ const deleteMessage = async (messageId) => {
|
|
|
27866
28054
|
*
|
|
27867
28055
|
* @category Message API
|
|
27868
28056
|
*/
|
|
27869
|
-
|
|
28057
|
+
softDeleteMessage.optimistically = (messageId) => {
|
|
27870
28058
|
const client = getActiveClient();
|
|
27871
|
-
client.log('message/
|
|
28059
|
+
client.log('message/softDeleteMessage.optimistically', messageId);
|
|
27872
28060
|
const message = pullFromCache(['message', 'get', messageId]);
|
|
27873
28061
|
if (!message)
|
|
27874
28062
|
return;
|
|
@@ -27885,8 +28073,8 @@ deleteMessage.optimistically = (messageId) => {
|
|
|
27885
28073
|
|
|
27886
28074
|
/**
|
|
27887
28075
|
* ```js
|
|
27888
|
-
* import {
|
|
27889
|
-
* const success = await markAsDelivered('subChannelId', 'messageId')
|
|
28076
|
+
* import { MessageRepository } from '@amityco/ts-sdk'
|
|
28077
|
+
* const success = await MessageRepository.markAsDelivered('subChannelId', 'messageId')
|
|
27890
28078
|
* ```
|
|
27891
28079
|
*
|
|
27892
28080
|
* Update `deliveredToSegment` in {@link Amity.SubChannelMarker}
|
|
@@ -28070,6 +28258,85 @@ getDeliveredUsers.locally = (query) => {
|
|
|
28070
28258
|
return { data: users, cachedAt, prevPage, nextPage };
|
|
28071
28259
|
};
|
|
28072
28260
|
|
|
28261
|
+
/* begin_public_function
|
|
28262
|
+
id: message.flag
|
|
28263
|
+
*/
|
|
28264
|
+
/**
|
|
28265
|
+
* ```js
|
|
28266
|
+
* import { MessageRepository } from '@amityco/ts-sdk'
|
|
28267
|
+
* const flagged = await MessageRepository.flagMessage(messageId)
|
|
28268
|
+
* ```
|
|
28269
|
+
*
|
|
28270
|
+
* @param messageId of the message to flag
|
|
28271
|
+
* @returns the created report result
|
|
28272
|
+
*
|
|
28273
|
+
* @category Message API
|
|
28274
|
+
* @async
|
|
28275
|
+
* */
|
|
28276
|
+
const flagMessage = async (messageId) => {
|
|
28277
|
+
const client = getActiveClient();
|
|
28278
|
+
client.log('message/flag', messageId);
|
|
28279
|
+
const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`);
|
|
28280
|
+
if (client.cache) {
|
|
28281
|
+
const messagePayload = await prepareMessagePayload(payload);
|
|
28282
|
+
ingestInCache(messagePayload);
|
|
28283
|
+
}
|
|
28284
|
+
fireEvent('message.flagged', payload);
|
|
28285
|
+
return !!payload;
|
|
28286
|
+
};
|
|
28287
|
+
/* end_public_function */
|
|
28288
|
+
|
|
28289
|
+
/* begin_public_function
|
|
28290
|
+
id: message.unflag
|
|
28291
|
+
*/
|
|
28292
|
+
/**
|
|
28293
|
+
* ```js
|
|
28294
|
+
* import { MessageRepository } from '@amityco/ts-sdk'
|
|
28295
|
+
* const unflagged = await MessageRepository.unflag(messageId)
|
|
28296
|
+
* ```
|
|
28297
|
+
*
|
|
28298
|
+
* @param messageId of the message to unflag
|
|
28299
|
+
* @returns boolean to indicate success
|
|
28300
|
+
*
|
|
28301
|
+
* @category Report API
|
|
28302
|
+
* @async
|
|
28303
|
+
* */
|
|
28304
|
+
const unflagMessage = async (messageId) => {
|
|
28305
|
+
const client = getActiveClient();
|
|
28306
|
+
client.log('message/unflag', messageId);
|
|
28307
|
+
const { data: payload } = await client.http.delete(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`);
|
|
28308
|
+
if (client.cache) {
|
|
28309
|
+
const messagePayload = await prepareMessagePayload(payload);
|
|
28310
|
+
ingestInCache(messagePayload);
|
|
28311
|
+
}
|
|
28312
|
+
fireEvent('message.unflagged', payload);
|
|
28313
|
+
return !!payload;
|
|
28314
|
+
};
|
|
28315
|
+
/* end_public_function */
|
|
28316
|
+
|
|
28317
|
+
/* begin_public_function
|
|
28318
|
+
id: message.check_flag_by_me
|
|
28319
|
+
*/
|
|
28320
|
+
/**
|
|
28321
|
+
* ```js
|
|
28322
|
+
* import { MessageRepository } from '@amityco/ts-sdk'
|
|
28323
|
+
* const isReportedByMe = await MessageRepository.isMessageFlaggedByMe(messageId)
|
|
28324
|
+
* ```
|
|
28325
|
+
*
|
|
28326
|
+
* @param messageId of the message to check a report of.
|
|
28327
|
+
* @returns `true` if the report is created by me, `false` if doesn't.
|
|
28328
|
+
*
|
|
28329
|
+
* @category Report API
|
|
28330
|
+
* @async
|
|
28331
|
+
* */
|
|
28332
|
+
const isMessageFlaggedByMe = async (messageId) => {
|
|
28333
|
+
const client = getActiveClient();
|
|
28334
|
+
client.log('message/isMessageFlaggedByMe', messageId);
|
|
28335
|
+
const { data } = await client.http.get(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`);
|
|
28336
|
+
return data.result;
|
|
28337
|
+
};
|
|
28338
|
+
/* end_public_function */
|
|
28339
|
+
|
|
28073
28340
|
/* begin_public_function
|
|
28074
28341
|
id: message.get
|
|
28075
28342
|
*/
|
|
@@ -28215,16 +28482,15 @@ const getMessages = (params, callback, config) => {
|
|
|
28215
28482
|
return;
|
|
28216
28483
|
collection.data = [...new Set([message.messageId, ...collection.data])];
|
|
28217
28484
|
pushToCache(cacheKey, collection);
|
|
28218
|
-
disposers.push(() => dropFromCache(cacheKey));
|
|
28219
28485
|
responder(collection);
|
|
28220
28486
|
};
|
|
28221
|
-
const onFetch = () => {
|
|
28222
|
-
var _a, _b, _c, _d
|
|
28487
|
+
const onFetch = (initial = false) => {
|
|
28488
|
+
var _a, _b, _c, _d;
|
|
28223
28489
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28224
28490
|
const messages = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
28225
|
-
if (messages.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
28491
|
+
if (!initial && messages.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
28226
28492
|
return;
|
|
28227
|
-
const query = createQuery(queryMessages, Object.assign(Object.assign({}, queryParams), { page: (
|
|
28493
|
+
const query = createQuery(queryMessages, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
|
|
28228
28494
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
28229
28495
|
const data = {
|
|
28230
28496
|
loading,
|
|
@@ -28240,7 +28506,8 @@ const getMessages = (params, callback, config) => {
|
|
|
28240
28506
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
28241
28507
|
};
|
|
28242
28508
|
disposers.push(onMessageFetched(realtimeRouter()), onMessageCreated(realtimeRouter()), onMessageUpdated(realtimeRouter()), onMessageDeleted(realtimeRouter()), onMessageFlagged(realtimeRouter()), onMessageUnflagged(realtimeRouter()), onMessageFlagCleared(realtimeRouter()), onMessageReactionAdded(realtimeRouter()), onMessageReactionRemoved(realtimeRouter()));
|
|
28243
|
-
onFetch();
|
|
28509
|
+
onFetch(true);
|
|
28510
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
28244
28511
|
return () => {
|
|
28245
28512
|
log(`getMessages(tmpid: ${timestamp}) > dispose`);
|
|
28246
28513
|
disposers.forEach(fn => fn());
|
|
@@ -28338,10 +28605,14 @@ var index$a = /*#__PURE__*/Object.freeze({
|
|
|
28338
28605
|
getMessageByIds: getMessages$1,
|
|
28339
28606
|
createMessage: createMessage,
|
|
28340
28607
|
updateMessage: updateMessage,
|
|
28341
|
-
|
|
28608
|
+
editMessage: editMessage,
|
|
28609
|
+
softDeleteMessage: softDeleteMessage,
|
|
28342
28610
|
markAsDelivered: markAsDelivered,
|
|
28343
28611
|
getReadUsers: getReadUsers,
|
|
28344
28612
|
getDeliveredUsers: getDeliveredUsers,
|
|
28613
|
+
flagMessage: flagMessage,
|
|
28614
|
+
unflagMessage: unflagMessage,
|
|
28615
|
+
isMessageFlaggedByMe: isMessageFlaggedByMe,
|
|
28345
28616
|
onMessageCreated: onMessageCreated,
|
|
28346
28617
|
onMessageUpdated: onMessageUpdated,
|
|
28347
28618
|
onMessageDeleted: onMessageDeleted,
|
|
@@ -29721,13 +29992,13 @@ const getCommunities = (params, callback, config) => {
|
|
|
29721
29992
|
pushToCache(cacheKey, collection);
|
|
29722
29993
|
responder(collection);
|
|
29723
29994
|
};
|
|
29724
|
-
const onFetch = () => {
|
|
29995
|
+
const onFetch = (initial = false) => {
|
|
29725
29996
|
var _a, _b, _c;
|
|
29726
29997
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29727
29998
|
const communities = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
29728
|
-
if (communities.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
29999
|
+
if (!initial && communities.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
29729
30000
|
return;
|
|
29730
|
-
const query = createQuery(queryCommunities, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
30001
|
+
const query = createQuery(queryCommunities, Object.assign(Object.assign({}, queryParams), { page: (_c = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _c !== void 0 ? _c : { limit } }));
|
|
29731
30002
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
29732
30003
|
const data = {
|
|
29733
30004
|
loading,
|
|
@@ -29743,11 +30014,11 @@ const getCommunities = (params, callback, config) => {
|
|
|
29743
30014
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
29744
30015
|
};
|
|
29745
30016
|
disposers.push(onCommunityCreated(realtimeRouter()), onCommunityDeleted(realtimeRouter()), onCommunityUpdated(realtimeRouter()), onCommunityJoined(realtimeRouter()), onCommunityLeft(realtimeRouter()), onCommunityUserChanged(realtimeRouter()));
|
|
29746
|
-
onFetch();
|
|
30017
|
+
onFetch(true);
|
|
30018
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
29747
30019
|
return () => {
|
|
29748
30020
|
log(`getCommunities(tmpid: ${timestamp}) > dispose`);
|
|
29749
30021
|
disposers.forEach(fn => fn());
|
|
29750
|
-
dropFromCache(cacheKey);
|
|
29751
30022
|
};
|
|
29752
30023
|
};
|
|
29753
30024
|
/* end_public_function */
|
|
@@ -29788,139 +30059,209 @@ const getCommunity = (communityId, callback) => {
|
|
|
29788
30059
|
/* end_public_function */
|
|
29789
30060
|
|
|
29790
30061
|
/* begin_public_function
|
|
29791
|
-
id: community.
|
|
30062
|
+
id: community.moderation.add_roles
|
|
29792
30063
|
*/
|
|
29793
30064
|
/**
|
|
29794
30065
|
* ```js
|
|
29795
30066
|
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
29796
|
-
* const updated = await CommunityRepository.moderation.
|
|
30067
|
+
* const updated = await CommunityRepository.moderation.addRoles(communityId, ['foo', 'bar'])
|
|
29797
30068
|
* ```
|
|
29798
30069
|
*
|
|
29799
|
-
* Adds a list of {@link Amity.
|
|
30070
|
+
* Adds a list of {@link Amity.Role} to a list of {@link Amity.User} on a {@link Amity.Community}
|
|
29800
30071
|
*
|
|
29801
30072
|
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
29802
|
-
* @param
|
|
29803
|
-
* @
|
|
30073
|
+
* @param roleIds Array of IDs of the {@link Amity.Role} to apply
|
|
30074
|
+
* @param userIds Array of IDs of the {@link Amity.User} to perform
|
|
30075
|
+
* @returns A success boolean if the {@link Amity.Role} were added to list of {@link Amity.User} in the {@link Amity.Community}
|
|
29804
30076
|
*
|
|
29805
30077
|
* @category Community API
|
|
29806
30078
|
* @async
|
|
29807
30079
|
*/
|
|
29808
|
-
const
|
|
30080
|
+
const addRoles = async (communityId, roleIds, userIds) => {
|
|
29809
30081
|
const client = getActiveClient();
|
|
29810
|
-
client.log('community/moderation/
|
|
29811
|
-
const { data: payload } = await client.http.post(`/api/
|
|
29812
|
-
fireEvent('community.userAdded', payload);
|
|
30082
|
+
client.log('community/moderation/addRoles', communityId, roleIds, userIds);
|
|
30083
|
+
const { data: payload } = await client.http.post(`/api/v4/communities/${communityId}/users/roles`, { communityId, roles: roleIds, userIds });
|
|
29813
30084
|
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
29814
30085
|
if (client.cache)
|
|
29815
30086
|
ingestInCache(data);
|
|
29816
30087
|
const { communityUsers } = data;
|
|
29817
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
30088
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
30089
|
+
roleIds.some(role => communityUser.roles.includes(role)));
|
|
29818
30090
|
};
|
|
29819
30091
|
/* end_public_function */
|
|
29820
30092
|
|
|
29821
30093
|
/* begin_public_function
|
|
29822
|
-
id: community.
|
|
30094
|
+
id: community.moderation.remove_roles
|
|
29823
30095
|
*/
|
|
29824
30096
|
/**
|
|
29825
30097
|
* ```js
|
|
29826
30098
|
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
29827
|
-
* const updated = await CommunityRepository.moderation.
|
|
30099
|
+
* const updated = await CommunityRepository.moderation.removeRoles(communityId, ['foo', 'bar'])
|
|
29828
30100
|
* ```
|
|
29829
30101
|
*
|
|
29830
|
-
* Removes a list of {@link Amity.
|
|
30102
|
+
* Removes a list of {@link Amity.Role} from a list of {@link Amity.User} on a {@link Amity.Community}
|
|
29831
30103
|
*
|
|
29832
|
-
* @param communityId The ID of the {@link Amity.Community} to
|
|
29833
|
-
* @param
|
|
29834
|
-
* @
|
|
30104
|
+
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
30105
|
+
* @param roleIds Array of IDs of the {@link Amity.Role} to apply
|
|
30106
|
+
* @param userIds Array of IDs of the {@link Amity.User} to perform
|
|
30107
|
+
* @returns A success boolean if the {@link Amity.Role} were removed from list of {@link Amity.User} in the {@link Amity.Community}
|
|
29835
30108
|
*
|
|
29836
30109
|
* @category Community API
|
|
29837
30110
|
* @async
|
|
29838
30111
|
*/
|
|
29839
|
-
const
|
|
30112
|
+
const removeRoles = async (communityId, roleIds, userIds) => {
|
|
29840
30113
|
const client = getActiveClient();
|
|
29841
|
-
client.log('community/moderation/
|
|
29842
|
-
const { data: payload } = await client.http.delete(`/api/
|
|
29843
|
-
fireEvent('community.userRemoved', payload);
|
|
30114
|
+
client.log('community/moderation/removeRoles', communityId, roleIds, userIds);
|
|
30115
|
+
const { data: payload } = await client.http.delete(`/api/v4/communities/${communityId}/users/roles`, { data: { communityId, roles: roleIds, userIds } });
|
|
29844
30116
|
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
29845
30117
|
if (client.cache)
|
|
29846
30118
|
ingestInCache(data);
|
|
29847
30119
|
const { communityUsers } = data;
|
|
29848
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
30120
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
30121
|
+
!roleIds.some(role => communityUser.roles.includes(role)));
|
|
29849
30122
|
};
|
|
29850
30123
|
/* end_public_function */
|
|
29851
30124
|
|
|
29852
30125
|
/* begin_public_function
|
|
29853
|
-
id: community.moderation.
|
|
30126
|
+
id: community.moderation.ban_members
|
|
29854
30127
|
*/
|
|
29855
30128
|
/**
|
|
29856
30129
|
* ```js
|
|
29857
30130
|
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
29858
|
-
*
|
|
30131
|
+
*
|
|
30132
|
+
* await CommunityRepository.Moderation.banMembers('communityId', ['userId1', 'userId2'])
|
|
29859
30133
|
* ```
|
|
29860
30134
|
*
|
|
29861
|
-
*
|
|
30135
|
+
* @param communityId of {@link Amity.Community} from which the users should be banned
|
|
30136
|
+
* @param userIds of the {@link Amity.User}'s to be banned
|
|
30137
|
+
* @returns the updated {@link Amity.Membership}'s object
|
|
30138
|
+
*
|
|
30139
|
+
* @category Community API
|
|
30140
|
+
* @async
|
|
30141
|
+
* */
|
|
30142
|
+
const banMembers = async (communityId, userIds) => {
|
|
30143
|
+
const client = getActiveClient();
|
|
30144
|
+
client.log('community/banMembers', { userIds, communityId });
|
|
30145
|
+
const { data: payload } = await client.http.put(`/api/v3/communities/${communityId}/users/ban`, {
|
|
30146
|
+
userIds,
|
|
30147
|
+
});
|
|
30148
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
30149
|
+
const cachedAt = client.cache && Date.now();
|
|
30150
|
+
if (client.cache)
|
|
30151
|
+
ingestInCache(data, { cachedAt });
|
|
30152
|
+
const { communityUsers } = data;
|
|
30153
|
+
return {
|
|
30154
|
+
data: communityUsers.filter(u => userIds.includes(u.userId)),
|
|
30155
|
+
cachedAt,
|
|
30156
|
+
};
|
|
30157
|
+
};
|
|
30158
|
+
/* end_public_function */
|
|
30159
|
+
|
|
30160
|
+
/* begin_public_function
|
|
30161
|
+
id: community.moderation.unban_members
|
|
30162
|
+
*/
|
|
30163
|
+
/**
|
|
30164
|
+
* ```js
|
|
30165
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
30166
|
+
*
|
|
30167
|
+
* await CommunityRepository.Moderation.unbanMembers('communityId', ['userId1', 'userId2'])
|
|
30168
|
+
* ```
|
|
30169
|
+
*
|
|
30170
|
+
* @param communityId of {@link Amity.Community} from which the users should be unbanned
|
|
30171
|
+
* @param userIds of the {@link Amity.User}'s to be unbanned
|
|
30172
|
+
* @returns the updated {@link Amity.Membership}'s object
|
|
30173
|
+
*
|
|
30174
|
+
* @category Community API
|
|
30175
|
+
* @async
|
|
30176
|
+
* */
|
|
30177
|
+
const unbanMembers = async (communityId, userIds) => {
|
|
30178
|
+
const client = getActiveClient();
|
|
30179
|
+
client.log('community/unbanMembers', { userIds, communityId });
|
|
30180
|
+
const { data: payload } = await client.http.put(`/api/v3/communities/${communityId}/users/unban`, {
|
|
30181
|
+
userIds,
|
|
30182
|
+
});
|
|
30183
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
30184
|
+
const cachedAt = client.cache && Date.now();
|
|
30185
|
+
if (client.cache)
|
|
30186
|
+
ingestInCache(data, { cachedAt });
|
|
30187
|
+
const { communityUsers } = data;
|
|
30188
|
+
return {
|
|
30189
|
+
data: communityUsers.filter(u => userIds.includes(u.userId)),
|
|
30190
|
+
cachedAt,
|
|
30191
|
+
};
|
|
30192
|
+
};
|
|
30193
|
+
/* end_public_function */
|
|
30194
|
+
|
|
30195
|
+
var index$8 = /*#__PURE__*/Object.freeze({
|
|
30196
|
+
__proto__: null,
|
|
30197
|
+
addRoles: addRoles,
|
|
30198
|
+
removeRoles: removeRoles,
|
|
30199
|
+
banMembers: banMembers,
|
|
30200
|
+
unbanMembers: unbanMembers
|
|
30201
|
+
});
|
|
30202
|
+
|
|
30203
|
+
/* begin_public_function
|
|
30204
|
+
id: community.membership.add_members
|
|
30205
|
+
*/
|
|
30206
|
+
/**
|
|
30207
|
+
* ```js
|
|
30208
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
30209
|
+
* const updated = await CommunityRepository.moderation.addMembers(communityId, ['foo', 'bar'])
|
|
30210
|
+
* ```
|
|
30211
|
+
*
|
|
30212
|
+
* Adds a list of {@link Amity.User} to a {@link Amity.Community} to add users to
|
|
29862
30213
|
*
|
|
29863
30214
|
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
29864
|
-
* @param
|
|
29865
|
-
* @
|
|
29866
|
-
* @returns A success boolean if the {@link Amity.Role} were added to list of {@link Amity.User} in the {@link Amity.Community}
|
|
30215
|
+
* @param userIds The list of IDs {@link Amity.User} to add
|
|
30216
|
+
* @returns A success boolean if the {@link Amity.User} were added to the {@link Amity.Community}
|
|
29867
30217
|
*
|
|
29868
30218
|
* @category Community API
|
|
29869
30219
|
* @async
|
|
29870
30220
|
*/
|
|
29871
|
-
const
|
|
30221
|
+
const addMembers = async (communityId, userIds) => {
|
|
29872
30222
|
const client = getActiveClient();
|
|
29873
|
-
client.log('community/moderation/
|
|
29874
|
-
const { data: payload } = await client.http.post(`/api/
|
|
30223
|
+
client.log('community/moderation/addMembers', communityId, userIds);
|
|
30224
|
+
const { data: payload } = await client.http.post(`/api/v3/communities/${communityId}/users`, { communityId, userIds });
|
|
30225
|
+
fireEvent('community.userAdded', payload);
|
|
29875
30226
|
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
29876
30227
|
if (client.cache)
|
|
29877
30228
|
ingestInCache(data);
|
|
29878
30229
|
const { communityUsers } = data;
|
|
29879
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
29880
|
-
roleIds.some(role => communityUser.roles.includes(role)));
|
|
30230
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership === 'member');
|
|
29881
30231
|
};
|
|
29882
30232
|
/* end_public_function */
|
|
29883
30233
|
|
|
29884
30234
|
/* begin_public_function
|
|
29885
|
-
id: community.
|
|
30235
|
+
id: community.membership.remove_member
|
|
29886
30236
|
*/
|
|
29887
30237
|
/**
|
|
29888
30238
|
* ```js
|
|
29889
30239
|
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
29890
|
-
* const updated = await CommunityRepository.moderation.
|
|
30240
|
+
* const updated = await CommunityRepository.moderation.removeMembers(communityId, ['foo', 'bar'])
|
|
29891
30241
|
* ```
|
|
29892
30242
|
*
|
|
29893
|
-
* Removes a list of {@link Amity.
|
|
30243
|
+
* Removes a list of {@link Amity.User} from a {@link Amity.Community}
|
|
29894
30244
|
*
|
|
29895
|
-
* @param communityId The ID of the {@link Amity.Community} to
|
|
29896
|
-
* @param
|
|
29897
|
-
* @
|
|
29898
|
-
* @returns A success boolean if the {@link Amity.Role} were removed from list of {@link Amity.User} in the {@link Amity.Community}
|
|
30245
|
+
* @param communityId The ID of the {@link Amity.Community} to edit
|
|
30246
|
+
* @param userIds The list of IDs {@link Amity.User} to remove
|
|
30247
|
+
* @returns A success boolean if the list of {@link Amity.User} were removed from the {@link Amity.Community}
|
|
29899
30248
|
*
|
|
29900
30249
|
* @category Community API
|
|
29901
30250
|
* @async
|
|
29902
30251
|
*/
|
|
29903
|
-
const
|
|
30252
|
+
const removeMembers = async (communityId, userIds) => {
|
|
29904
30253
|
const client = getActiveClient();
|
|
29905
|
-
client.log('community/moderation/
|
|
29906
|
-
const { data: payload } = await client.http.delete(`/api/
|
|
30254
|
+
client.log('community/moderation/removeMembers', communityId, userIds);
|
|
30255
|
+
const { data: payload } = await client.http.delete(`/api/v3/communities/${communityId}/users`, { data: { communityId, userIds } });
|
|
30256
|
+
fireEvent('community.userRemoved', payload);
|
|
29907
30257
|
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
29908
30258
|
if (client.cache)
|
|
29909
30259
|
ingestInCache(data);
|
|
29910
30260
|
const { communityUsers } = data;
|
|
29911
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
29912
|
-
!roleIds.some(role => communityUser.roles.includes(role)));
|
|
30261
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership !== 'member');
|
|
29913
30262
|
};
|
|
29914
30263
|
/* end_public_function */
|
|
29915
30264
|
|
|
29916
|
-
var index$8 = /*#__PURE__*/Object.freeze({
|
|
29917
|
-
__proto__: null,
|
|
29918
|
-
addMembers: addMembers,
|
|
29919
|
-
removeMembers: removeMembers,
|
|
29920
|
-
addRoles: addRoles,
|
|
29921
|
-
removeRoles: removeRoles
|
|
29922
|
-
});
|
|
29923
|
-
|
|
29924
30265
|
/**
|
|
29925
30266
|
* ```js
|
|
29926
30267
|
* import { queryCommunityMembers } from '@amityco/ts-sdk'
|
|
@@ -30042,8 +30383,7 @@ const getMembers = (params, callback, config) => {
|
|
|
30042
30383
|
.map(id => pullFromCache(['communityUsers', 'get', id]))
|
|
30043
30384
|
.filter(Boolean)
|
|
30044
30385
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
30045
|
-
|
|
30046
|
-
communityMembers = communityMembers.filter(c => { var _a; return (_a = c.roles) === null || _a === void 0 ? void 0 : _a.some(t => { var _a; return (_a = params.roles) === null || _a === void 0 ? void 0 : _a.includes(t); }); });
|
|
30386
|
+
communityMembers = filterByPropIntersection(communityMembers, 'roles', params.roles);
|
|
30047
30387
|
if (params.membership) {
|
|
30048
30388
|
communityMembers = communityMembers.filter(({ communityMembership }) =>
|
|
30049
30389
|
// @ts-ignore
|
|
@@ -30078,13 +30418,13 @@ const getMembers = (params, callback, config) => {
|
|
|
30078
30418
|
pushToCache(cacheKey, collection);
|
|
30079
30419
|
responder(collection);
|
|
30080
30420
|
};
|
|
30081
|
-
const onFetch = () => {
|
|
30421
|
+
const onFetch = (initial = false) => {
|
|
30082
30422
|
var _a, _b, _c;
|
|
30083
30423
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30084
30424
|
const communityMembers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30085
|
-
if (communityMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
30425
|
+
if (!initial && communityMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
30086
30426
|
return;
|
|
30087
|
-
const query = createQuery(queryCommunityMembers, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
30427
|
+
const query = createQuery(queryCommunityMembers, Object.assign(Object.assign({}, queryParams), { page: (_c = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _c !== void 0 ? _c : { limit } }));
|
|
30088
30428
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
30089
30429
|
const data = {
|
|
30090
30430
|
loading,
|
|
@@ -30102,7 +30442,7 @@ const getMembers = (params, callback, config) => {
|
|
|
30102
30442
|
}, queryOptions(policy));
|
|
30103
30443
|
};
|
|
30104
30444
|
disposers.push(onCommunityLeft(realtimeRouter()), onCommunityJoined(realtimeRouter()), onCommunityUserBanned(realtimeRouter()), onCommunityUserUnbanned(realtimeRouter()), onCommunityUserChanged(realtimeRouter()), onCommunityUserRoleAdded(realtimeRouter()), onCommunityUserRoleRemoved(realtimeRouter()));
|
|
30105
|
-
onFetch();
|
|
30445
|
+
onFetch(true);
|
|
30106
30446
|
return () => {
|
|
30107
30447
|
log(`getMembers(tmpid: ${timestamp}) > dispose`);
|
|
30108
30448
|
disposers.forEach(fn => fn());
|
|
@@ -30112,6 +30452,8 @@ const getMembers = (params, callback, config) => {
|
|
|
30112
30452
|
|
|
30113
30453
|
var index$7 = /*#__PURE__*/Object.freeze({
|
|
30114
30454
|
__proto__: null,
|
|
30455
|
+
addMembers: addMembers,
|
|
30456
|
+
removeMembers: removeMembers,
|
|
30115
30457
|
getMembers: getMembers,
|
|
30116
30458
|
onCommunityUserAdded: onCommunityUserAdded,
|
|
30117
30459
|
onCommunityUserRemoved: onCommunityUserRemoved,
|
|
@@ -30336,13 +30678,13 @@ const getCategories = (params, callback, config) => {
|
|
|
30336
30678
|
* observers
|
|
30337
30679
|
*};
|
|
30338
30680
|
*/
|
|
30339
|
-
const onFetch = () => {
|
|
30681
|
+
const onFetch = (initial = false) => {
|
|
30340
30682
|
var _a, _b, _c;
|
|
30341
30683
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30342
30684
|
const categories = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30343
|
-
if (categories.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
30685
|
+
if (!initial && categories.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
30344
30686
|
return;
|
|
30345
|
-
const query = createQuery(queryCategories, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
30687
|
+
const query = createQuery(queryCategories, Object.assign(Object.assign({}, queryParams), { page: (_c = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _c !== void 0 ? _c : { limit } }));
|
|
30346
30688
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
30347
30689
|
const data = {
|
|
30348
30690
|
loading,
|
|
@@ -30360,7 +30702,7 @@ const getCategories = (params, callback, config) => {
|
|
|
30360
30702
|
disposers.push(() => {
|
|
30361
30703
|
// @TODO -> update once observers added
|
|
30362
30704
|
});
|
|
30363
|
-
onFetch();
|
|
30705
|
+
onFetch(true);
|
|
30364
30706
|
return () => {
|
|
30365
30707
|
log(`getCategories(tmpid: ${timestamp}) > dispose`);
|
|
30366
30708
|
disposers.forEach(fn => fn());
|
|
@@ -30395,7 +30737,12 @@ const queryGlobalFeed = async (query) => {
|
|
|
30395
30737
|
const client = getActiveClient();
|
|
30396
30738
|
client.log('feed/queryGlobalFeed', query);
|
|
30397
30739
|
const _a = query !== null && query !== void 0 ? query : {}, { useCustomRanking, page } = _a, params = __rest(_a, ["useCustomRanking", "page"]);
|
|
30398
|
-
|
|
30740
|
+
/*
|
|
30741
|
+
* TODO: Remove useCustomRanking key from query
|
|
30742
|
+
*/
|
|
30743
|
+
if (useCustomRanking)
|
|
30744
|
+
console.warn('The param "useCustomRanking" has been deprecated. To get custom ranking feed use FeedRepository.getCustomRankingGlobalFeed instead');
|
|
30745
|
+
const { data: queryPayload } = await client.http.get(`/api/v4/me/global-feeds`, {
|
|
30399
30746
|
params: Object.assign(Object.assign({}, params), { options: {
|
|
30400
30747
|
token: toToken(page, 'skiplimit'),
|
|
30401
30748
|
} }),
|
|
@@ -30409,7 +30756,7 @@ const queryGlobalFeed = async (query) => {
|
|
|
30409
30756
|
const cacheKey = [
|
|
30410
30757
|
'globalFeed',
|
|
30411
30758
|
'query',
|
|
30412
|
-
Object.assign(Object.assign({}, params), {
|
|
30759
|
+
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
30413
30760
|
];
|
|
30414
30761
|
pushToCache(cacheKey, { posts: posts.map(getResolver('post')), paging });
|
|
30415
30762
|
}
|
|
@@ -30438,11 +30785,95 @@ queryGlobalFeed.locally = (query) => {
|
|
|
30438
30785
|
client.log('post/queryGlobalFeed.locally', query);
|
|
30439
30786
|
if (!client.cache)
|
|
30440
30787
|
return;
|
|
30441
|
-
const _c = query !== null && query !== void 0 ? query : {}, {
|
|
30788
|
+
const _c = query !== null && query !== void 0 ? query : {}, { page } = _c, params = __rest(_c, ["page"]);
|
|
30442
30789
|
const queryKey = [
|
|
30443
30790
|
'globalFeed',
|
|
30444
30791
|
'query',
|
|
30445
|
-
Object.assign(Object.assign({}, params), {
|
|
30792
|
+
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
30793
|
+
];
|
|
30794
|
+
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
30795
|
+
if (!(data === null || data === void 0 ? void 0 : data.posts.length))
|
|
30796
|
+
return;
|
|
30797
|
+
const posts = data.posts
|
|
30798
|
+
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
30799
|
+
.filter(Boolean)
|
|
30800
|
+
.map(({ data }) => data);
|
|
30801
|
+
const prevPage = toPage(data === null || data === void 0 ? void 0 : data.paging.previous);
|
|
30802
|
+
const nextPage = toPage(data === null || data === void 0 ? void 0 : data.paging.next);
|
|
30803
|
+
return posts.length === ((_b = data === null || data === void 0 ? void 0 : data.posts) === null || _b === void 0 ? void 0 : _b.length)
|
|
30804
|
+
? { data: posts, cachedAt, prevPage, nextPage }
|
|
30805
|
+
: undefined;
|
|
30806
|
+
};
|
|
30807
|
+
|
|
30808
|
+
/* begin_public_function
|
|
30809
|
+
id: feed.query.custom_ranking_feed
|
|
30810
|
+
*/
|
|
30811
|
+
/**
|
|
30812
|
+
* ```js
|
|
30813
|
+
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
30814
|
+
* const posts = await FeedRepository.getCustomRankingGlobalFeed()
|
|
30815
|
+
* ```
|
|
30816
|
+
*
|
|
30817
|
+
* Queries a paginable list of {@link Amity.Post} objects
|
|
30818
|
+
*
|
|
30819
|
+
* @param query The query parameters
|
|
30820
|
+
* @returns A page of {@link Amity.Post} objects
|
|
30821
|
+
*
|
|
30822
|
+
* @category Feed API
|
|
30823
|
+
* @async
|
|
30824
|
+
* */
|
|
30825
|
+
const getCustomRankingGlobalFeed = async (query) => {
|
|
30826
|
+
const client = getActiveClient();
|
|
30827
|
+
client.log('feed/getCustomRankingGlobalFeed', query);
|
|
30828
|
+
const _a = query !== null && query !== void 0 ? query : {}, { page } = _a, params = __rest(_a, ["page"]);
|
|
30829
|
+
const { data: queryPayload } = await client.http.get(`/api/v5/me/global-feeds`, {
|
|
30830
|
+
params: Object.assign(Object.assign({}, params), { options: {
|
|
30831
|
+
token: toToken(page, 'skiplimit'),
|
|
30832
|
+
} }),
|
|
30833
|
+
});
|
|
30834
|
+
const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
|
|
30835
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
30836
|
+
const { posts } = data;
|
|
30837
|
+
const cachedAt = client.cache && Date.now();
|
|
30838
|
+
if (client.cache) {
|
|
30839
|
+
ingestInCache(data);
|
|
30840
|
+
const cacheKey = [
|
|
30841
|
+
'customGlobalFeed',
|
|
30842
|
+
'query',
|
|
30843
|
+
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
30844
|
+
];
|
|
30845
|
+
pushToCache(cacheKey, { posts: posts.map(getResolver('post')), paging });
|
|
30846
|
+
}
|
|
30847
|
+
const nextPage = toPage(paging.next);
|
|
30848
|
+
const prevPage = toPage(paging.previous);
|
|
30849
|
+
return { data: posts, cachedAt, prevPage, nextPage };
|
|
30850
|
+
};
|
|
30851
|
+
/* end_public_function */
|
|
30852
|
+
/**
|
|
30853
|
+
* ```js
|
|
30854
|
+
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
30855
|
+
* const posts = await FeedRepository.getCustomRankingGlobalFeed.locally()
|
|
30856
|
+
* ```
|
|
30857
|
+
*
|
|
30858
|
+
* Queries a paginable list of {@link Amity.Post} objects from cache
|
|
30859
|
+
*
|
|
30860
|
+
* @param query The query parameters
|
|
30861
|
+
* @returns A page of {@link Amity.Post} objects
|
|
30862
|
+
*
|
|
30863
|
+
* @category Feed API
|
|
30864
|
+
* @async
|
|
30865
|
+
* */
|
|
30866
|
+
getCustomRankingGlobalFeed.locally = (query) => {
|
|
30867
|
+
var _a, _b;
|
|
30868
|
+
const client = getActiveClient();
|
|
30869
|
+
client.log('post/getCustomRankingGlobalFeed.locally', query);
|
|
30870
|
+
if (!client.cache)
|
|
30871
|
+
return;
|
|
30872
|
+
const _c = query !== null && query !== void 0 ? query : {}, { page } = _c, params = __rest(_c, ["page"]);
|
|
30873
|
+
const queryKey = [
|
|
30874
|
+
'customGlobalFeed',
|
|
30875
|
+
'query',
|
|
30876
|
+
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
30446
30877
|
];
|
|
30447
30878
|
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
30448
30879
|
if (!(data === null || data === void 0 ? void 0 : data.posts.length))
|
|
@@ -30460,7 +30891,8 @@ queryGlobalFeed.locally = (query) => {
|
|
|
30460
30891
|
|
|
30461
30892
|
var index$4 = /*#__PURE__*/Object.freeze({
|
|
30462
30893
|
__proto__: null,
|
|
30463
|
-
queryGlobalFeed: queryGlobalFeed
|
|
30894
|
+
queryGlobalFeed: queryGlobalFeed,
|
|
30895
|
+
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed
|
|
30464
30896
|
});
|
|
30465
30897
|
|
|
30466
30898
|
/* begin_public_function
|
|
@@ -30607,6 +31039,7 @@ const createPost = async (bundle) => {
|
|
|
30607
31039
|
const updatePost = async (postId, patch) => {
|
|
30608
31040
|
const client = getActiveClient();
|
|
30609
31041
|
client.log('user/updatePost', patch);
|
|
31042
|
+
console.warn('Deprecation: updatePost has been renamed to editPost. Update post API will be deprecated soon.');
|
|
30610
31043
|
const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
|
|
30611
31044
|
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
30612
31045
|
const cachedAt = client.cache && Date.now();
|
|
@@ -30622,8 +31055,42 @@ const updatePost = async (postId, patch) => {
|
|
|
30622
31055
|
/* end_public_function */
|
|
30623
31056
|
|
|
30624
31057
|
/* begin_public_function
|
|
30625
|
-
id: post.
|
|
31058
|
+
id: post.edit
|
|
30626
31059
|
*/
|
|
31060
|
+
/**
|
|
31061
|
+
* ```js
|
|
31062
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
31063
|
+
* const updated = await PostRepository.editPost(postId, {
|
|
31064
|
+
* data: { text: 'hello world' }
|
|
31065
|
+
* })
|
|
31066
|
+
* ```
|
|
31067
|
+
*
|
|
31068
|
+
* Updates an {@link Amity.Post}
|
|
31069
|
+
*
|
|
31070
|
+
* @param postId The ID of the {@link Amity.Post} to edit
|
|
31071
|
+
* @param patch The patch data to apply
|
|
31072
|
+
* @returns the updated {@link Amity.Post} object
|
|
31073
|
+
*
|
|
31074
|
+
* @category Post API
|
|
31075
|
+
* @async
|
|
31076
|
+
*/
|
|
31077
|
+
const editPost = async (postId, patch) => {
|
|
31078
|
+
const client = getActiveClient();
|
|
31079
|
+
client.log('user/editPost', patch);
|
|
31080
|
+
const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
|
|
31081
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
31082
|
+
const cachedAt = client.cache && Date.now();
|
|
31083
|
+
if (client.cache)
|
|
31084
|
+
ingestInCache(data, { cachedAt });
|
|
31085
|
+
fireEvent('post.updated', data);
|
|
31086
|
+
const { posts } = data;
|
|
31087
|
+
return {
|
|
31088
|
+
data: posts.find(post => post.postId === postId),
|
|
31089
|
+
cachedAt,
|
|
31090
|
+
};
|
|
31091
|
+
};
|
|
31092
|
+
/* end_public_function */
|
|
31093
|
+
|
|
30627
31094
|
/**
|
|
30628
31095
|
* ```js
|
|
30629
31096
|
* import { deletePost } from '@amityco/ts-sdk'
|
|
@@ -30635,14 +31102,12 @@ const updatePost = async (postId, patch) => {
|
|
|
30635
31102
|
* @param postId The {@link Amity.Post} ID to delete
|
|
30636
31103
|
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
30637
31104
|
*
|
|
30638
|
-
* @
|
|
31105
|
+
* @private
|
|
30639
31106
|
* @async
|
|
30640
31107
|
*/
|
|
30641
31108
|
const deletePost = async (postId, permanent = false) => {
|
|
30642
31109
|
const client = getActiveClient();
|
|
30643
|
-
client.log('post/deletePost', postId);
|
|
30644
31110
|
const post = await getPost$1(postId);
|
|
30645
|
-
// API-FIX: This endpoint has not been implemented yet.
|
|
30646
31111
|
await client.http.delete(`/api/v4/posts/${encodeURIComponent(postId)}`, {
|
|
30647
31112
|
params: {
|
|
30648
31113
|
postId,
|
|
@@ -30686,6 +31151,55 @@ const deletePost = async (postId, permanent = false) => {
|
|
|
30686
31151
|
upsertInCache(['post', 'get', postId], { isDeleted: true });
|
|
30687
31152
|
}
|
|
30688
31153
|
return deleted;
|
|
31154
|
+
};
|
|
31155
|
+
|
|
31156
|
+
/* begin_public_function
|
|
31157
|
+
id: post.soft_delete
|
|
31158
|
+
*/
|
|
31159
|
+
/**
|
|
31160
|
+
* ```js
|
|
31161
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
31162
|
+
* const success = await PostRepository.softDeletePost('foobar')
|
|
31163
|
+
* ```
|
|
31164
|
+
*
|
|
31165
|
+
* Soft deletes a {@link Amity.Post}
|
|
31166
|
+
*
|
|
31167
|
+
* @param postId The {@link Amity.Post} ID to soft delete
|
|
31168
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
31169
|
+
*
|
|
31170
|
+
* @category Post API
|
|
31171
|
+
* @async
|
|
31172
|
+
*/
|
|
31173
|
+
const softDeletePost = async (postId) => {
|
|
31174
|
+
const client = getActiveClient();
|
|
31175
|
+
client.log('post/softDeletePost', postId);
|
|
31176
|
+
const softDeleted = await deletePost(postId, false);
|
|
31177
|
+
return softDeleted;
|
|
31178
|
+
};
|
|
31179
|
+
/* end_public_function */
|
|
31180
|
+
|
|
31181
|
+
/* begin_public_function
|
|
31182
|
+
id: post.hard_delete
|
|
31183
|
+
*/
|
|
31184
|
+
/**
|
|
31185
|
+
* ```js
|
|
31186
|
+
* import { hardDeletePost } from '@amityco/ts-sdk'
|
|
31187
|
+
* const success = await hardDeletePost('foobar')
|
|
31188
|
+
* ```
|
|
31189
|
+
*
|
|
31190
|
+
* Hard deletes a {@link Amity.Post}
|
|
31191
|
+
*
|
|
31192
|
+
* @param postId The {@link Amity.Post} ID to be hard delete
|
|
31193
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
31194
|
+
*
|
|
31195
|
+
* @category Post API
|
|
31196
|
+
* @async
|
|
31197
|
+
*/
|
|
31198
|
+
const hardDeletePost = async (postId) => {
|
|
31199
|
+
const client = getActiveClient();
|
|
31200
|
+
client.log('post/hardDeletePost', postId);
|
|
31201
|
+
const hardDeleted = await deletePost(postId, true);
|
|
31202
|
+
return hardDeleted;
|
|
30689
31203
|
};
|
|
30690
31204
|
/* end_public_function */
|
|
30691
31205
|
|
|
@@ -30765,6 +31279,86 @@ const declinePost = async (postId) => {
|
|
|
30765
31279
|
};
|
|
30766
31280
|
/* end_public_function */
|
|
30767
31281
|
|
|
31282
|
+
/* begin_public_function
|
|
31283
|
+
id: post.flag
|
|
31284
|
+
*/
|
|
31285
|
+
/**
|
|
31286
|
+
* ```js
|
|
31287
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
31288
|
+
* const flagged = await PostRepository.flagPost(postId)
|
|
31289
|
+
* ```
|
|
31290
|
+
*
|
|
31291
|
+
* @param postId of the post to flag
|
|
31292
|
+
* @returns a boolean
|
|
31293
|
+
*
|
|
31294
|
+
* @category Post API
|
|
31295
|
+
* @async
|
|
31296
|
+
* */
|
|
31297
|
+
const flagPost = async (postId) => {
|
|
31298
|
+
const client = getActiveClient();
|
|
31299
|
+
client.log('post/flagPost', postId);
|
|
31300
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`);
|
|
31301
|
+
if (client.cache) {
|
|
31302
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
31303
|
+
}
|
|
31304
|
+
fireEvent('post.flagged', payload);
|
|
31305
|
+
return !!payload;
|
|
31306
|
+
};
|
|
31307
|
+
/* end_public_function */
|
|
31308
|
+
|
|
31309
|
+
/* begin_public_function
|
|
31310
|
+
id: post.unflag
|
|
31311
|
+
*/
|
|
31312
|
+
/**
|
|
31313
|
+
* ```js
|
|
31314
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
31315
|
+
* const unflagged = await PostRepository.unflagPost(postId)
|
|
31316
|
+
* ```
|
|
31317
|
+
*
|
|
31318
|
+
* @param postId of the post to unflag
|
|
31319
|
+
* @returns the unflag post result
|
|
31320
|
+
*
|
|
31321
|
+
* @category Post API
|
|
31322
|
+
* @async
|
|
31323
|
+
* */
|
|
31324
|
+
const unflagPost = async (postId) => {
|
|
31325
|
+
const client = getActiveClient();
|
|
31326
|
+
client.log('post/unflagPost', postId);
|
|
31327
|
+
const { data: payload } = await client.http.delete(`/api/v3/posts/${encodeURIComponent(postId)}/unflag`);
|
|
31328
|
+
if (client.cache) {
|
|
31329
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
31330
|
+
}
|
|
31331
|
+
fireEvent('post.unflagged', payload);
|
|
31332
|
+
return !!payload;
|
|
31333
|
+
};
|
|
31334
|
+
/* end_public_function */
|
|
31335
|
+
|
|
31336
|
+
/* begin_public_function
|
|
31337
|
+
id: post.check_flag_by_me
|
|
31338
|
+
*/
|
|
31339
|
+
/**
|
|
31340
|
+
* ```js
|
|
31341
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
31342
|
+
* const isReported = await PostRepository.isPostFlaggedByMe('post', postId)
|
|
31343
|
+
* ```
|
|
31344
|
+
*
|
|
31345
|
+
* @param postId of the post to check if flagged by current user
|
|
31346
|
+
* @returns `true` if the post is flagged by me, `false` if doesn't.
|
|
31347
|
+
*
|
|
31348
|
+
* @category Post API
|
|
31349
|
+
* @async
|
|
31350
|
+
* */
|
|
31351
|
+
const isPostFlaggedByMe = async (postId) => {
|
|
31352
|
+
var _a, _b;
|
|
31353
|
+
const client = getActiveClient();
|
|
31354
|
+
client.log('post/isPostFlaggedByMe', postId);
|
|
31355
|
+
const { result, isFlagByMe } = (_a = (await synchronousWSCall(client, 'v3/post.isflagbyme', {
|
|
31356
|
+
postId,
|
|
31357
|
+
}))) !== null && _a !== void 0 ? _a : {};
|
|
31358
|
+
return (_b = result !== null && result !== void 0 ? result : isFlagByMe) !== null && _b !== void 0 ? _b : false;
|
|
31359
|
+
};
|
|
31360
|
+
/* end_public_function */
|
|
31361
|
+
|
|
30768
31362
|
/**
|
|
30769
31363
|
* ```js
|
|
30770
31364
|
* import { PostRepository } from '@amityco/ts-sdk'
|
|
@@ -31055,16 +31649,15 @@ const getPosts = (params, callback, config) => {
|
|
|
31055
31649
|
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
31056
31650
|
}
|
|
31057
31651
|
pushToCache(cacheKey, collection);
|
|
31058
|
-
disposers.push(() => dropFromCache(cacheKey));
|
|
31059
31652
|
responder(collection);
|
|
31060
31653
|
};
|
|
31061
|
-
const onFetch = () => {
|
|
31062
|
-
var _a, _b, _c, _d
|
|
31654
|
+
const onFetch = (initial = false) => {
|
|
31655
|
+
var _a, _b, _c, _d;
|
|
31063
31656
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31064
31657
|
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
31065
|
-
if (posts.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
31658
|
+
if (!initial && posts.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
31066
31659
|
return;
|
|
31067
|
-
const query = createQuery(queryPosts, Object.assign(Object.assign({}, queryParams), { page: (
|
|
31660
|
+
const query = createQuery(queryPosts, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
|
|
31068
31661
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
31069
31662
|
const data = {
|
|
31070
31663
|
loading,
|
|
@@ -31080,7 +31673,8 @@ const getPosts = (params, callback, config) => {
|
|
|
31080
31673
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
31081
31674
|
};
|
|
31082
31675
|
disposers.push(onPostCreated(realtimeRouter('onCreate')), onPostApproved(realtimeRouter('onApproved')), onPostDeclined(realtimeRouter('onDeclined')), onPostDeleted(realtimeRouter('onDelete')), onPostUpdated(realtimeRouter('onUpdate')), onPostFlagged(realtimeRouter('onFlagged')), onPostUnflagged(realtimeRouter('onUnflagged')), onPostReactionAdded(realtimeRouter('onReactionAdded')), onPostReactionRemoved(realtimeRouter('onReactionRemoved')));
|
|
31083
|
-
onFetch();
|
|
31676
|
+
onFetch(true);
|
|
31677
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
31084
31678
|
return () => {
|
|
31085
31679
|
log(`getPosts(tmpid: ${timestamp}) > dispose`);
|
|
31086
31680
|
disposers.forEach(fn => fn());
|
|
@@ -31093,9 +31687,15 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
31093
31687
|
getPostByIds: getPostByIds,
|
|
31094
31688
|
createPost: createPost,
|
|
31095
31689
|
updatePost: updatePost,
|
|
31690
|
+
editPost: editPost,
|
|
31096
31691
|
deletePost: deletePost,
|
|
31692
|
+
softDeletePost: softDeletePost,
|
|
31693
|
+
hardDeletePost: hardDeletePost,
|
|
31097
31694
|
approvePost: approvePost,
|
|
31098
31695
|
declinePost: declinePost,
|
|
31696
|
+
flagPost: flagPost,
|
|
31697
|
+
unflagPost: unflagPost,
|
|
31698
|
+
isPostFlaggedByMe: isPostFlaggedByMe,
|
|
31099
31699
|
onPostCreated: onPostCreated,
|
|
31100
31700
|
onPostUpdated: onPostUpdated,
|
|
31101
31701
|
onPostDeleted: onPostDeleted,
|
|
@@ -31601,13 +32201,13 @@ const getComments = (params, callback, config) => {
|
|
|
31601
32201
|
pushToCache(cacheKey, collection);
|
|
31602
32202
|
responder(collection);
|
|
31603
32203
|
};
|
|
31604
|
-
const onFetch = () => {
|
|
31605
|
-
var _a, _b, _c, _d
|
|
32204
|
+
const onFetch = (initial = false) => {
|
|
32205
|
+
var _a, _b, _c, _d;
|
|
31606
32206
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31607
32207
|
const comments = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
31608
|
-
if (comments.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
32208
|
+
if (!initial && comments.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
31609
32209
|
return;
|
|
31610
|
-
const query = createQuery(queryComments, Object.assign(Object.assign({}, queryParams), { page: (
|
|
32210
|
+
const query = createQuery(queryComments, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
|
|
31611
32211
|
runQuery(query, ({ data: result, error, loading, prevPage, nextPage }) => {
|
|
31612
32212
|
// depend on sortBy value we have two different pagination type
|
|
31613
32213
|
const page = queryParams.sortBy ? nextPage : prevPage;
|
|
@@ -31625,11 +32225,11 @@ const getComments = (params, callback, config) => {
|
|
|
31625
32225
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
31626
32226
|
};
|
|
31627
32227
|
disposers.push(onCommentCreated(realtimeRouter('onCreate')), onCommentUpdated(realtimeRouter('onUpdate')), onCommentDeleted(realtimeRouter('onDelete')), onCommentFlagged(realtimeRouter('onFlagged')), onCommentUnflagged(realtimeRouter('onUnflagged')), onCommentReactionAdded(realtimeRouter('onReactionAdded')), onCommentReactionRemoved(realtimeRouter('onReactionRemoved')));
|
|
31628
|
-
onFetch();
|
|
32228
|
+
onFetch(true);
|
|
32229
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
31629
32230
|
return () => {
|
|
31630
32231
|
log(`getComments(tmpid: ${timestamp}) > dispose`);
|
|
31631
32232
|
disposers.forEach(fn => fn());
|
|
31632
|
-
dropFromCache(cacheKey);
|
|
31633
32233
|
};
|
|
31634
32234
|
};
|
|
31635
32235
|
/* end_public_function */
|
|
@@ -32303,4 +32903,4 @@ const createUserToken = async (apiKey, apiRegion, params) => {
|
|
|
32303
32903
|
return { accessToken: data.accessToken };
|
|
32304
32904
|
};
|
|
32305
32905
|
|
|
32306
|
-
export { API_REGIONS, index$5 as CategoryRepository, index$b as ChannelRepository, index$i as Client, index$2 as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$6 as CommunityRepository, ContentFeedType, DefaultCommunityPostSetting, index$4 as FeedRepository, index$f as FileRepository, FileType, MessageContentType, index$a as MessageRepository, index as PollRepository, PostContentType, index$3 as PostRepository, index$e as ReactionRepository, index$1 as StreamRepository, index$9 as SubChannelRepository, SubscriptionLevels, index$g as UserRepository, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterBySearchTerm, getChannelMarkers, getChannelTopic, getCommentTopic, getCommunityTopic, getMarkedMessageTopic, getMessageMarkers, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getSubChannelMarkers, getSubChannelTopic, getUserMarker, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, onChannelMarkerFetched, onFeedMarkerFetched, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByLastActivity, sortByLastCreated, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };
|
|
32906
|
+
export { API_REGIONS, index$5 as CategoryRepository, index$b as ChannelRepository, index$i as Client, index$2 as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$6 as CommunityRepository, ContentFeedType, DefaultCommunityPostSetting, index$4 as FeedRepository, index$f as FileRepository, FileType, MessageContentType, index$a as MessageRepository, index as PollRepository, PostContentType, index$3 as PostRepository, index$e as ReactionRepository, index$1 as StreamRepository, index$9 as SubChannelRepository, SubscriptionLevels, index$g as UserRepository, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, getChannelMarkers, getChannelTopic, getCommentTopic, getCommunityTopic, getMarkedMessageTopic, getMessageMarkers, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getSubChannelMarkers, getSubChannelTopic, getUserMarker, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByLastActivity, sortByLastCreated, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };
|