@amityco/ts-sdk 7.4.1-9b7bc08.0 → 7.4.1-b29d2b5.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/index.cjs.js +10 -3
- package/dist/index.esm.js +10 -3
- 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/package.json +1 -1
- package/src/messageRepository/api/flagMessage.ts +19 -2
package/dist/index.cjs.js
CHANGED
|
@@ -15921,19 +15921,26 @@ getDeliveredUsers.locally = (query) => {
|
|
|
15921
15921
|
/**
|
|
15922
15922
|
* ```js
|
|
15923
15923
|
* import { MessageRepository } from '@amityco/ts-sdk'
|
|
15924
|
-
* const flagged = await MessageRepository.flagMessage(messageId)
|
|
15924
|
+
* const flagged = await MessageRepository.flagMessage(messageId, reason)
|
|
15925
15925
|
* ```
|
|
15926
15926
|
*
|
|
15927
15927
|
* @param messageId of the message to flag
|
|
15928
|
+
* @param reason the reason to flag the message
|
|
15928
15929
|
* @returns the created report result
|
|
15929
15930
|
*
|
|
15930
15931
|
* @category Message API
|
|
15931
15932
|
* @async
|
|
15932
15933
|
* */
|
|
15933
|
-
const flagMessage = async (messageId) => {
|
|
15934
|
+
const flagMessage = async (messageId, reason) => {
|
|
15934
15935
|
const client = getActiveClient();
|
|
15935
15936
|
client.log('message/flag', messageId);
|
|
15936
|
-
const
|
|
15937
|
+
const isPredefinedReason = reason &&
|
|
15938
|
+
Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
|
|
15939
|
+
const body = {
|
|
15940
|
+
reason: isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
|
|
15941
|
+
detail: !isPredefinedReason ? reason : '',
|
|
15942
|
+
};
|
|
15943
|
+
const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`, body);
|
|
15937
15944
|
if (client.cache) {
|
|
15938
15945
|
const messagePayload = await prepareMessagePayload(payload);
|
|
15939
15946
|
ingestInCache(messagePayload);
|
package/dist/index.esm.js
CHANGED
|
@@ -32013,19 +32013,26 @@ getDeliveredUsers.locally = (query) => {
|
|
|
32013
32013
|
/**
|
|
32014
32014
|
* ```js
|
|
32015
32015
|
* import { MessageRepository } from '@amityco/ts-sdk'
|
|
32016
|
-
* const flagged = await MessageRepository.flagMessage(messageId)
|
|
32016
|
+
* const flagged = await MessageRepository.flagMessage(messageId, reason)
|
|
32017
32017
|
* ```
|
|
32018
32018
|
*
|
|
32019
32019
|
* @param messageId of the message to flag
|
|
32020
|
+
* @param reason the reason to flag the message
|
|
32020
32021
|
* @returns the created report result
|
|
32021
32022
|
*
|
|
32022
32023
|
* @category Message API
|
|
32023
32024
|
* @async
|
|
32024
32025
|
* */
|
|
32025
|
-
const flagMessage = async (messageId) => {
|
|
32026
|
+
const flagMessage = async (messageId, reason) => {
|
|
32026
32027
|
const client = getActiveClient();
|
|
32027
32028
|
client.log('message/flag', messageId);
|
|
32028
|
-
const
|
|
32029
|
+
const isPredefinedReason = reason &&
|
|
32030
|
+
Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
|
|
32031
|
+
const body = {
|
|
32032
|
+
reason: isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
|
|
32033
|
+
detail: !isPredefinedReason ? reason : '',
|
|
32034
|
+
};
|
|
32035
|
+
const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`, body);
|
|
32029
32036
|
if (client.cache) {
|
|
32030
32037
|
const messagePayload = await prepareMessagePayload(payload);
|
|
32031
32038
|
ingestInCache(messagePayload);
|