@amityco/ts-sdk 7.3.1-e2dead4.0 → 7.4.1-4207cb63.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/dist/@types/core/events.d.ts +3 -0
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +3 -1
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +22 -4
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/client.d.ts +10 -0
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +11 -1
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/invitation.d.ts +88 -0
- package/dist/@types/domains/invitation.d.ts.map +1 -0
- package/dist/@types/index.d.ts +2 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/commentRepository/api/flagComment.d.ts +3 -2
- package/dist/commentRepository/api/flagComment.d.ts.map +1 -1
- package/dist/communityRepository/api/createCommunity.d.ts +2 -2
- package/dist/communityRepository/api/createCommunity.d.ts.map +1 -1
- package/dist/communityRepository/api/getCommunities.d.ts +1 -1
- package/dist/communityRepository/api/getCommunities.d.ts.map +1 -1
- package/dist/communityRepository/api/getCommunity.d.ts.map +1 -1
- package/dist/communityRepository/api/getRecommendedCommunities.d.ts +3 -1
- package/dist/communityRepository/api/getRecommendedCommunities.d.ts.map +1 -1
- package/dist/communityRepository/api/getTrendingCommunities.d.ts +3 -1
- package/dist/communityRepository/api/getTrendingCommunities.d.ts.map +1 -1
- package/dist/communityRepository/api/queryCommunities.d.ts.map +1 -1
- package/dist/communityRepository/api/updateCommunity.d.ts +2 -2
- package/dist/communityRepository/api/updateCommunity.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityJoined.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityJoined.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityLeft.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityLeft.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserAdded.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserAdded.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserBanned.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserBanned.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserChanged.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserChanged.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserRemoved.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserRemoved.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserRoleAdded.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserRoleAdded.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserUnbanned.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserUnbanned.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityJoined.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityJoined.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityLeft.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityLeft.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/utils.d.ts +2 -2
- package/dist/communityRepository/communityMembership/events/utils.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts +1 -1
- package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts +1 -1
- package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts.map +1 -1
- package/dist/communityRepository/events/onCommunityCreated.d.ts +1 -1
- package/dist/communityRepository/events/onCommunityCreated.d.ts.map +1 -1
- package/dist/communityRepository/events/onCommunityDeleted.d.ts +1 -1
- package/dist/communityRepository/events/onCommunityDeleted.d.ts.map +1 -1
- package/dist/communityRepository/events/onCommunityUpdated.d.ts +1 -1
- package/dist/communityRepository/events/onCommunityUpdated.d.ts.map +1 -1
- package/dist/communityRepository/events/utils.d.ts +1 -1
- package/dist/communityRepository/events/utils.d.ts.map +1 -1
- package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/utils/communityWithMembership.d.ts +1 -1
- package/dist/communityRepository/utils/communityWithMembership.d.ts.map +1 -1
- package/dist/communityRepository/utils/payload.d.ts +1 -1
- package/dist/communityRepository/utils/payload.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.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/index.cjs.js +3234 -2474
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +3203 -2444
- package/dist/index.umd.js +4 -4
- package/dist/invitationRepository/events/index.d.ts +4 -0
- package/dist/invitationRepository/events/index.d.ts.map +1 -0
- package/dist/invitationRepository/events/onLocalInvitationCreated.d.ts +17 -0
- package/dist/invitationRepository/events/onLocalInvitationCreated.d.ts.map +1 -0
- package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts +17 -0
- package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts.map +1 -0
- package/dist/invitationRepository/events/onLocalInvitationUpdated.d.ts +17 -0
- package/dist/invitationRepository/events/onLocalInvitationUpdated.d.ts.map +1 -0
- package/dist/invitationRepository/index.d.ts +3 -0
- package/dist/invitationRepository/index.d.ts.map +1 -0
- package/dist/invitationRepository/internalApi/acceptInvitation.d.ts +16 -0
- package/dist/invitationRepository/internalApi/acceptInvitation.d.ts.map +1 -0
- package/dist/invitationRepository/internalApi/cancelInvitation.d.ts +16 -0
- package/dist/invitationRepository/internalApi/cancelInvitation.d.ts.map +1 -0
- package/dist/invitationRepository/internalApi/createInvitations.d.ts +21 -0
- package/dist/invitationRepository/internalApi/createInvitations.d.ts.map +1 -0
- package/dist/invitationRepository/internalApi/getInvitation.d.ts +17 -0
- package/dist/invitationRepository/internalApi/getInvitation.d.ts.map +1 -0
- package/dist/invitationRepository/internalApi/index.d.ts +5 -0
- package/dist/invitationRepository/internalApi/index.d.ts.map +1 -0
- package/dist/invitationRepository/internalApi/rejectInvitation.d.ts +16 -0
- package/dist/invitationRepository/internalApi/rejectInvitation.d.ts.map +1 -0
- package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts +14 -0
- package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts.map +1 -0
- package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts +5 -0
- package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts.map +1 -0
- package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts +15 -0
- package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts.map +1 -0
- package/dist/invitationRepository/observers/getInvitations/enums.d.ts +6 -0
- package/dist/invitationRepository/observers/getInvitations/enums.d.ts.map +1 -0
- package/dist/invitationRepository/observers/getInvitations.d.ts +12 -0
- package/dist/invitationRepository/observers/getInvitations.d.ts.map +1 -0
- package/dist/invitationRepository/observers/getMyCommunityInvitations.d.ts +12 -0
- package/dist/invitationRepository/observers/getMyCommunityInvitations.d.ts.map +1 -0
- package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsLiveCollectionController.d.ts +14 -0
- package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsLiveCollectionController.d.ts.map +1 -0
- package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.d.ts +5 -0
- package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.d.ts.map +1 -0
- package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts +15 -0
- package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts.map +1 -0
- package/dist/invitationRepository/observers/index.d.ts +2 -0
- package/dist/invitationRepository/observers/index.d.ts.map +1 -0
- package/dist/invitationRepository/utils/convertRawInvitationToInternalInvitation.d.ts +2 -0
- package/dist/invitationRepository/utils/convertRawInvitationToInternalInvitation.d.ts.map +1 -0
- package/dist/invitationRepository/utils/index.d.ts +2 -0
- package/dist/invitationRepository/utils/index.d.ts.map +1 -0
- package/dist/invitationRepository/utils/prepareInvitationPayload.d.ts +2 -0
- package/dist/invitationRepository/utils/prepareInvitationPayload.d.ts.map +1 -0
- package/dist/invitationRepository/utils/prepareMyInvitationsPayload.d.ts +2 -0
- package/dist/invitationRepository/utils/prepareMyInvitationsPayload.d.ts.map +1 -0
- package/dist/messageRepository/api/flagMessage.d.ts +1 -1
- package/dist/messageRepository/api/flagMessage.d.ts.map +1 -1
- package/dist/postRepository/api/flagPost.d.ts +3 -2
- package/dist/postRepository/api/flagPost.d.ts.map +1 -1
- package/dist/utils/linkedObject/communityLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/communityLinkedObject.d.ts.map +1 -0
- package/dist/utils/linkedObject/index.d.ts +2 -0
- package/dist/utils/linkedObject/index.d.ts.map +1 -1
- package/dist/utils/linkedObject/invitationLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/invitationLinkedObject.d.ts.map +1 -0
- package/dist/utils/tests/dummy/post.d.ts +3 -3
- package/package.json +1 -1
- package/src/@types/core/events.ts +4 -0
- package/src/@types/core/model.ts +5 -1
- package/src/@types/core/payload.ts +26 -4
- package/src/@types/domains/client.ts +12 -0
- package/src/@types/domains/community.ts +20 -1
- package/src/@types/domains/invitation.ts +116 -0
- package/src/@types/index.ts +2 -0
- package/src/commentRepository/api/flagComment.ts +20 -3
- package/src/communityRepository/api/createCommunity.ts +5 -2
- package/src/communityRepository/api/getCommunities.ts +7 -2
- package/src/communityRepository/api/getCommunity.ts +5 -2
- package/src/communityRepository/api/getRecommendedCommunities.ts +11 -4
- package/src/communityRepository/api/getTrendingCommunities.ts +11 -4
- package/src/communityRepository/api/queryCommunities.ts +6 -1
- package/src/communityRepository/api/updateCommunity.ts +13 -3
- package/src/communityRepository/communityMembership/events/onCommunityJoined.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityLeft.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserAdded.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserBanned.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserChanged.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserRemoved.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserRoleAdded.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserUnbanned.ts +1 -1
- package/src/communityRepository/communityMembership/events/onLocalCommunityJoined.ts +1 -1
- package/src/communityRepository/communityMembership/events/onLocalCommunityLeft.ts +1 -1
- package/src/communityRepository/communityMembership/events/onLocalCommunityUserAdded.ts +1 -1
- package/src/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.ts +1 -1
- package/src/communityRepository/communityMembership/events/onUserDeleted.ts +3 -1
- package/src/communityRepository/communityMembership/events/utils.ts +2 -2
- package/src/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.ts +8 -2
- package/src/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.ts +8 -2
- package/src/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.ts +1 -1
- package/src/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.ts +1 -1
- package/src/communityRepository/events/onCommunityCreated.ts +1 -1
- package/src/communityRepository/events/onCommunityDeleted.ts +1 -1
- package/src/communityRepository/events/onCommunityUpdated.ts +1 -1
- package/src/communityRepository/events/utils.ts +1 -1
- package/src/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.ts +2 -2
- package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.ts +2 -2
- package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.ts +2 -2
- package/src/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.ts +2 -2
- package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.ts +2 -2
- package/src/communityRepository/utils/communityWithMembership.ts +8 -4
- package/src/communityRepository/utils/payload.ts +1 -1
- package/src/core/liveCollection/PaginationController.ts +1 -1
- package/src/core/liveCollection/PaginationNoPageController.ts +1 -1
- package/src/core/model/idResolvers.ts +2 -0
- package/src/core/model/index.ts +2 -0
- package/src/index.ts +2 -0
- package/src/invitationRepository/events/index.ts +3 -0
- package/src/invitationRepository/events/onLocalInvitationCreated.ts +33 -0
- package/src/invitationRepository/events/onLocalInvitationDeleted.ts +33 -0
- package/src/invitationRepository/events/onLocalInvitationUpdated.ts +33 -0
- package/src/invitationRepository/index.ts +2 -0
- package/src/invitationRepository/internalApi/acceptInvitation.ts +45 -0
- package/src/invitationRepository/internalApi/cancelInvitation.ts +44 -0
- package/src/invitationRepository/internalApi/createInvitations.ts +52 -0
- package/src/invitationRepository/internalApi/getInvitation.ts +47 -0
- package/src/invitationRepository/internalApi/index.ts +4 -0
- package/src/invitationRepository/internalApi/rejectInvitation.ts +45 -0
- package/src/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.ts +148 -0
- package/src/invitationRepository/observers/getInvitations/InvitationsPaginationController.ts +19 -0
- package/src/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.ts +97 -0
- package/src/invitationRepository/observers/getInvitations/enums.ts +5 -0
- package/src/invitationRepository/observers/getInvitations.ts +44 -0
- package/src/invitationRepository/observers/getMyCommunityInvitations.ts +48 -0
- package/src/invitationRepository/observers/getMyInvitations/MyInvitationsLiveCollectionController.ts +148 -0
- package/src/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.ts +22 -0
- package/src/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.ts +105 -0
- package/src/invitationRepository/observers/index.ts +1 -0
- package/src/invitationRepository/utils/convertRawInvitationToInternalInvitation.ts +8 -0
- package/src/invitationRepository/utils/index.ts +1 -0
- package/src/invitationRepository/utils/prepareInvitationPayload.ts +12 -0
- package/src/invitationRepository/utils/prepareMyInvitationsPayload.ts +12 -0
- package/src/messagePreview/utils/getChannelMessagePreviewWithUser.ts +3 -3
- package/src/messageRepository/api/flagMessage.ts +7 -5
- package/src/postRepository/api/flagPost.ts +19 -3
- package/src/utils/linkedObject/communityLinkedObject.ts +36 -0
- package/src/utils/linkedObject/index.ts +4 -0
- package/src/utils/linkedObject/invitationLinkedObject.ts +44 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './prepareInvitationPayload';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { convertRawUserToInternalUser } from '~/userRepository/utils/convertRawUserToInternalUser';
|
|
2
|
+
import { convertRawInvitationToInternalInvitation } from './convertRawInvitationToInternalInvitation';
|
|
3
|
+
|
|
4
|
+
export const prepareInvitationPayload = (
|
|
5
|
+
rawPayload: Amity.InvitationPayload,
|
|
6
|
+
): Amity.ProcessedInvitationPayload => {
|
|
7
|
+
return {
|
|
8
|
+
...rawPayload,
|
|
9
|
+
invitations: rawPayload.invitations.map(convertRawInvitationToInternalInvitation),
|
|
10
|
+
users: rawPayload.users.map(convertRawUserToInternalUser),
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { convertRawUserToInternalUser } from '~/userRepository/utils/convertRawUserToInternalUser';
|
|
2
|
+
import { convertRawInvitationToInternalInvitation } from './convertRawInvitationToInternalInvitation';
|
|
3
|
+
|
|
4
|
+
export const prepareMyInvitationsPayload = (
|
|
5
|
+
rawPayload: Amity.MyInvitationsPayload,
|
|
6
|
+
): Amity.ProcessedMyInvitationsPayload => {
|
|
7
|
+
return {
|
|
8
|
+
...rawPayload,
|
|
9
|
+
users: rawPayload.users.map(convertRawUserToInternalUser),
|
|
10
|
+
invitations: rawPayload.invitations.map(convertRawInvitationToInternalInvitation),
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { pullFromCache } from '~/cache/api';
|
|
1
|
+
import { pullFromCache } from '~/cache/api/pullFromCache';
|
|
2
2
|
import { getChannelMessagePreview } from './getChannelMessagePreview';
|
|
3
|
-
import {
|
|
3
|
+
import { userLinkedObject } from '~/utils/linkedObject/userLinkedObject';
|
|
4
4
|
|
|
5
5
|
export const getChannelMessagePreviewWithUser = (
|
|
6
6
|
channel: Amity.StaticInternalChannel,
|
|
@@ -20,7 +20,7 @@ export const getChannelMessagePreviewWithUser = (
|
|
|
20
20
|
const messagePreviewWithUser = messagePreview
|
|
21
21
|
? {
|
|
22
22
|
...messagePreview,
|
|
23
|
-
user: internalUser ?
|
|
23
|
+
user: internalUser ? userLinkedObject(internalUser) : undefined,
|
|
24
24
|
}
|
|
25
25
|
: null;
|
|
26
26
|
|
|
@@ -22,18 +22,20 @@ import { prepareMessagePayload } from '~/messageRepository/utils';
|
|
|
22
22
|
* */
|
|
23
23
|
export const flagMessage = async (
|
|
24
24
|
messageId: Amity.Message['messageId'],
|
|
25
|
-
reason
|
|
25
|
+
reason?: Amity.ContentFlagReason,
|
|
26
26
|
): Promise<boolean> => {
|
|
27
27
|
const client = getActiveClient();
|
|
28
28
|
client.log('message/flag', messageId);
|
|
29
29
|
|
|
30
|
-
const isPredefinedReason =
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const isPredefinedReason =
|
|
31
|
+
reason &&
|
|
32
|
+
Object.entries(ContentFlagReasonEnum).some(
|
|
33
|
+
([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason,
|
|
34
|
+
);
|
|
33
35
|
|
|
34
36
|
const body = {
|
|
35
37
|
reason: isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
|
|
36
|
-
detail: isPredefinedReason ?
|
|
38
|
+
detail: !isPredefinedReason ? reason : '',
|
|
37
39
|
};
|
|
38
40
|
|
|
39
41
|
const { data: payload } = await client.http.post<Amity.MessagePayload>(
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
-
|
|
3
2
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
3
|
import { fireEvent } from '~/core/events';
|
|
5
4
|
import { prepareMembershipPayload } from '~/group/utils';
|
|
5
|
+
import { ContentFlagReasonEnum } from '~/@types';
|
|
6
6
|
|
|
7
7
|
/* begin_public_function
|
|
8
8
|
id: post.flag
|
|
@@ -10,21 +10,37 @@ import { prepareMembershipPayload } from '~/group/utils';
|
|
|
10
10
|
/**
|
|
11
11
|
* ```js
|
|
12
12
|
* import { PostRepository } from '@amityco/ts-sdk'
|
|
13
|
-
* const flagged = await PostRepository.flagPost(postId)
|
|
13
|
+
* const flagged = await PostRepository.flagPost(postId, reason)
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
16
|
* @param postId of the post to flag
|
|
17
|
+
* @param reason the reason to flag the post
|
|
17
18
|
* @returns a boolean
|
|
18
19
|
*
|
|
19
20
|
* @category Post API
|
|
20
21
|
* @async
|
|
21
22
|
* */
|
|
22
|
-
export const flagPost = async (
|
|
23
|
+
export const flagPost = async (
|
|
24
|
+
postId: Amity.Post['postId'],
|
|
25
|
+
reason?: Amity.ContentFlagReason,
|
|
26
|
+
): Promise<boolean> => {
|
|
23
27
|
const client = getActiveClient();
|
|
24
28
|
client.log('post/flagPost', postId);
|
|
25
29
|
|
|
30
|
+
const isPredefinedReason =
|
|
31
|
+
reason &&
|
|
32
|
+
Object.entries(ContentFlagReasonEnum).some(
|
|
33
|
+
([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason,
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const body = {
|
|
37
|
+
reason: reason && isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
|
|
38
|
+
detail: reason && !isPredefinedReason ? reason : '',
|
|
39
|
+
};
|
|
40
|
+
|
|
26
41
|
const { data: payload } = await client.http.post<Amity.PostPayload>(
|
|
27
42
|
`/api/v3/posts/${encodeURIComponent(postId)}/flag`,
|
|
43
|
+
body,
|
|
28
44
|
);
|
|
29
45
|
|
|
30
46
|
if (client.cache) {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { InvitationTypeEnum } from '~/@types';
|
|
2
|
+
import { createInvitations } from '~/invitationRepository/internalApi';
|
|
3
|
+
import { getInvitation } from '~/invitationRepository/internalApi/getInvitation';
|
|
4
|
+
import { getInvitations } from '~/invitationRepository/observers/getInvitations';
|
|
5
|
+
|
|
6
|
+
export const communityLinkedObject = (community: Amity.InternalCommunity): Amity.Community => {
|
|
7
|
+
return {
|
|
8
|
+
...community,
|
|
9
|
+
createInvitations: async (userIds: string[]): Promise<void> => {
|
|
10
|
+
await createInvitations({
|
|
11
|
+
type: InvitationTypeEnum.CommunityMemberInvite,
|
|
12
|
+
targetType: 'community',
|
|
13
|
+
targetId: community.communityId,
|
|
14
|
+
userIds,
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
getMemberInvitations: (
|
|
18
|
+
params: Pick<Amity.InvitationLiveCollection, 'limit' | 'sortBy' | 'statuses'>,
|
|
19
|
+
callback: Amity.LiveCollectionCallback<Amity.Invitation>,
|
|
20
|
+
): Amity.Unsubscriber => {
|
|
21
|
+
return getInvitations(
|
|
22
|
+
{
|
|
23
|
+
...params,
|
|
24
|
+
targetId: community.communityId,
|
|
25
|
+
targetType: 'community',
|
|
26
|
+
type: InvitationTypeEnum.CommunityMemberInvite,
|
|
27
|
+
},
|
|
28
|
+
callback,
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
getInvitation: async () => {
|
|
32
|
+
const { data } = await getInvitation('community', community.communityId);
|
|
33
|
+
return data;
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -11,6 +11,8 @@ import { channelLinkedObject } from './channelLinkedObject';
|
|
|
11
11
|
import { adLinkedObject } from './adLinkedObject';
|
|
12
12
|
import { pinnedPostLinkedObject } from './pinnedPostLinkedObject';
|
|
13
13
|
import { notificationTrayLinkedObject } from './notificationTrayLinkedObject';
|
|
14
|
+
import { communityLinkedObject } from './communityLinkedObject';
|
|
15
|
+
import { invitationLinkedObject } from './invitationLinkedObject';
|
|
14
16
|
|
|
15
17
|
export const LinkedObject = {
|
|
16
18
|
ad: adLinkedObject,
|
|
@@ -26,4 +28,6 @@ export const LinkedObject = {
|
|
|
26
28
|
channel: channelLinkedObject,
|
|
27
29
|
pinnedPost: pinnedPostLinkedObject,
|
|
28
30
|
notificationTray: notificationTrayLinkedObject,
|
|
31
|
+
community: communityLinkedObject,
|
|
32
|
+
invitation: invitationLinkedObject,
|
|
29
33
|
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { pullFromCache } from '~/cache/api';
|
|
2
|
+
import { userLinkedObject } from './userLinkedObject';
|
|
3
|
+
import {
|
|
4
|
+
acceptInvitation,
|
|
5
|
+
cancelInvitation,
|
|
6
|
+
rejectInvitation,
|
|
7
|
+
} from '~/invitationRepository/internalApi';
|
|
8
|
+
|
|
9
|
+
export const invitationLinkedObject = (invitation: Amity.InternalInvitation): Amity.Invitation => {
|
|
10
|
+
return {
|
|
11
|
+
...invitation,
|
|
12
|
+
get user(): Amity.User | undefined {
|
|
13
|
+
const cacheData = pullFromCache<Amity.User>(['user', 'get', invitation.invitedUserPublicId]);
|
|
14
|
+
if (cacheData?.data) return userLinkedObject(cacheData.data);
|
|
15
|
+
return undefined;
|
|
16
|
+
},
|
|
17
|
+
get createdBy(): Amity.User | undefined {
|
|
18
|
+
const cacheData = pullFromCache<Amity.User>(['user', 'get', invitation.inviterUserPublicId]);
|
|
19
|
+
if (cacheData?.data) return userLinkedObject(cacheData.data);
|
|
20
|
+
return undefined;
|
|
21
|
+
},
|
|
22
|
+
get target(): Amity.InvitationTarget<Amity.InvitationTargetType> | undefined {
|
|
23
|
+
if (invitation.targetType === 'community') {
|
|
24
|
+
const cacheData = pullFromCache<Amity.InternalCommunity>([
|
|
25
|
+
'community',
|
|
26
|
+
'get',
|
|
27
|
+
invitation.targetId,
|
|
28
|
+
]);
|
|
29
|
+
if (cacheData?.data) return cacheData.data;
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
},
|
|
34
|
+
accept: async () => {
|
|
35
|
+
await acceptInvitation(invitation._id);
|
|
36
|
+
},
|
|
37
|
+
reject: async () => {
|
|
38
|
+
await rejectInvitation(invitation._id);
|
|
39
|
+
},
|
|
40
|
+
cancel: async () => {
|
|
41
|
+
await cancelInvitation(invitation._id);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
};
|