@amityco/ts-sdk 7.3.1-508a928.0 → 7.3.1-6783892.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/commentRepository/api/flagComment.d.ts +1 -1
- package/dist/commentRepository/api/flagComment.d.ts.map +1 -1
- package/dist/index.cjs.js +15 -11
- package/dist/index.esm.js +15 -11
- package/dist/index.umd.js +1 -1
- package/dist/messageRepository/api/flagMessage.d.ts +3 -2
- package/dist/messageRepository/api/flagMessage.d.ts.map +1 -1
- package/dist/postRepository/api/flagPost.d.ts +1 -1
- package/dist/postRepository/api/flagPost.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/commentRepository/api/flagComment.ts +6 -8
- package/src/messageRepository/api/flagMessage.ts +17 -2
- package/src/postRepository/api/flagPost.ts +6 -8
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ```js
|
|
3
3
|
* import { MessageRepository } from '@amityco/ts-sdk'
|
|
4
|
-
* const flagged = await MessageRepository.flagMessage(messageId)
|
|
4
|
+
* const flagged = await MessageRepository.flagMessage(messageId, reason)
|
|
5
5
|
* ```
|
|
6
6
|
*
|
|
7
7
|
* @param messageId of the message to flag
|
|
8
|
+
* @param reason the reason to flag the message
|
|
8
9
|
* @returns the created report result
|
|
9
10
|
*
|
|
10
11
|
* @category Message API
|
|
11
12
|
* @async
|
|
12
13
|
* */
|
|
13
|
-
export declare const flagMessage: (messageId: Amity.Message['messageId']) => Promise<boolean>;
|
|
14
|
+
export declare const flagMessage: (messageId: Amity.Message['messageId'], reason: Amity.ContentFlagReason) => Promise<boolean>;
|
|
14
15
|
//# sourceMappingURL=flagMessage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flagMessage.d.ts","sourceRoot":"","sources":["../../../src/messageRepository/api/flagMessage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"flagMessage.d.ts","sourceRoot":"","sources":["../../../src/messageRepository/api/flagMessage.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;KAYK;AACL,eAAO,MAAM,WAAW,cACX,MAAM,OAAO,CAAC,WAAW,CAAC,UAC7B,MAAM,iBAAiB,KAC9B,QAAQ,OAAO,CA0BjB,CAAC"}
|
|
@@ -11,5 +11,5 @@
|
|
|
11
11
|
* @category Post API
|
|
12
12
|
* @async
|
|
13
13
|
* */
|
|
14
|
-
export declare const flagPost: (postId: Amity.Post['postId'], reason
|
|
14
|
+
export declare const flagPost: (postId: Amity.Post['postId'], reason: Amity.ContentFlagReason) => Promise<boolean>;
|
|
15
15
|
//# sourceMappingURL=flagPost.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flagPost.d.ts","sourceRoot":"","sources":["../../../src/postRepository/api/flagPost.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;KAYK;AACL,eAAO,MAAM,QAAQ,WACX,MAAM,IAAI,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"flagPost.d.ts","sourceRoot":"","sources":["../../../src/postRepository/api/flagPost.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;KAYK;AACL,eAAO,MAAM,QAAQ,WACX,MAAM,IAAI,CAAC,QAAQ,CAAC,UACpB,MAAM,iBAAiB,KAC9B,QAAQ,OAAO,CAyBjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -22,20 +22,18 @@ import { ContentFlagReasonEnum } from '~/@types';
|
|
|
22
22
|
* */
|
|
23
23
|
export const flagComment = async (
|
|
24
24
|
commentId: Amity.Comment['commentId'],
|
|
25
|
-
reason
|
|
25
|
+
reason: Amity.ContentFlagReason,
|
|
26
26
|
): Promise<boolean> => {
|
|
27
27
|
const client = getActiveClient();
|
|
28
28
|
client.log('comment/flagComment', commentId);
|
|
29
29
|
|
|
30
|
-
const isPredefinedReason =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason,
|
|
34
|
-
);
|
|
30
|
+
const isPredefinedReason = Object.entries(ContentFlagReasonEnum).some(
|
|
31
|
+
([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason,
|
|
32
|
+
);
|
|
35
33
|
|
|
36
34
|
const body = {
|
|
37
|
-
reason:
|
|
38
|
-
detail:
|
|
35
|
+
reason: isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
|
|
36
|
+
detail: isPredefinedReason ? '' : reason,
|
|
39
37
|
};
|
|
40
38
|
|
|
41
39
|
const { data: payload } = await client.http.post<Amity.CommentPayload>(
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fireEvent } from '~/core/events';
|
|
2
|
+
import { ContentFlagReasonEnum } from '~/@types';
|
|
2
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
3
4
|
import { getActiveClient } from '~/client/api/activeClient';
|
|
4
5
|
import { prepareMessagePayload } from '~/messageRepository/utils';
|
|
@@ -9,21 +10,35 @@ import { prepareMessagePayload } from '~/messageRepository/utils';
|
|
|
9
10
|
/**
|
|
10
11
|
* ```js
|
|
11
12
|
* import { MessageRepository } from '@amityco/ts-sdk'
|
|
12
|
-
* const flagged = await MessageRepository.flagMessage(messageId)
|
|
13
|
+
* const flagged = await MessageRepository.flagMessage(messageId, reason)
|
|
13
14
|
* ```
|
|
14
15
|
*
|
|
15
16
|
* @param messageId of the message to flag
|
|
17
|
+
* @param reason the reason to flag the message
|
|
16
18
|
* @returns the created report result
|
|
17
19
|
*
|
|
18
20
|
* @category Message API
|
|
19
21
|
* @async
|
|
20
22
|
* */
|
|
21
|
-
export const flagMessage = async (
|
|
23
|
+
export const flagMessage = async (
|
|
24
|
+
messageId: Amity.Message['messageId'],
|
|
25
|
+
reason: Amity.ContentFlagReason,
|
|
26
|
+
): Promise<boolean> => {
|
|
22
27
|
const client = getActiveClient();
|
|
23
28
|
client.log('message/flag', messageId);
|
|
24
29
|
|
|
30
|
+
const isPredefinedReason = Object.entries(ContentFlagReasonEnum).some(
|
|
31
|
+
([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason,
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const body = {
|
|
35
|
+
reason: isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
|
|
36
|
+
detail: isPredefinedReason ? '' : reason,
|
|
37
|
+
};
|
|
38
|
+
|
|
25
39
|
const { data: payload } = await client.http.post<Amity.MessagePayload>(
|
|
26
40
|
`/api/v5/messages/${encodeURIComponent(messageId)}/flags`,
|
|
41
|
+
body,
|
|
27
42
|
);
|
|
28
43
|
|
|
29
44
|
if (client.cache) {
|
|
@@ -22,20 +22,18 @@ import { ContentFlagReasonEnum } from '~/@types';
|
|
|
22
22
|
* */
|
|
23
23
|
export const flagPost = async (
|
|
24
24
|
postId: Amity.Post['postId'],
|
|
25
|
-
reason
|
|
25
|
+
reason: Amity.ContentFlagReason,
|
|
26
26
|
): Promise<boolean> => {
|
|
27
27
|
const client = getActiveClient();
|
|
28
28
|
client.log('post/flagPost', postId);
|
|
29
29
|
|
|
30
|
-
const isPredefinedReason =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason,
|
|
34
|
-
);
|
|
30
|
+
const isPredefinedReason = Object.entries(ContentFlagReasonEnum).some(
|
|
31
|
+
([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason,
|
|
32
|
+
);
|
|
35
33
|
|
|
36
34
|
const body = {
|
|
37
|
-
reason:
|
|
38
|
-
detail:
|
|
35
|
+
reason: isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
|
|
36
|
+
detail: isPredefinedReason ? '' : reason,
|
|
39
37
|
};
|
|
40
38
|
|
|
41
39
|
const { data: payload } = await client.http.post<Amity.PostPayload>(
|