@amityco/ts-sdk-react-native 7.4.0 → 7.5.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 CHANGED
@@ -135,8 +135,8 @@ const PostContentType = Object.freeze({
135
135
 
136
136
  function getVersion() {
137
137
  try {
138
- // the string ''v7.4.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
139
- return 'v7.4.0-cjs';
138
+ // the string ''v7.5.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
139
+ return 'v7.5.0-cjs';
140
140
  }
141
141
  catch (error) {
142
142
  return '__dev__';
@@ -16088,19 +16088,26 @@ getDeliveredUsers.locally = (query) => {
16088
16088
  /**
16089
16089
  * ```js
16090
16090
  * import { MessageRepository } from '@amityco/ts-sdk-react-native'
16091
- * const flagged = await MessageRepository.flagMessage(messageId)
16091
+ * const flagged = await MessageRepository.flagMessage(messageId, reason)
16092
16092
  * ```
16093
16093
  *
16094
16094
  * @param messageId of the message to flag
16095
+ * @param reason the reason to flag the message
16095
16096
  * @returns the created report result
16096
16097
  *
16097
16098
  * @category Message API
16098
16099
  * @async
16099
16100
  * */
16100
- const flagMessage = async (messageId) => {
16101
+ const flagMessage = async (messageId, reason) => {
16101
16102
  const client = getActiveClient();
16102
16103
  client.log('message/flag', messageId);
16103
- const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`);
16104
+ const isPredefinedReason = reason &&
16105
+ Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
16106
+ const body = {
16107
+ reason: isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
16108
+ detail: !isPredefinedReason ? reason : '',
16109
+ };
16110
+ const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`, body);
16104
16111
  if (client.cache) {
16105
16112
  const messagePayload = await prepareMessagePayload(payload);
16106
16113
  ingestInCache(messagePayload);
package/dist/index.esm.js CHANGED
@@ -101,8 +101,8 @@ const PostContentType = Object.freeze({
101
101
 
102
102
  function getVersion() {
103
103
  try {
104
- // the string ''v7.4.0-esm'' should be replaced by actual value by @rollup/plugin-replace
105
- return 'v7.4.0-esm';
104
+ // the string ''v7.5.0-esm'' should be replaced by actual value by @rollup/plugin-replace
105
+ return 'v7.5.0-esm';
106
106
  }
107
107
  catch (error) {
108
108
  return '__dev__';
@@ -32161,19 +32161,26 @@ getDeliveredUsers.locally = (query) => {
32161
32161
  /**
32162
32162
  * ```js
32163
32163
  * import { MessageRepository } from '@amityco/ts-sdk-react-native'
32164
- * const flagged = await MessageRepository.flagMessage(messageId)
32164
+ * const flagged = await MessageRepository.flagMessage(messageId, reason)
32165
32165
  * ```
32166
32166
  *
32167
32167
  * @param messageId of the message to flag
32168
+ * @param reason the reason to flag the message
32168
32169
  * @returns the created report result
32169
32170
  *
32170
32171
  * @category Message API
32171
32172
  * @async
32172
32173
  * */
32173
- const flagMessage = async (messageId) => {
32174
+ const flagMessage = async (messageId, reason) => {
32174
32175
  const client = getActiveClient();
32175
32176
  client.log('message/flag', messageId);
32176
- const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`);
32177
+ const isPredefinedReason = reason &&
32178
+ Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
32179
+ const body = {
32180
+ reason: isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
32181
+ detail: !isPredefinedReason ? reason : '',
32182
+ };
32183
+ const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`, body);
32177
32184
  if (client.cache) {
32178
32185
  const messagePayload = await prepareMessagePayload(payload);
32179
32186
  ingestInCache(messagePayload);