@amityco/ts-sdk 7.2.1-b894bb3a.0 → 7.2.1-c3db7142.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.
@@ -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":"AAUA;;;;;;;;;;;KAWK;AACL,eAAO,MAAM,WAAW,cAAqB,MAAM,OAAO,CAAC,WAAW,CAAC,KAAG,QAAQ,OAAO,CAgBxF,CAAC"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amityco/ts-sdk",
3
- "version": "7.2.1-b894bb3a.0",
3
+ "version": "7.2.1-c3db7142.0",
4
4
  "license": "CC-BY-ND-4.0",
5
5
  "author": "amity.co <developers@amity.co> (https://amity.co)",
6
6
  "description": "Amity Social Cloud Typescript SDK",
@@ -31,7 +31,7 @@ declare global {
31
31
  image9_16: string;
32
32
  callToAction: string;
33
33
  callToActionUrl: string;
34
- targets: Amity.AdTarget;
34
+ target: Amity.AdTarget;
35
35
  startAt: Amity.timestamp;
36
36
  endAt?: Amity.timestamp;
37
37
  createdAt: Amity.timestamp;
@@ -6,8 +6,24 @@ export const ContentFeedType = Object.freeze({
6
6
  MESSAGE: 'message',
7
7
  });
8
8
 
9
+ export enum ContentFlagReasonEnum {
10
+ CommunityGuidelines = 'Against community guidelines',
11
+ HarassmentOrBullying = 'Harassment or bullying',
12
+ SelfHarmOrSuicide = 'Self-harm or suicide',
13
+ ViolenceOrThreateningContent = 'Violence or threatening content',
14
+ SellingRestrictedItems = 'Selling and promoting restricted items',
15
+ SexualContentOrNudity = 'Sexual message or nudity',
16
+ SpamOrScams = 'Spam or scams',
17
+ FalseInformation = 'False information or misinformation',
18
+ Others = 'Others',
19
+ }
20
+
9
21
  declare global {
10
22
  namespace Amity {
23
+ type ContentFlagReason =
24
+ | Exclude<`${ContentFlagReasonEnum}`, `${ContentFlagReasonEnum.Others}`>
25
+ | (string & {});
26
+
11
27
  type ContentType = 'text' | 'image' | 'file' | 'video' | 'poll' | 'json' | string;
12
28
 
13
29
  type ContentFeedType = ValueOf<typeof ContentFeedType>;
@@ -1,8 +1,7 @@
1
- import { getActiveClient } from '~/client/api/activeClient';
2
-
3
- import { ingestInCache } from '~/cache/api/ingestInCache';
4
1
  import { fireEvent } from '~/core/events';
5
-
2
+ import { ContentFlagReasonEnum } from '~/@types';
3
+ import { ingestInCache } from '~/cache/api/ingestInCache';
4
+ import { getActiveClient } from '~/client/api/activeClient';
6
5
  import { prepareMessagePayload } from '~/messageRepository/utils';
7
6
 
8
7
  /* begin_public_function
@@ -11,21 +10,35 @@ import { prepareMessagePayload } from '~/messageRepository/utils';
11
10
  /**
12
11
  * ```js
13
12
  * import { MessageRepository } from '@amityco/ts-sdk'
14
- * const flagged = await MessageRepository.flagMessage(messageId)
13
+ * const flagged = await MessageRepository.flagMessage(messageId, reason)
15
14
  * ```
16
15
  *
17
16
  * @param messageId of the message to flag
17
+ * @param reason the reason to flag the message
18
18
  * @returns the created report result
19
19
  *
20
20
  * @category Message API
21
21
  * @async
22
22
  * */
23
- export const flagMessage = async (messageId: Amity.Message['messageId']): Promise<boolean> => {
23
+ export const flagMessage = async (
24
+ messageId: Amity.Message['messageId'],
25
+ reason: Amity.ContentFlagReason,
26
+ ): Promise<boolean> => {
24
27
  const client = getActiveClient();
25
28
  client.log('message/flag', messageId);
26
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
+
27
39
  const { data: payload } = await client.http.post<Amity.MessagePayload>(
28
40
  `/api/v5/messages/${encodeURIComponent(messageId)}/flags`,
41
+ body,
29
42
  );
30
43
 
31
44
  if (client.cache) {