@amityco/ts-sdk 0.0.1-beta.39 → 0.0.1-beta.40
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/.eslintrc.json +2 -0
- package/dist/@types/core/events.d.ts +22 -22
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +3 -2
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +87 -34
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +1 -1
- package/dist/@types/domains/client.d.ts +1 -1
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/comment.d.ts +5 -0
- package/dist/@types/domains/comment.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +11 -0
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/content.d.ts +7 -1
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/@types/domains/group.d.ts +2 -2
- package/dist/@types/global.d.ts +8 -0
- package/dist/@types/global.d.ts.map +1 -1
- package/dist/cache/api/ingestInCache.d.ts +2 -1
- package/dist/cache/api/ingestInCache.d.ts.map +1 -1
- package/dist/channel/api/banChannelMembers.d.ts.map +1 -1
- package/dist/channel/api/queryChannelMembers.d.ts.map +1 -1
- package/dist/channel/api/unbanChannelMembers.d.ts.map +1 -1
- package/dist/channel/events/onChannelJoined.d.ts.map +1 -1
- package/dist/channel/events/onChannelLeft.d.ts.map +1 -1
- package/dist/channel/events/onChannelMemberAdded.d.ts.map +1 -1
- package/dist/channel/events/onChannelMemberBanned.d.ts.map +1 -1
- package/dist/channel/events/onChannelMemberRemoved.d.ts.map +1 -1
- package/dist/channel/events/onChannelMemberUnbanned.d.ts.map +1 -1
- package/dist/channel/utils/index.d.ts +2 -2
- package/dist/channel/utils/index.d.ts.map +1 -1
- package/dist/comment/api/createComment.d.ts +1 -1
- package/dist/comment/api/createComment.d.ts.map +1 -1
- package/dist/comment/api/deleteComment.d.ts.map +1 -1
- package/dist/comment/api/tests/updateComment.test.d.ts +2 -0
- package/dist/comment/api/tests/updateComment.test.d.ts.map +1 -0
- package/dist/community/api/addCommunityMembers.d.ts.map +1 -1
- package/dist/community/api/addCommunityMembersRoles.d.ts +1 -1
- package/dist/community/api/addCommunityMembersRoles.d.ts.map +1 -1
- package/dist/community/api/deleteCommunity.d.ts.map +1 -1
- package/dist/community/api/joinCommunity.d.ts.map +1 -1
- package/dist/community/api/leaveCommunity.d.ts.map +1 -1
- package/dist/community/api/queryCommunityMembers.d.ts +1 -7
- package/dist/community/api/queryCommunityMembers.d.ts.map +1 -1
- package/dist/community/api/removeCommunityMembers.d.ts.map +1 -1
- package/dist/community/api/removeCommunityMembersRoles.d.ts +1 -1
- package/dist/community/api/removeCommunityMembersRoles.d.ts.map +1 -1
- package/dist/community/events/index.d.ts +2 -0
- package/dist/community/events/index.d.ts.map +1 -1
- package/dist/community/events/onCommunityUserRoleAdded.d.ts +17 -0
- package/dist/community/events/onCommunityUserRoleAdded.d.ts.map +1 -0
- package/dist/community/events/onCommunityUserRoleRemoved.d.ts +17 -0
- package/dist/community/events/onCommunityUserRoleRemoved.d.ts.map +1 -0
- package/dist/community/events/test/onCommunityUserRoleAdded.test.d.ts +2 -0
- package/dist/community/events/test/onCommunityUserRoleAdded.test.d.ts.map +1 -0
- package/dist/community/events/test/onCommunityUserRoleRemoved.test.d.ts +2 -0
- package/dist/community/events/test/onCommunityUserRoleRemoved.test.d.ts.map +1 -0
- package/dist/community/events/utils.d.ts.map +1 -1
- package/dist/community/observers/index.d.ts +2 -0
- package/dist/community/observers/index.d.ts.map +1 -1
- package/dist/community/observers/liveCommunity.d.ts +21 -0
- package/dist/community/observers/liveCommunity.d.ts.map +1 -0
- package/dist/community/observers/liveCommunityMembers.d.ts +20 -0
- package/dist/community/observers/liveCommunityMembers.d.ts.map +1 -0
- package/dist/community/observers/tests/liveCommunity.test.d.ts +2 -0
- package/dist/community/observers/tests/liveCommunity.test.d.ts.map +1 -0
- package/dist/community/observers/tests/liveCommunityMembers.test.d.ts +2 -0
- package/dist/community/observers/tests/liveCommunityMembers.test.d.ts.map +1 -0
- package/dist/community/utils/payload.d.ts +3 -5
- package/dist/community/utils/payload.d.ts.map +1 -1
- package/dist/core/device.d.ts.map +1 -1
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/model/idResolvers.d.ts +2 -4
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/identifyModel.d.ts +2 -2
- package/dist/core/model/identifyModel.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/core/query/query.d.ts.map +1 -1
- package/dist/external/api/tests/createUserToken.test.d.ts +2 -0
- package/dist/external/api/tests/createUserToken.test.d.ts.map +1 -0
- package/dist/feed/api/queryGlobalFeed.d.ts.map +1 -1
- package/dist/group/utils/withUser.d.ts.map +1 -1
- package/dist/index.cjs.js +481 -200
- package/dist/index.esm.js +477 -200
- package/dist/index.umd.js +4 -4
- package/dist/message/api/createMessage.d.ts.map +1 -1
- package/dist/message/utils/index.d.ts +3 -3
- package/dist/message/utils/index.d.ts.map +1 -1
- package/dist/poll/api/tests/closePoll.test.d.ts +2 -0
- package/dist/poll/api/tests/closePoll.test.d.ts.map +1 -0
- package/dist/poll/api/tests/createPoll.test.d.ts +2 -0
- package/dist/poll/api/tests/createPoll.test.d.ts.map +1 -0
- package/dist/poll/api/tests/getPoll.test.d.ts +2 -0
- package/dist/poll/api/tests/getPoll.test.d.ts.map +1 -0
- package/dist/poll/api/tests/votePoll.test.d.ts +2 -0
- package/dist/poll/api/tests/votePoll.test.d.ts.map +1 -0
- package/dist/post/api/approvePost.d.ts.map +1 -1
- package/dist/post/api/createPost.d.ts.map +1 -1
- package/dist/post/api/declinePost.d.ts.map +1 -1
- package/dist/post/api/deletePost.d.ts.map +1 -1
- package/dist/post/api/getPost.d.ts.map +1 -1
- package/dist/post/api/getPosts.d.ts.map +1 -1
- package/dist/post/api/queryPosts.d.ts.map +1 -1
- package/dist/post/api/updatePost.d.ts.map +1 -1
- package/dist/post/events/utils.d.ts.map +1 -1
- package/dist/reaction/api/queryReactions.d.ts.map +1 -1
- package/dist/reaction/api/removeReaction.d.ts.map +1 -1
- package/dist/reaction/events/onReactorAdded.d.ts.map +1 -1
- package/dist/reaction/events/onReactorRemoved.d.ts.map +1 -1
- package/dist/reaction/utils/dispatchReactable.d.ts +1 -1
- package/dist/reaction/utils/dispatchReactable.d.ts.map +1 -1
- package/dist/report/api/createReport.d.ts.map +1 -1
- package/dist/report/api/deleteReport.d.ts.map +1 -1
- package/dist/subChannel/utils/index.d.ts +1 -1
- package/dist/subChannel/utils/index.d.ts.map +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/tests/dummy/channel.d.ts +31 -35
- package/dist/utils/tests/dummy/channel.d.ts.map +1 -1
- package/dist/utils/tests/dummy/community.d.ts +35 -84
- package/dist/utils/tests/dummy/community.d.ts.map +1 -1
- package/dist/utils/tests/dummy/feed.d.ts +2 -18
- package/dist/utils/tests/dummy/feed.d.ts.map +1 -1
- package/dist/utils/tests/dummy/member.d.ts +1 -1
- package/dist/utils/tests/dummy/post.d.ts +30 -29
- package/dist/utils/tests/dummy/post.d.ts.map +1 -1
- package/dist/version.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/events.ts +22 -20
- package/src/@types/core/model.ts +3 -2
- package/src/@types/core/payload.ts +102 -38
- package/src/@types/domains/channel.ts +1 -1
- package/src/@types/domains/client.ts +1 -1
- package/src/@types/domains/comment.ts +7 -0
- package/src/@types/domains/community.ts +25 -0
- package/src/@types/domains/content.ts +9 -1
- package/src/@types/domains/group.ts +2 -2
- package/src/@types/global.ts +10 -0
- package/src/cache/api/ingestInCache.ts +3 -6
- package/src/cache/api/tests/ingestInCache.test.ts +12 -9
- package/src/channel/api/addChannelMembers.ts +5 -5
- package/src/channel/api/banChannelMembers.ts +1 -3
- package/src/channel/api/getChannel.ts +1 -1
- package/src/channel/api/queryChannelMembers.ts +1 -3
- package/src/channel/api/removeChannelMembers.ts +5 -5
- package/src/channel/api/tests/addChannelMembers.test.ts +4 -3
- package/src/channel/api/tests/createChannel.test.ts +5 -3
- package/src/channel/api/tests/getChannel.test.ts +2 -1
- package/src/channel/api/tests/joinChannel.test.ts +2 -2
- package/src/channel/api/tests/leaveChannel.test.ts +2 -2
- package/src/channel/api/tests/queryChannelMembers.test.ts +2 -5
- package/src/channel/api/tests/queryChannels.test.ts +4 -3
- package/src/channel/api/tests/removeChannelMembers.test.ts +16 -5
- package/src/channel/api/unbanChannelMembers.ts +1 -3
- package/src/channel/events/onChannelJoined.ts +1 -3
- package/src/channel/events/onChannelLeft.ts +1 -3
- package/src/channel/events/onChannelMemberAdded.ts +1 -3
- package/src/channel/events/onChannelMemberBanned.ts +1 -3
- package/src/channel/events/onChannelMemberRemoved.ts +1 -3
- package/src/channel/events/onChannelMemberUnbanned.ts +1 -3
- package/src/channel/observers/tests/liveChannelMembers.test.ts +5 -12
- package/src/channel/observers/tests/liveChannels.test.ts +3 -1
- package/src/channel/utils/index.ts +9 -6
- package/src/comment/api/createComment.ts +18 -2
- package/src/comment/api/deleteComment.ts +19 -2
- package/src/comment/api/tests/createComment.test.ts +169 -9
- package/src/comment/api/tests/updateComment.test.ts +189 -0
- package/src/comment/events/tests/onCommentCreated.test.ts +3 -3
- package/src/comment/events/tests/onCommentDeleted.test.ts +3 -3
- package/src/comment/observers/tests/liveComment.test.ts +18 -2
- package/src/community/api/addCommunityMembers.ts +6 -3
- package/src/community/api/addCommunityMembersRoles.ts +5 -2
- package/src/community/api/createCommunity.ts +5 -5
- package/src/community/api/deleteCommunity.ts +9 -1
- package/src/community/api/getCommunities.ts +2 -2
- package/src/community/api/getCommunity.ts +2 -2
- package/src/community/api/getRecommendedCommunities.ts +2 -2
- package/src/community/api/getTopTrendingCommunities.ts +2 -2
- package/src/community/api/joinCommunity.ts +6 -3
- package/src/community/api/leaveCommunity.ts +6 -3
- package/src/community/api/queryCommunities.ts +3 -3
- package/src/community/api/queryCommunityMembers.ts +3 -7
- package/src/community/api/removeCommunityMembers.ts +7 -3
- package/src/community/api/removeCommunityMembersRoles.ts +5 -2
- package/src/community/api/test/queryCommunityMembers.test.ts +2 -1
- package/src/community/api/test/removeCommunityMemberRole.test.ts +4 -1
- package/src/community/api/updateCommunity.ts +5 -5
- package/src/community/events/index.ts +2 -0
- package/src/community/events/onCommunityUserRoleAdded.ts +20 -0
- package/src/community/events/onCommunityUserRoleRemoved.ts +20 -0
- package/src/community/events/test/onCommunityDeleted.test.ts +8 -1
- package/src/community/events/test/onCommunityUserRoleAdded.test.ts +50 -0
- package/src/community/events/test/onCommunityUserRoleRemoved.test.ts +50 -0
- package/src/community/events/utils.ts +4 -8
- package/src/community/observers/index.ts +4 -0
- package/src/community/observers/liveCommunity.ts +45 -0
- package/src/community/observers/liveCommunityMembers.ts +187 -0
- package/src/community/observers/tests/liveCommunities.test.ts +38 -18
- package/src/community/observers/tests/liveCommunity.test.ts +147 -0
- package/src/community/observers/tests/liveCommunityMembers.test.ts +195 -0
- package/src/community/utils/payload.ts +28 -22
- package/src/core/device.ts +2 -4
- package/src/core/model/idResolvers.ts +4 -3
- package/src/core/model/identifyModel.ts +3 -3
- package/src/core/model/index.ts +1 -0
- package/src/core/query/query.ts +7 -0
- package/src/core/tests/query/query/runQuery.test.ts +8 -3
- package/src/core/tests/subscription.test.ts +80 -2
- package/src/external/api/tests/createUserToken.test.ts +29 -0
- package/src/feed/api/queryGlobalFeed.ts +8 -4
- package/src/group/utils/test/withUsers.test.ts +5 -5
- package/src/group/utils/withUser.ts +20 -14
- package/src/message/api/createMessage.ts +10 -9
- package/src/message/api/getMessage.ts +2 -2
- package/src/message/api/getMessages.ts +1 -1
- package/src/message/api/queryMessages.ts +2 -2
- package/src/message/api/tests/createMessage.test.ts +5 -1
- package/src/message/api/updateMessage.ts +1 -1
- package/src/message/events/onMessageCreated.ts +1 -1
- package/src/message/events/onMessageDeleted.ts +1 -1
- package/src/message/events/onMessageFetched.ts +1 -1
- package/src/message/events/onMessageFlagCleared.ts +1 -1
- package/src/message/events/onMessageFlagged.ts +1 -1
- package/src/message/events/onMessageReactionAdded.ts +1 -1
- package/src/message/events/onMessageReactionRemoved.ts +1 -1
- package/src/message/events/onMessageUnflagged.ts +1 -1
- package/src/message/events/onMessageUpdated.ts +1 -1
- package/src/message/tests/events.test.ts +10 -2
- package/src/message/tests/observers/liveMessage.test.ts +6 -1
- package/src/message/tests/observers/liveMessages.test.ts +16 -3
- package/src/message/utils/index.ts +5 -3
- package/src/poll/api/tests/closePoll.test.ts +50 -0
- package/src/poll/api/tests/createPoll.test.ts +70 -0
- package/src/poll/api/tests/getPoll.test.ts +31 -0
- package/src/poll/api/tests/votePoll.test.ts +41 -0
- package/src/poll/events/onPollDeleted.ts +1 -1
- package/src/poll/events/onPollUpdated.ts +1 -1
- package/src/post/api/approvePost.ts +10 -10
- package/src/post/api/createPost.ts +6 -3
- package/src/post/api/declinePost.ts +11 -11
- package/src/post/api/deletePost.ts +19 -2
- package/src/post/api/getPost.ts +5 -2
- package/src/post/api/getPosts.ts +4 -1
- package/src/post/api/queryPosts.ts +3 -1
- package/src/post/api/tests/queryPosts.test.ts +5 -4
- package/src/post/api/updatePost.ts +4 -1
- package/src/post/events/onPostReactionAdded.ts +1 -1
- package/src/post/events/onPostReactionRemoved.ts +1 -1
- package/src/post/events/utils.ts +12 -2
- package/src/post/observers/tests/livePost.test.ts +10 -3
- package/src/post/observers/tests/livePosts.test.ts +12 -4
- package/src/post/tests/api/getPost.test.ts +13 -3
- package/src/post/tests/api/queryPosts.test.ts +5 -4
- package/src/reaction/api/addReaction.ts +3 -3
- package/src/reaction/api/queryReactions.ts +2 -0
- package/src/reaction/api/removeReaction.ts +4 -3
- package/src/reaction/events/onReactionAdded.ts +3 -3
- package/src/reaction/events/onReactionRemoved.ts +3 -3
- package/src/reaction/events/onReactorAdded.ts +8 -2
- package/src/reaction/events/onReactorRemoved.ts +8 -2
- package/src/reaction/utils/dispatchReactable.ts +1 -1
- package/src/reaction/utils/fetchReference.ts +1 -1
- package/src/report/api/createReport.ts +14 -8
- package/src/report/api/deleteReport.ts +14 -8
- package/src/subChannel/api/createSubChannel.ts +1 -1
- package/src/subChannel/api/getSubChannel.ts +1 -1
- package/src/subChannel/api/getSubChannels.ts +1 -1
- package/src/subChannel/api/querySubChannels.ts +2 -2
- package/src/subChannel/api/updateSubChannel.ts +1 -1
- package/src/subChannel/events/onSubChannelCreated.ts +1 -1
- package/src/subChannel/events/onSubChannelDeleted.ts +1 -1
- package/src/subChannel/events/onSubChannelUpdated.ts +1 -1
- package/src/subChannel/utils/index.ts +2 -2
- package/src/user/observers/tests/liveUsers.test.ts +2 -0
- package/src/user/tests/api/getUser.test.ts +17 -3
- package/src/utils/index.ts +2 -2
- package/src/utils/liveObject.ts +1 -1
- package/src/utils/tests/dummy/channel.ts +18 -11
- package/src/utils/tests/dummy/community.ts +68 -6
- package/src/utils/tests/dummy/feed.ts +1 -1
- package/src/utils/tests/dummy/member.ts +1 -1
- package/src/utils/tests/dummy/post.ts +93 -9
- package/src/version.ts +9 -3
|
@@ -1,19 +1,64 @@
|
|
|
1
|
-
import { createComment } from '../createComment';
|
|
2
1
|
import { getActiveClient } from '~/client/api';
|
|
3
2
|
import {
|
|
4
3
|
client,
|
|
5
4
|
connectClient,
|
|
6
5
|
disconnectClient,
|
|
7
6
|
comment11,
|
|
7
|
+
imageComment11,
|
|
8
|
+
textImageComment11,
|
|
9
|
+
textMentionComment11,
|
|
10
|
+
textWithParentComment11,
|
|
8
11
|
post11,
|
|
9
|
-
|
|
12
|
+
textCommentPayload,
|
|
13
|
+
imageCommentPayload,
|
|
14
|
+
textImageCommentPayload,
|
|
15
|
+
textCommentMentionPayload,
|
|
16
|
+
textCommentParentIdPayload,
|
|
17
|
+
file11,
|
|
18
|
+
user11,
|
|
19
|
+
user12,
|
|
20
|
+
post12,
|
|
10
21
|
} from '~/utils/tests';
|
|
22
|
+
import { ASCApiError } from '~/core/errors';
|
|
23
|
+
import { createComment } from '../createComment';
|
|
11
24
|
|
|
12
|
-
const
|
|
25
|
+
const createTextCommentResponse = {
|
|
13
26
|
data: {
|
|
14
|
-
...
|
|
27
|
+
...textCommentPayload,
|
|
28
|
+
files: [],
|
|
29
|
+
commentChildren: [],
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const createImageCommentResponse = {
|
|
34
|
+
data: {
|
|
35
|
+
...imageCommentPayload,
|
|
36
|
+
files: [],
|
|
15
37
|
commentChildren: [],
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const createTextImageCommentResponse = {
|
|
42
|
+
data: {
|
|
43
|
+
...textImageCommentPayload,
|
|
16
44
|
files: [],
|
|
45
|
+
commentChildren: [],
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const createTextMentionCommentResponse = {
|
|
50
|
+
data: {
|
|
51
|
+
...textCommentMentionPayload,
|
|
52
|
+
files: [],
|
|
53
|
+
commentChildren: [],
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const createTextCommentParentIdResponse = {
|
|
58
|
+
data: {
|
|
59
|
+
...textCommentParentIdPayload,
|
|
60
|
+
files: [],
|
|
61
|
+
commentChildren: [],
|
|
17
62
|
},
|
|
18
63
|
};
|
|
19
64
|
|
|
@@ -22,12 +67,60 @@ const getPostResponse = {
|
|
|
22
67
|
cachedAt: 1673337034544,
|
|
23
68
|
};
|
|
24
69
|
|
|
25
|
-
const
|
|
70
|
+
const textCommentRequestPayload: Parameters<typeof createComment>[0] = {
|
|
71
|
+
referenceId: post11.postId,
|
|
72
|
+
referenceType: 'post',
|
|
73
|
+
data: {
|
|
74
|
+
text: 'test',
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const textCommentParentIdRequestPayload: Parameters<typeof createComment>[0] = {
|
|
79
|
+
referenceId: post11.postId,
|
|
80
|
+
referenceType: 'post',
|
|
81
|
+
parentId: post12.postId,
|
|
82
|
+
data: {
|
|
83
|
+
text: 'test',
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const imageCommentRequestPayload: Parameters<typeof createComment>[0] = {
|
|
88
|
+
referenceId: post11.postId,
|
|
89
|
+
referenceType: 'post',
|
|
90
|
+
attachments: [
|
|
91
|
+
{
|
|
92
|
+
type: 'image',
|
|
93
|
+
fileId: file11.fileId,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const textImageCommentRequestPayload: Parameters<typeof createComment>[0] = {
|
|
26
99
|
referenceId: post11.postId,
|
|
27
100
|
referenceType: 'post',
|
|
28
101
|
data: {
|
|
29
102
|
text: 'test',
|
|
30
103
|
},
|
|
104
|
+
attachments: [
|
|
105
|
+
{
|
|
106
|
+
type: 'image',
|
|
107
|
+
fileId: file11.fileId,
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const textCommentWithMentionRequestPayload: Parameters<typeof createComment>[0] = {
|
|
113
|
+
referenceId: post11.postId,
|
|
114
|
+
referenceType: 'post',
|
|
115
|
+
data: {
|
|
116
|
+
text: 'test',
|
|
117
|
+
},
|
|
118
|
+
mentionees: [
|
|
119
|
+
{
|
|
120
|
+
type: 'user',
|
|
121
|
+
userIds: [user11._id, user12._id],
|
|
122
|
+
},
|
|
123
|
+
],
|
|
31
124
|
};
|
|
32
125
|
|
|
33
126
|
jest.mock('~/post/api/getPost', () => ({
|
|
@@ -38,12 +131,79 @@ describe('createComment', () => {
|
|
|
38
131
|
beforeAll(connectClient);
|
|
39
132
|
afterAll(disconnectClient);
|
|
40
133
|
|
|
41
|
-
|
|
42
|
-
|
|
134
|
+
// integration_test_id: 2f83eabc-46db-43d8-89c6-1b5339d6a273
|
|
135
|
+
it('creates a text comment and returns the new valid comment', async () => {
|
|
136
|
+
client.http.post = jest.fn().mockResolvedValueOnce(createTextCommentResponse);
|
|
43
137
|
|
|
44
|
-
const newComment = await createComment(
|
|
138
|
+
const newComment = await createComment(textCommentRequestPayload);
|
|
45
139
|
|
|
46
|
-
expect(getActiveClient().http.post).toHaveBeenCalledWith(
|
|
140
|
+
expect(getActiveClient().http.post).toHaveBeenCalledWith(
|
|
141
|
+
'/api/v3/comments',
|
|
142
|
+
textCommentRequestPayload,
|
|
143
|
+
);
|
|
47
144
|
expect(newComment.data).toEqual(comment11);
|
|
48
145
|
});
|
|
146
|
+
|
|
147
|
+
// integration_test_id: 81e7d5bc-6881-4f9b-b8d4-deb5fe67200c
|
|
148
|
+
it('creates a image comment and returns the new valid comment', async () => {
|
|
149
|
+
client.http.post = jest.fn().mockResolvedValueOnce(createImageCommentResponse);
|
|
150
|
+
|
|
151
|
+
const newComment = await createComment(imageCommentRequestPayload);
|
|
152
|
+
|
|
153
|
+
expect(getActiveClient().http.post).toHaveBeenCalledWith(
|
|
154
|
+
'/api/v3/comments',
|
|
155
|
+
imageCommentRequestPayload,
|
|
156
|
+
);
|
|
157
|
+
expect(newComment.data).toEqual(imageComment11);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// integration_test_id: 015838a8-3267-4253-920a-9ae83197cf22
|
|
161
|
+
it('creates an image + text comment and returns the new valid comment', async () => {
|
|
162
|
+
client.http.post = jest.fn().mockResolvedValueOnce(createTextImageCommentResponse);
|
|
163
|
+
|
|
164
|
+
const newComment = await createComment(textImageCommentRequestPayload);
|
|
165
|
+
|
|
166
|
+
expect(getActiveClient().http.post).toHaveBeenCalledWith(
|
|
167
|
+
'/api/v3/comments',
|
|
168
|
+
textImageCommentRequestPayload,
|
|
169
|
+
);
|
|
170
|
+
expect(newComment.data).toEqual(textImageComment11);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// integration_test_id: c2285355-f3b6-4e22-926b-11bcf0393161
|
|
174
|
+
it('creates text comment with mention and returns the new valid comment', async () => {
|
|
175
|
+
client.http.post = jest.fn().mockResolvedValueOnce(createTextMentionCommentResponse);
|
|
176
|
+
|
|
177
|
+
const newComment = await createComment(textCommentWithMentionRequestPayload);
|
|
178
|
+
|
|
179
|
+
expect(getActiveClient().http.post).toHaveBeenCalledWith(
|
|
180
|
+
'/api/v3/comments',
|
|
181
|
+
textCommentWithMentionRequestPayload,
|
|
182
|
+
);
|
|
183
|
+
expect(newComment.data).toEqual(textMentionComment11);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// integration_test_id: cb1bfe11-c11a-4324-aeb5-03370da820ad
|
|
187
|
+
it('creates text comment with parent_id and returns the new valid comment', async () => {
|
|
188
|
+
client.http.post = jest.fn().mockResolvedValueOnce(createTextCommentParentIdResponse);
|
|
189
|
+
|
|
190
|
+
const newComment = await createComment(textCommentParentIdRequestPayload);
|
|
191
|
+
|
|
192
|
+
expect(getActiveClient().http.post).toHaveBeenCalledWith(
|
|
193
|
+
'/api/v3/comments',
|
|
194
|
+
textCommentParentIdRequestPayload,
|
|
195
|
+
);
|
|
196
|
+
expect(newComment.data).toEqual(textWithParentComment11);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// integration_test_id: 7f411488-abba-46d1-8707-a1d8adbd7242
|
|
200
|
+
it('creates text comment with invalid parent_id and returns 400400 error', async () => {
|
|
201
|
+
client.http.post = jest
|
|
202
|
+
.fn()
|
|
203
|
+
.mockRejectedValueOnce(
|
|
204
|
+
new ASCApiError('not found!', Amity.ServerError.ITEM_NOT_FOUND, Amity.ErrorLevel.ERROR),
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
await expect(createComment(textCommentParentIdRequestPayload)).rejects.toThrow();
|
|
208
|
+
});
|
|
49
209
|
});
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { createComment } from '../createComment';
|
|
2
|
+
import { updateComment } from '../updateComment';
|
|
3
|
+
import { getActiveClient } from '~/client/api';
|
|
4
|
+
import {
|
|
5
|
+
client,
|
|
6
|
+
connectClient,
|
|
7
|
+
disconnectClient,
|
|
8
|
+
comment11,
|
|
9
|
+
imageComment11,
|
|
10
|
+
textImageComment11,
|
|
11
|
+
textMentionComment11,
|
|
12
|
+
textCommentPayload,
|
|
13
|
+
imageCommentPayload,
|
|
14
|
+
textImageCommentPayload,
|
|
15
|
+
textCommentMentionPayload,
|
|
16
|
+
file11,
|
|
17
|
+
user11,
|
|
18
|
+
user12,
|
|
19
|
+
post11,
|
|
20
|
+
} from '~/utils/tests';
|
|
21
|
+
import { ASCApiError } from '~/core/errors';
|
|
22
|
+
|
|
23
|
+
const updateTextCommentResponse = {
|
|
24
|
+
data: {
|
|
25
|
+
...textCommentPayload,
|
|
26
|
+
files: [],
|
|
27
|
+
commentChildren: [],
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const updateImageCommentResponse = {
|
|
32
|
+
data: {
|
|
33
|
+
...imageCommentPayload,
|
|
34
|
+
files: [],
|
|
35
|
+
commentChildren: [],
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const updateTextMentionCommentResponse = {
|
|
40
|
+
data: {
|
|
41
|
+
...textCommentMentionPayload,
|
|
42
|
+
files: [],
|
|
43
|
+
commentChildren: [],
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const updateTextImageCommentResponse = {
|
|
48
|
+
data: {
|
|
49
|
+
...textImageCommentPayload,
|
|
50
|
+
files: [],
|
|
51
|
+
commentChildren: [],
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const textCommentRequestPayload: Parameters<typeof createComment>[0] = {
|
|
56
|
+
referenceId: post11.postId,
|
|
57
|
+
referenceType: 'post',
|
|
58
|
+
data: {
|
|
59
|
+
text: 'test',
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const textCommentWithMentionRequestPayload: Parameters<typeof createComment>[0] = {
|
|
64
|
+
...textCommentRequestPayload,
|
|
65
|
+
mentionees: [
|
|
66
|
+
{
|
|
67
|
+
type: 'user',
|
|
68
|
+
userIds: [user11._id, user12._id],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const textImageCommentRequestPayload: Parameters<typeof createComment>[0] = {
|
|
74
|
+
...textCommentRequestPayload,
|
|
75
|
+
attachments: [
|
|
76
|
+
{
|
|
77
|
+
type: 'image',
|
|
78
|
+
fileId: file11.fileId,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const imageCommentRequestPayload: Parameters<typeof createComment>[0] = {
|
|
84
|
+
referenceId: post11.postId,
|
|
85
|
+
referenceType: 'post',
|
|
86
|
+
attachments: [
|
|
87
|
+
{
|
|
88
|
+
type: 'image',
|
|
89
|
+
fileId: file11.fileId,
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
describe('updateComment', () => {
|
|
95
|
+
beforeAll(connectClient);
|
|
96
|
+
afterAll(disconnectClient);
|
|
97
|
+
|
|
98
|
+
// functional and logic test
|
|
99
|
+
[
|
|
100
|
+
{
|
|
101
|
+
// integration_test_id: 1f0c74da-863e-44eb-acf1-3de57b1a0e79
|
|
102
|
+
title: 'update comment with valid data and return a new data',
|
|
103
|
+
mockRequest: updateTextCommentResponse,
|
|
104
|
+
mockFunction: textCommentRequestPayload,
|
|
105
|
+
expectResult: comment11,
|
|
106
|
+
extraCase: [],
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
// integration_test_id: 72550ea2-2943-4708-bc36-dd2b4fcf44b7
|
|
110
|
+
title: 'update text comment with mention and returns the new valid comment',
|
|
111
|
+
mockRequest: updateTextMentionCommentResponse,
|
|
112
|
+
mockFunction: textCommentWithMentionRequestPayload,
|
|
113
|
+
expectResult: textMentionComment11,
|
|
114
|
+
extraCase: [],
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
// integration_test_id: 9df2ff6c-81b7-4bdd-bcd2-33d9752735ed
|
|
118
|
+
title: 'update an image + text comment and returns the new valid comment',
|
|
119
|
+
mockRequest: updateTextImageCommentResponse,
|
|
120
|
+
mockFunction: textImageCommentRequestPayload,
|
|
121
|
+
expectResult: textImageComment11,
|
|
122
|
+
extraCase: [],
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
// integration_test_id: 75c77684-09f3-442e-8089-6d37e2182a65
|
|
126
|
+
title: 'add image to existing comment and returns the new valid comment',
|
|
127
|
+
mockRequest: updateTextImageCommentResponse,
|
|
128
|
+
mockFunction: textImageCommentRequestPayload,
|
|
129
|
+
expectResult: textImageComment11,
|
|
130
|
+
extraCase: [],
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
// integration_test_id: b50d7783-ab5e-4473-be3b-08ffe8b5142a
|
|
134
|
+
title: 'remove image from existing comment and returns the new valid comment',
|
|
135
|
+
mockRequest: updateTextCommentResponse,
|
|
136
|
+
mockFunction: textCommentRequestPayload,
|
|
137
|
+
expectResult: comment11,
|
|
138
|
+
extraCase: [{ attachments: [] }],
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
// integration_test_id: f31daa63-7214-400a-a7a1-d9b00d37137e
|
|
142
|
+
title: 'remove text from existing media comment and returns the new valid comment',
|
|
143
|
+
mockRequest: updateImageCommentResponse,
|
|
144
|
+
mockFunction: imageCommentRequestPayload,
|
|
145
|
+
expectResult: imageComment11,
|
|
146
|
+
extraCase: [{ data: { text: '' } }],
|
|
147
|
+
},
|
|
148
|
+
].forEach(({ title, mockRequest, mockFunction, expectResult, extraCase }) =>
|
|
149
|
+
it(title, async () => {
|
|
150
|
+
client.http.put = jest.fn().mockResolvedValueOnce(mockRequest);
|
|
151
|
+
|
|
152
|
+
const newComment = await updateComment(comment11.commentId, mockFunction);
|
|
153
|
+
|
|
154
|
+
expect(getActiveClient().http.put).toHaveBeenCalledWith(
|
|
155
|
+
`/api/v3/comments/${comment11.commentId}`,
|
|
156
|
+
mockFunction,
|
|
157
|
+
);
|
|
158
|
+
expect(newComment.data).toEqual(expectResult);
|
|
159
|
+
|
|
160
|
+
extraCase.forEach(value => {
|
|
161
|
+
expect(newComment.data).toEqual(expect.objectContaining(value));
|
|
162
|
+
});
|
|
163
|
+
}),
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
// Failed case
|
|
167
|
+
[
|
|
168
|
+
{
|
|
169
|
+
// integration_test_id: f2c24783-733e-4a4a-90c4-b518a8d584a1
|
|
170
|
+
title: 'edit text comment with invalid comment_id and returns 400400 error',
|
|
171
|
+
errorCode: Amity.ServerError.ITEM_NOT_FOUND,
|
|
172
|
+
payload: textCommentRequestPayload,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
// integration_test_id: 2f556a4c-2148-4d59-b07e-f415d7c8928c
|
|
176
|
+
title: 'edit text comment which not own by current user and returns 400301 error',
|
|
177
|
+
errorCode: Amity.ServerError.PERMISSION_DENIED,
|
|
178
|
+
payload: textCommentRequestPayload,
|
|
179
|
+
},
|
|
180
|
+
].forEach(({ title, errorCode, payload }) =>
|
|
181
|
+
it(title, async () => {
|
|
182
|
+
client.http.put = jest
|
|
183
|
+
.fn()
|
|
184
|
+
.mockRejectedValueOnce(new ASCApiError('not found!', errorCode, Amity.ErrorLevel.ERROR));
|
|
185
|
+
|
|
186
|
+
await expect(createComment(payload)).rejects.toThrow();
|
|
187
|
+
}),
|
|
188
|
+
);
|
|
189
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { client, comment11,
|
|
1
|
+
import { client, comment11, textCommentPayload } from '~/utils/tests';
|
|
2
2
|
import { onCommentCreated } from '../onCommentCreated';
|
|
3
3
|
|
|
4
4
|
describe('onCommentCreated', () => {
|
|
@@ -6,7 +6,7 @@ describe('onCommentCreated', () => {
|
|
|
6
6
|
const callback = jest.fn();
|
|
7
7
|
|
|
8
8
|
const unsub = onCommentCreated(callback);
|
|
9
|
-
client.emitter.emit('comment.created',
|
|
9
|
+
client.emitter.emit('comment.created', textCommentPayload);
|
|
10
10
|
|
|
11
11
|
unsub();
|
|
12
12
|
|
|
@@ -20,7 +20,7 @@ describe('onCommentCreated', () => {
|
|
|
20
20
|
const unsub = onCommentCreated(callback);
|
|
21
21
|
unsub();
|
|
22
22
|
|
|
23
|
-
client.emitter.emit('comment.created',
|
|
23
|
+
client.emitter.emit('comment.created', textCommentPayload);
|
|
24
24
|
|
|
25
25
|
expect(callback).not.toHaveBeenCalled();
|
|
26
26
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { client, comment11,
|
|
1
|
+
import { client, comment11, textCommentPayload } from '~/utils/tests';
|
|
2
2
|
import { onCommentDeleted } from '../onCommentDeleted';
|
|
3
3
|
|
|
4
4
|
describe('onCommentDeleted', () => {
|
|
@@ -6,7 +6,7 @@ describe('onCommentDeleted', () => {
|
|
|
6
6
|
const callback = jest.fn();
|
|
7
7
|
|
|
8
8
|
const unsub = onCommentDeleted(callback);
|
|
9
|
-
client.emitter.emit('comment.deleted',
|
|
9
|
+
client.emitter.emit('comment.deleted', textCommentPayload);
|
|
10
10
|
|
|
11
11
|
unsub();
|
|
12
12
|
|
|
@@ -20,7 +20,7 @@ describe('onCommentDeleted', () => {
|
|
|
20
20
|
const unsub = onCommentDeleted(callback);
|
|
21
21
|
unsub();
|
|
22
22
|
|
|
23
|
-
client.emitter.emit('comment.deleted',
|
|
23
|
+
client.emitter.emit('comment.deleted', textCommentPayload);
|
|
24
24
|
|
|
25
25
|
expect(callback).not.toHaveBeenCalled();
|
|
26
26
|
});
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
user12,
|
|
9
9
|
} from '~/utils/tests';
|
|
10
10
|
import { getFutureDate } from '~/core/model';
|
|
11
|
+
|
|
11
12
|
import { liveComment } from '../liveComment';
|
|
12
13
|
|
|
13
14
|
describe('liveComment', () => {
|
|
@@ -45,7 +46,14 @@ describe('liveComment', () => {
|
|
|
45
46
|
|
|
46
47
|
liveComment(comment.commentId, callback);
|
|
47
48
|
await pause();
|
|
48
|
-
|
|
49
|
+
|
|
50
|
+
client.emitter.emit(event, {
|
|
51
|
+
comments: [update],
|
|
52
|
+
commentChildren: [],
|
|
53
|
+
users: [],
|
|
54
|
+
files: [],
|
|
55
|
+
});
|
|
56
|
+
|
|
49
57
|
await pause();
|
|
50
58
|
|
|
51
59
|
expect(callback).toHaveBeenCalledTimes(3);
|
|
@@ -80,7 +88,15 @@ describe('liveComment', () => {
|
|
|
80
88
|
|
|
81
89
|
liveComment(comment.commentId, callback);
|
|
82
90
|
await pause();
|
|
83
|
-
|
|
91
|
+
|
|
92
|
+
client.emitter.emit(event, {
|
|
93
|
+
comments: [update],
|
|
94
|
+
reactor,
|
|
95
|
+
commentChildren: [],
|
|
96
|
+
users: [],
|
|
97
|
+
files: [],
|
|
98
|
+
});
|
|
99
|
+
|
|
84
100
|
await pause();
|
|
85
101
|
|
|
86
102
|
expect(callback).toHaveBeenCalledTimes(3);
|
|
@@ -2,6 +2,7 @@ import { getActiveClient } from '~/client/api';
|
|
|
2
2
|
|
|
3
3
|
import { fireEvent } from '~/core/events';
|
|
4
4
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
5
|
+
import { prepareMembershipPayload } from '~/group/utils';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* ```js
|
|
@@ -25,14 +26,16 @@ export const addCommunityMembers = async (
|
|
|
25
26
|
const client = getActiveClient();
|
|
26
27
|
client.log('community/addCommunityMembers', communityId, userIds);
|
|
27
28
|
|
|
28
|
-
const { data } = await client.http.post<Amity.CommunityMembershipPayload>(
|
|
29
|
+
const { data: payload } = await client.http.post<Amity.CommunityMembershipPayload>(
|
|
29
30
|
`/api/v3/communities/${communityId}/users`,
|
|
30
31
|
{ communityId, userIds },
|
|
31
32
|
);
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
fireEvent('community.userAdded', payload);
|
|
35
|
+
|
|
36
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
34
37
|
|
|
35
|
-
|
|
38
|
+
if (client.cache) ingestInCache(data);
|
|
36
39
|
|
|
37
40
|
const { communityUsers } = data;
|
|
38
41
|
return !!communityUsers.find(
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getActiveClient } from '~/client/api';
|
|
2
2
|
|
|
3
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
|
+
import { prepareMembershipPayload } from '~/group/utils';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* ```js
|
|
@@ -12,7 +13,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
12
13
|
*
|
|
13
14
|
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
14
15
|
* @param roleIds Array of IDs of the {@link Amity.Role} to apply
|
|
15
|
-
* @param
|
|
16
|
+
* @param userIds Array of IDs of the {@link Amity.User} to perform
|
|
16
17
|
* @returns A success boolean if the {@link Amity.Role} were added to list of {@link Amity.User} in the {@link Amity.Community}
|
|
17
18
|
*
|
|
18
19
|
* @category Community API
|
|
@@ -26,11 +27,13 @@ export const addCommunityMembersRoles = async (
|
|
|
26
27
|
const client = getActiveClient();
|
|
27
28
|
client.log('community/addCommunityMembersRoles', communityId, roleIds, userIds);
|
|
28
29
|
|
|
29
|
-
const { data } = await client.http.post<Amity.CommunityMembershipPayload>(
|
|
30
|
+
const { data: payload } = await client.http.post<Amity.CommunityMembershipPayload>(
|
|
30
31
|
`/api/v4/communities/${communityId}/users/roles`,
|
|
31
32
|
{ communityId, roles: roleIds, userIds },
|
|
32
33
|
);
|
|
33
34
|
|
|
35
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
36
|
+
|
|
34
37
|
if (client.cache) ingestInCache(data);
|
|
35
38
|
|
|
36
39
|
const { communityUsers } = data;
|
|
@@ -3,7 +3,7 @@ import { getActiveClient } from '~/client/api';
|
|
|
3
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
4
|
import { fireEvent } from '~/core/events';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { prepareCommunityRequest, prepareCommunityPayload } from '../utils';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* ```js
|
|
@@ -41,16 +41,16 @@ export const createCommunity = async (
|
|
|
41
41
|
|
|
42
42
|
const { data: payload } = await client.http.post<Amity.CommunityPayload>(
|
|
43
43
|
'/api/v3/communities/',
|
|
44
|
-
|
|
44
|
+
prepareCommunityRequest(bundle),
|
|
45
45
|
);
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
fireEvent('community.created', payload);
|
|
48
|
+
|
|
49
|
+
const data = prepareCommunityPayload(payload);
|
|
48
50
|
|
|
49
51
|
const cachedAt = client.cache && Date.now();
|
|
50
52
|
if (client.cache) ingestInCache(data, { cachedAt });
|
|
51
53
|
|
|
52
|
-
fireEvent('community.created', data);
|
|
53
|
-
|
|
54
54
|
const { communities } = data;
|
|
55
55
|
return {
|
|
56
56
|
data: communities[0],
|
|
@@ -27,7 +27,15 @@ export const deleteCommunity = async (
|
|
|
27
27
|
await client.http.delete<{ success: boolean }>(`/api/v3/communities/${communityId}`);
|
|
28
28
|
|
|
29
29
|
const deleted = await getCommunity(communityId);
|
|
30
|
-
|
|
30
|
+
|
|
31
|
+
fireEvent('community.deleted', {
|
|
32
|
+
communities: [deleted.data],
|
|
33
|
+
categories: [],
|
|
34
|
+
communityUsers: [],
|
|
35
|
+
feeds: [],
|
|
36
|
+
files: [],
|
|
37
|
+
users: [],
|
|
38
|
+
});
|
|
31
39
|
|
|
32
40
|
return deleted.data;
|
|
33
41
|
};
|
|
@@ -3,7 +3,7 @@ import { getActiveClient } from '~/client/api';
|
|
|
3
3
|
import { pullFromCache } from '~/cache/api';
|
|
4
4
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { prepareCommunityPayload } from '../utils';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* ```js
|
|
@@ -33,7 +33,7 @@ export const getCommunities = async (
|
|
|
33
33
|
},
|
|
34
34
|
);
|
|
35
35
|
|
|
36
|
-
const data =
|
|
36
|
+
const data = prepareCommunityPayload(payload);
|
|
37
37
|
|
|
38
38
|
const cachedAt = client.cache && Date.now();
|
|
39
39
|
if (client.cache) ingestInCache(data, { cachedAt });
|
|
@@ -3,7 +3,7 @@ import { getActiveClient } from '~/client/api';
|
|
|
3
3
|
import { pullFromCache } from '~/cache/api';
|
|
4
4
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { prepareCommunityPayload } from '../utils';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* ```js
|
|
@@ -30,7 +30,7 @@ export const getCommunity = async (
|
|
|
30
30
|
`/api/v3/communities/${communityId}`,
|
|
31
31
|
);
|
|
32
32
|
|
|
33
|
-
const data =
|
|
33
|
+
const data = prepareCommunityPayload(payload);
|
|
34
34
|
|
|
35
35
|
const cachedAt = client.cache && Date.now();
|
|
36
36
|
if (client.cache) ingestInCache(data, { cachedAt });
|
|
@@ -4,7 +4,7 @@ import { getResolver } from '~/core/model';
|
|
|
4
4
|
import { pullFromCache, pushToCache } from '~/cache/api';
|
|
5
5
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { prepareCommunityPayload } from '../utils';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* ```js
|
|
@@ -35,7 +35,7 @@ export const getRecommendedCommunities = async (
|
|
|
35
35
|
{ params: { options: { limit } } },
|
|
36
36
|
);
|
|
37
37
|
|
|
38
|
-
const data =
|
|
38
|
+
const data = prepareCommunityPayload(payload);
|
|
39
39
|
const { communities } = data;
|
|
40
40
|
|
|
41
41
|
const cachedAt = client.cache && Date.now();
|
|
@@ -4,7 +4,7 @@ import { getResolver } from '~/core/model';
|
|
|
4
4
|
import { pullFromCache, pushToCache } from '~/cache/api';
|
|
5
5
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { prepareCommunityPayload } from '../utils';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* ```js
|
|
@@ -35,7 +35,7 @@ export const getTopTrendingCommunities = async (
|
|
|
35
35
|
{ params: { options: { limit } } },
|
|
36
36
|
);
|
|
37
37
|
|
|
38
|
-
const data =
|
|
38
|
+
const data = prepareCommunityPayload(payload);
|
|
39
39
|
const { communities } = data;
|
|
40
40
|
|
|
41
41
|
const cachedAt = client.cache && Date.now();
|