@amityco/ts-sdk 7.28.1-d5061930.0 → 7.29.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/errors.d.ts +0 -2
- package/dist/@types/core/errors.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +1 -13
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/content.d.ts +0 -11
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/@types/domains/user.d.ts +0 -31
- package/dist/@types/domains/user.d.ts.map +1 -1
- package/dist/channelRepository/observers/getChannels/ChannelLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/observers/searchChannels/SearchChannelLiveCollectionController.d.ts.map +1 -1
- package/dist/client/api/resumeSession.d.ts.map +1 -1
- package/dist/client/api/setupLoginSubscriptions.d.ts.map +1 -1
- package/dist/commentRepository/api/flagComment.d.ts +5 -72
- package/dist/commentRepository/api/flagComment.d.ts.map +1 -1
- package/dist/commentRepository/internalApi/index.d.ts +0 -2
- package/dist/commentRepository/internalApi/index.d.ts.map +1 -1
- package/dist/core/microtasks.d.ts.map +1 -1
- package/dist/core/query/sorting.d.ts +0 -10
- package/dist/core/query/sorting.d.ts.map +1 -1
- package/dist/index.cjs.js +70 -631
- package/dist/index.esm.js +71 -631
- package/dist/index.umd.js +2 -2
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +0 -1
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts.map +1 -1
- package/dist/messageRepository/api/createMessage.d.ts.map +1 -1
- package/dist/messageRepository/api/flagMessage.d.ts +6 -73
- package/dist/messageRepository/api/flagMessage.d.ts.map +1 -1
- package/dist/postRepository/api/flagPost.d.ts +6 -73
- package/dist/postRepository/api/flagPost.d.ts.map +1 -1
- package/dist/postRepository/internalApi/index.d.ts +0 -2
- package/dist/postRepository/internalApi/index.d.ts.map +1 -1
- package/dist/userRepository/api/flagUser.d.ts +9 -50
- package/dist/userRepository/api/flagUser.d.ts.map +1 -1
- package/dist/userRepository/api/index.d.ts +0 -2
- package/dist/userRepository/api/index.d.ts.map +1 -1
- package/dist/utils/tests/dummy/channel.d.ts +0 -4
- package/dist/utils/tests/dummy/channel.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/channelRepository/observers/tests/integrations/getChannelsSortByLastMessage.integration.test.d.ts +0 -2
- package/dist/channelRepository/observers/tests/integrations/getChannelsSortByLastMessage.integration.test.d.ts.map +0 -1
- package/dist/channelRepository/utils/channelActivityOnLoginHandler.d.ts +0 -16
- package/dist/channelRepository/utils/channelActivityOnLoginHandler.d.ts.map +0 -1
- package/dist/channelRepository/utils/tests/integrations/channelActivity.integration.test.d.ts +0 -2
- package/dist/channelRepository/utils/tests/integrations/channelActivity.integration.test.d.ts.map +0 -1
- package/dist/channelRepository/utils/tests/updateChannelActivityTimestamps.test.d.ts +0 -2
- package/dist/channelRepository/utils/tests/updateChannelActivityTimestamps.test.d.ts.map +0 -1
- package/dist/channelRepository/utils/updateChannelActivityTimestamps.d.ts +0 -34
- package/dist/channelRepository/utils/updateChannelActivityTimestamps.d.ts.map +0 -1
- package/dist/commentRepository/internalApi/flagCommentWithOptions.d.ts +0 -13
- package/dist/commentRepository/internalApi/flagCommentWithOptions.d.ts.map +0 -1
- package/dist/commentRepository/internalApi/flagCommentWithReasonString.d.ts +0 -17
- package/dist/commentRepository/internalApi/flagCommentWithReasonString.d.ts.map +0 -1
- package/dist/commentRepository/internalApi/tests/integration/flagCommentWithOptions.integration.test.d.ts +0 -2
- package/dist/commentRepository/internalApi/tests/integration/flagCommentWithOptions.integration.test.d.ts.map +0 -1
- package/dist/commentRepository/internalApi/tests/integration/flagCommentWithReasonString.integration.test.d.ts +0 -2
- package/dist/commentRepository/internalApi/tests/integration/flagCommentWithReasonString.integration.test.d.ts.map +0 -1
- package/dist/core/query/tests/sorting.test.d.ts +0 -2
- package/dist/core/query/tests/sorting.test.d.ts.map +0 -1
- package/dist/core/tests/microtasks.test.d.ts +0 -2
- package/dist/core/tests/microtasks.test.d.ts.map +0 -1
- package/dist/core/transports/tests/integration/serverErrorCodes.integration.test.d.ts +0 -2
- package/dist/core/transports/tests/integration/serverErrorCodes.integration.test.d.ts.map +0 -1
- package/dist/messageRepository/api/tests/integration/flagMessage.overloads.integration.test.d.ts +0 -2
- package/dist/messageRepository/api/tests/integration/flagMessage.overloads.integration.test.d.ts.map +0 -1
- package/dist/messageRepository/internalApi/flagMessageWithOptions.d.ts +0 -13
- package/dist/messageRepository/internalApi/flagMessageWithOptions.d.ts.map +0 -1
- package/dist/messageRepository/internalApi/flagMessageWithReasonString.d.ts +0 -18
- package/dist/messageRepository/internalApi/flagMessageWithReasonString.d.ts.map +0 -1
- package/dist/messageRepository/internalApi/tests/integration/flagMessageWithOptions.integration.test.d.ts +0 -2
- package/dist/messageRepository/internalApi/tests/integration/flagMessageWithOptions.integration.test.d.ts.map +0 -1
- package/dist/messageRepository/internalApi/tests/integration/flagMessageWithReasonString.integration.test.d.ts +0 -2
- package/dist/messageRepository/internalApi/tests/integration/flagMessageWithReasonString.integration.test.d.ts.map +0 -1
- package/dist/postRepository/api/tests/integration/flagPost.overloads.integration.test.d.ts +0 -2
- package/dist/postRepository/api/tests/integration/flagPost.overloads.integration.test.d.ts.map +0 -1
- package/dist/postRepository/internalApi/flagPostWithOptions.d.ts +0 -13
- package/dist/postRepository/internalApi/flagPostWithOptions.d.ts.map +0 -1
- package/dist/postRepository/internalApi/flagPostWithReasonString.d.ts +0 -17
- package/dist/postRepository/internalApi/flagPostWithReasonString.d.ts.map +0 -1
- package/dist/postRepository/internalApi/tests/integration/flagPostWithOptions.integration.test.d.ts +0 -2
- package/dist/postRepository/internalApi/tests/integration/flagPostWithOptions.integration.test.d.ts.map +0 -1
- package/dist/postRepository/internalApi/tests/integration/flagPostWithReasonString.integration.test.d.ts +0 -2
- package/dist/postRepository/internalApi/tests/integration/flagPostWithReasonString.integration.test.d.ts.map +0 -1
- package/dist/userRepository/api/flagUserBehavior.d.ts +0 -29
- package/dist/userRepository/api/flagUserBehavior.d.ts.map +0 -1
- package/dist/userRepository/api/flagUserProfile.d.ts +0 -29
- package/dist/userRepository/api/flagUserProfile.d.ts.map +0 -1
- package/dist/userRepository/api/tests/integration/flagUser.overloads.integration.test.d.ts +0 -2
- package/dist/userRepository/api/tests/integration/flagUser.overloads.integration.test.d.ts.map +0 -1
- package/dist/userRepository/api/tests/integration/flagUserBehavior.integration.test.d.ts +0 -2
- package/dist/userRepository/api/tests/integration/flagUserBehavior.integration.test.d.ts.map +0 -1
- package/dist/userRepository/api/tests/integration/flagUserProfile.integration.test.d.ts +0 -2
- package/dist/userRepository/api/tests/integration/flagUserProfile.integration.test.d.ts.map +0 -1
- package/dist/userRepository/utils/submitUserReport.d.ts +0 -10
- package/dist/userRepository/utils/submitUserReport.d.ts.map +0 -1
- package/dist/userRepository/utils/userReport.d.ts +0 -35
- package/dist/userRepository/utils/userReport.d.ts.map +0 -1
- package/dist/utils/contentFlag.d.ts +0 -28
- package/dist/utils/contentFlag.d.ts.map +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -58,18 +58,6 @@ exports.UserReportTypeEnum = void 0;
|
|
|
58
58
|
UserReportTypeEnum["AVATAR"] = "avatarFileId";
|
|
59
59
|
UserReportTypeEnum["BEHAVIOR"] = "behavior";
|
|
60
60
|
})(exports.UserReportTypeEnum || (exports.UserReportTypeEnum = {}));
|
|
61
|
-
/**
|
|
62
|
-
* The profile field a user is reported for in `UserRepository.flagUserProfile`.
|
|
63
|
-
* Each member is the backend `reportType` wire value. There is deliberately no
|
|
64
|
-
* behavior member: behavior reports need a reason and go through
|
|
65
|
-
* `UserRepository.flagUserBehavior`.
|
|
66
|
-
*/
|
|
67
|
-
exports.UserProfileFieldEnum = void 0;
|
|
68
|
-
(function (UserProfileFieldEnum) {
|
|
69
|
-
UserProfileFieldEnum["DISPLAY_NAME"] = "displayName";
|
|
70
|
-
UserProfileFieldEnum["DESCRIPTION"] = "description";
|
|
71
|
-
UserProfileFieldEnum["AVATAR"] = "avatarFileId";
|
|
72
|
-
})(exports.UserProfileFieldEnum || (exports.UserProfileFieldEnum = {}));
|
|
73
61
|
|
|
74
62
|
const FileType = Object.freeze({
|
|
75
63
|
FILE: 'file',
|
|
@@ -344,8 +332,8 @@ exports.AmityLiveViewerCountMode = void 0;
|
|
|
344
332
|
|
|
345
333
|
function getVersion() {
|
|
346
334
|
try {
|
|
347
|
-
// the string ''v7.
|
|
348
|
-
return 'v7.
|
|
335
|
+
// the string ''v7.29.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
336
|
+
return 'v7.29.0-cjs';
|
|
349
337
|
}
|
|
350
338
|
catch (error) {
|
|
351
339
|
return '__dev__';
|
|
@@ -846,18 +834,6 @@ class AmityModuleNotEntitledError extends ASCApiError {
|
|
|
846
834
|
this.type = 'AmityModuleNotEntitledError';
|
|
847
835
|
}
|
|
848
836
|
}
|
|
849
|
-
/**
|
|
850
|
-
* Input sanitization related error
|
|
851
|
-
* @category Errors
|
|
852
|
-
*/
|
|
853
|
-
class ASCInvalidParameterError extends ASCError {
|
|
854
|
-
/**
|
|
855
|
-
* @param message A custom error message
|
|
856
|
-
*/
|
|
857
|
-
constructor(message) {
|
|
858
|
-
super(message, 800110 /* Amity.ClientError.INVALID_PARAMETERS */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
837
|
|
|
862
838
|
let activeClient = null;
|
|
863
839
|
/**
|
|
@@ -1631,24 +1607,6 @@ const sortByLastUpdated = ({ updatedAt: a = 0 }, { updatedAt: b = 0 }) => new Da
|
|
|
1631
1607
|
* Sorting a collection by the items with most recent activity
|
|
1632
1608
|
*/
|
|
1633
1609
|
const sortByLastActivity = ({ lastActivity: a }, { lastActivity: b }) => new Date(b).valueOf() - new Date(a).valueOf();
|
|
1634
|
-
/**
|
|
1635
|
-
* Sorting a channel collection by the time of its newest message (newest first).
|
|
1636
|
-
* Channels whose `lastMessageAt` is `null` sort last, ordered by `createdAt`
|
|
1637
|
-
* (newest first) among themselves, matching the server's `sortBy=lastMessage`
|
|
1638
|
-
* order so the local sort agrees with the page order.
|
|
1639
|
-
*/
|
|
1640
|
-
const sortByLastMessage = (a, b) => {
|
|
1641
|
-
var _a, _b;
|
|
1642
|
-
const aAt = (_a = a.lastMessageAt) !== null && _a !== void 0 ? _a : null;
|
|
1643
|
-
const bAt = (_b = b.lastMessageAt) !== null && _b !== void 0 ? _b : null;
|
|
1644
|
-
if (aAt !== null && bAt !== null)
|
|
1645
|
-
return new Date(bAt).valueOf() - new Date(aAt).valueOf();
|
|
1646
|
-
if (aAt !== null)
|
|
1647
|
-
return -1;
|
|
1648
|
-
if (bAt !== null)
|
|
1649
|
-
return 1;
|
|
1650
|
-
return new Date(b.createdAt).valueOf() - new Date(a.createdAt).valueOf();
|
|
1651
|
-
};
|
|
1652
1610
|
/**
|
|
1653
1611
|
* Filter items by untilAt timestamp based on sort direction
|
|
1654
1612
|
* - For 'lastCreated' (newest first): untilAt acts as lower bound, excludes items older than boundary
|
|
@@ -1733,13 +1691,8 @@ const scheduleTask = (task) => {
|
|
|
1733
1691
|
clearTimeout(timer);
|
|
1734
1692
|
tasks.push(task);
|
|
1735
1693
|
timer = setTimeout(() => {
|
|
1736
|
-
|
|
1737
|
-
// while the batch runs (an event handler that fires an event) must land in
|
|
1738
|
-
// a fresh queue and its own timer, not in the array being drained and then
|
|
1739
|
-
// discarded.
|
|
1740
|
-
const batch = tasks;
|
|
1694
|
+
tasks.forEach(fn => fn());
|
|
1741
1695
|
tasks = [];
|
|
1742
|
-
batch.forEach(fn => fn());
|
|
1743
1696
|
}, 0);
|
|
1744
1697
|
};
|
|
1745
1698
|
|
|
@@ -8089,140 +8042,6 @@ const postCommentCountEngineOnLoginHandler = () => onSessionStateChange(state =>
|
|
|
8089
8042
|
}
|
|
8090
8043
|
});
|
|
8091
8044
|
|
|
8092
|
-
const BOTH_FIELDS = { lastActivity: true, lastMessageAt: true };
|
|
8093
|
-
/**
|
|
8094
|
-
* The channel cache is keyed by `channelInternalId`, but a message names its
|
|
8095
|
-
* channel by whichever id the producer had: the raw MQTT payload carries the
|
|
8096
|
-
* internal id, a converted `Amity.InternalMessage` carries the public id, and
|
|
8097
|
-
* the optimistic message carries the sub-channel's `channelId`. Try the direct
|
|
8098
|
-
* key first, then match any of the three ids.
|
|
8099
|
-
*/
|
|
8100
|
-
const findCachedChannel = (channelId) => {
|
|
8101
|
-
var _a, _b, _c;
|
|
8102
|
-
const direct = (_a = pullFromCache(['channel', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
8103
|
-
if (direct)
|
|
8104
|
-
return direct;
|
|
8105
|
-
return (_c = (_b = queryCache(['channel', 'get'])) === null || _b === void 0 ? void 0 : _b.find(({ data }) => data.channelInternalId === channelId ||
|
|
8106
|
-
data.channelId === channelId ||
|
|
8107
|
-
data.channelPublicId === channelId)) === null || _c === void 0 ? void 0 : _c.data;
|
|
8108
|
-
};
|
|
8109
|
-
const isNewer = (stored, at) => !stored || convertDateStringToTimestamp(stored) < convertDateStringToTimestamp(at);
|
|
8110
|
-
const isSameInstant = (stored, at) => !!stored && convertDateStringToTimestamp(stored) === convertDateStringToTimestamp(at);
|
|
8111
|
-
/** Pushes the changed fields in one write and emits one `local.channel.updated`. */
|
|
8112
|
-
const commit = (channel, changes) => {
|
|
8113
|
-
if (Object.keys(changes).length === 0)
|
|
8114
|
-
return false;
|
|
8115
|
-
const updated = shallowClone(channel, changes);
|
|
8116
|
-
// Write back under the key the cache actually uses (the resolver key), not
|
|
8117
|
-
// under `channel.channelId`, which can differ from `channelInternalId`.
|
|
8118
|
-
pushToCache(['channel', 'get', getResolver('channel')(updated)], updated);
|
|
8119
|
-
fireEvent('local.channel.updated', {
|
|
8120
|
-
channels: [updated],
|
|
8121
|
-
channelUsers: [],
|
|
8122
|
-
users: [],
|
|
8123
|
-
files: [],
|
|
8124
|
-
});
|
|
8125
|
-
return true;
|
|
8126
|
-
};
|
|
8127
|
-
/**
|
|
8128
|
-
* Single owner of every local write to a channel's ordering timestamps,
|
|
8129
|
-
* `lastActivity` and `lastMessageAt` (ChannelActivityService v1).
|
|
8130
|
-
*
|
|
8131
|
-
* - Monotonic per field: a field moves only when `at` is newer than the stored
|
|
8132
|
-
* value (or the stored value is `null`), so a late or replayed event never
|
|
8133
|
-
* moves a channel down the list.
|
|
8134
|
-
* - One write: both fields are read, compared and pushed in a single cache
|
|
8135
|
-
* update, followed by one `local.channel.updated` event so every open channel
|
|
8136
|
-
* collection re-sorts once.
|
|
8137
|
-
* - Server channel payloads never go through here; they overwrite unguarded.
|
|
8138
|
-
*
|
|
8139
|
-
* @returns `true` when at least one field moved
|
|
8140
|
-
* @category private
|
|
8141
|
-
*/
|
|
8142
|
-
const updateChannelActivityTimestamps = (channelId, at, fields = BOTH_FIELDS) => {
|
|
8143
|
-
const client = getActiveClient();
|
|
8144
|
-
if (!client.cache || !channelId || !at)
|
|
8145
|
-
return false;
|
|
8146
|
-
const channel = findCachedChannel(channelId);
|
|
8147
|
-
if (!channel)
|
|
8148
|
-
return false;
|
|
8149
|
-
const changes = {};
|
|
8150
|
-
if (fields.lastActivity && isNewer(channel.lastActivity, at))
|
|
8151
|
-
changes.lastActivity = at;
|
|
8152
|
-
if (fields.lastMessageAt && isNewer(channel.lastMessageAt, at))
|
|
8153
|
-
changes.lastMessageAt = at;
|
|
8154
|
-
return commit(channel, changes);
|
|
8155
|
-
};
|
|
8156
|
-
/**
|
|
8157
|
-
* Local correction for the current user's own send (ChannelActivityService v1
|
|
8158
|
-
* REQ-009, Trigger Matrix row 1b). Once the server confirms the message, each
|
|
8159
|
-
* field that still holds the device-clock `localAt` written at send time is
|
|
8160
|
-
* replaced by the server's `serverAt`, even when that is older. A field a newer
|
|
8161
|
-
* message has already moved is left alone. One write, one change notification,
|
|
8162
|
-
* nothing when neither field still holds `localAt`.
|
|
8163
|
-
*
|
|
8164
|
-
* @returns `true` when at least one field was replaced
|
|
8165
|
-
* @category private
|
|
8166
|
-
*/
|
|
8167
|
-
const confirmOwnMessage = (channelId, localAt, serverAt) => {
|
|
8168
|
-
const client = getActiveClient();
|
|
8169
|
-
if (!client.cache || !channelId || !localAt || !serverAt)
|
|
8170
|
-
return false;
|
|
8171
|
-
if (isSameInstant(localAt, serverAt))
|
|
8172
|
-
return false;
|
|
8173
|
-
const channel = findCachedChannel(channelId);
|
|
8174
|
-
if (!channel)
|
|
8175
|
-
return false;
|
|
8176
|
-
const changes = {};
|
|
8177
|
-
if (isSameInstant(channel.lastActivity, localAt))
|
|
8178
|
-
changes.lastActivity = serverAt;
|
|
8179
|
-
if (isSameInstant(channel.lastMessageAt, localAt))
|
|
8180
|
-
changes.lastMessageAt = serverAt;
|
|
8181
|
-
return commit(channel, changes);
|
|
8182
|
-
};
|
|
8183
|
-
|
|
8184
|
-
/**
|
|
8185
|
-
* Session-wide owner of the local `lastActivity` / `lastMessageAt` updates
|
|
8186
|
-
* (ChannelActivityService v1, Web migration rows W1 – W5).
|
|
8187
|
-
*
|
|
8188
|
-
* Registered once per session from `setupLoginSubscriptions` and
|
|
8189
|
-
* `resumeSession`, so the update runs whether or not a channel collection is
|
|
8190
|
-
* open, and exactly once per message however many collections are open.
|
|
8191
|
-
*
|
|
8192
|
-
* It listens to the raw events rather than `onMessageCreatedMqtt`, so it does
|
|
8193
|
-
* not duplicate that subscriber's side effects (mark-read, unread recount).
|
|
8194
|
-
*
|
|
8195
|
-
* @category private
|
|
8196
|
-
*/
|
|
8197
|
-
const channelActivityOnLoginHandler = () => {
|
|
8198
|
-
const client = getActiveClient();
|
|
8199
|
-
const disposers = [
|
|
8200
|
-
// Any user's new message, in any message feed of the channel. The raw
|
|
8201
|
-
// payload's `channelId` is the channel's internal id.
|
|
8202
|
-
createEventSubscriber(client, 'channelActivity', 'message.created', payload => {
|
|
8203
|
-
payload.messages.forEach(message => {
|
|
8204
|
-
updateChannelActivityTimestamps(message.channelId, message.createdAt);
|
|
8205
|
-
});
|
|
8206
|
-
}),
|
|
8207
|
-
// The current user's own send fires this three times: with the optimistic
|
|
8208
|
-
// message at send time (Syncing), on the create response (Synced), and on
|
|
8209
|
-
// failure (Error). The device-clock time of the Syncing / Error fires was
|
|
8210
|
-
// already applied synchronously in createMessageOptimistic, and replaying it
|
|
8211
|
-
// here could undo the server correction made on the response
|
|
8212
|
-
// (confirmOwnMessage). Only the server-confirmed fire goes through the guard.
|
|
8213
|
-
createEventSubscriber(client, 'channelActivity', 'local.message.created', payload => {
|
|
8214
|
-
payload.messages.forEach(message => {
|
|
8215
|
-
if (message.syncState !== "synced" /* Amity.SyncState.Synced */)
|
|
8216
|
-
return;
|
|
8217
|
-
updateChannelActivityTimestamps(message.channelId, message.createdAt);
|
|
8218
|
-
});
|
|
8219
|
-
}),
|
|
8220
|
-
];
|
|
8221
|
-
return () => {
|
|
8222
|
-
disposers.forEach(fn => fn());
|
|
8223
|
-
};
|
|
8224
|
-
};
|
|
8225
|
-
|
|
8226
8045
|
const EVENTS = [
|
|
8227
8046
|
'disconnected',
|
|
8228
8047
|
'error',
|
|
@@ -8412,7 +8231,7 @@ const setupLoginSubscriptions = (unsubWatcher) => {
|
|
|
8412
8231
|
// NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
|
|
8413
8232
|
// the channel because currently backend can't handle this, so every time a user is banned from
|
|
8414
8233
|
// a channel or the channel is deleted the channel's unread count will not be reset to zero
|
|
8415
|
-
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler(), reactionSyncEngineOnLoginHandler(), blockedUserSyncEngineOnLoginHandler(), blockingUserSyncEngineOnLoginHandler(), blockRealtimeOnLoginHandler(), resetAutoSubscriptionsOnLogout(), CursorController.clearOnLogout(), postCommentCountEngineOnLoginHandler()
|
|
8234
|
+
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler(), reactionSyncEngineOnLoginHandler(), blockedUserSyncEngineOnLoginHandler(), blockingUserSyncEngineOnLoginHandler(), blockRealtimeOnLoginHandler(), resetAutoSubscriptionsOnLogout(), CursorController.clearOnLogout(), postCommentCountEngineOnLoginHandler());
|
|
8416
8235
|
if (client.useLegacyUnreadCount) {
|
|
8417
8236
|
subscriptions.push(readReceiptSyncEngineOnLoginHandler());
|
|
8418
8237
|
}
|
|
@@ -9673,7 +9492,7 @@ const resumeSession = async (params, sessionHandler, config) => {
|
|
|
9673
9492
|
// NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
|
|
9674
9493
|
// the channel because currently backend can't handle this, so every time a user is banned from
|
|
9675
9494
|
// a channel or the channel is deleted the channel's unread count will not be reset to zero
|
|
9676
|
-
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler()
|
|
9495
|
+
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler());
|
|
9677
9496
|
if (client.useLegacyUnreadCount) {
|
|
9678
9497
|
subscriptions$1.push(readReceiptSyncEngineOnLoginHandler());
|
|
9679
9498
|
}
|
|
@@ -13632,7 +13451,7 @@ const getWatchSessionStorage = () => {
|
|
|
13632
13451
|
return storageInstance;
|
|
13633
13452
|
};
|
|
13634
13453
|
|
|
13635
|
-
const privateKey = "
|
|
13454
|
+
const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHo80SecH7FuF2\nhFYnb+l26/VN8UMLXAQFLnxciNTEwkGVFMpdezlH8rU2HtUJL4RETogbAOLVY0XM\njs6sPn8G1nALmh9qeDpUtVqFOVtBHxEZ910TLOtQiunjqJKO5nWdqZ71EC3OFluR\niGQkO84BiIFbv37ub7xl3S8XarbtKoLcyVpkDHi+1wx1pgCAn6gtBUgckPL5NR8j\nLseabl3HAXQfhTCKo4tmOFM2Dxwl1IUMmIJrJg/aIU/U0tj/1Eoo7mG0JcNWX19l\nW3EecCbi0ncCJOrkUdwlBrcjaMayaX/ubEwyUeTGiLdyc4L3GRLHjyK8xgVNXRMH\nbZWJ2a5NAgMBAAECggEASxuE+35zTFO/XydKgmvIGcWL9FbgMlXb7Vcf0nBoG945\nbiz0NVc2paraIhJXc608xbYF3qLmtAE1MVBI0ORyRdBHNxY024l/6H6SH60Ed+uI\nM4ysp5ourY6Vj+DLwpdRiI9YDjqYAQDIUmhNxJP7XPhOMoZI6st+xZQBM34ic/bv\nAMSJm9OZphSp3+qXVkFZztr2mxD2EZSJJLYxi8BCdgM2qhazalbcJ6zDKHCZWVWm\n8RRxDGldyMb/237JxETzP40tAlzOZDmBAbUgEnurDJ93RVDIE3rbZUshwgeQd18a\nem096mWgvB1AIKYgsTAR3pw+V19YWAjq/glP6fz8wQKBgQD/oQq+ukKF0PRgBeM5\ngeTjSwsdGppQLmf5ndujvoiz/TpdjDEPu6R8kigQr1rG2t4K/yfdZoI8RdmJD1al\n3Q7N9hofooSy4rj6E3txzWZCHJjHad2cnCp/O26HiReGAl7wTcfTmNdiFHhZQzm5\nJBkvWAiwuvQMNfEbnXxw6/vIDwKBgQDH7fX8gsc77JLvAWgp1MaQN/sbqVb6JeT1\nFQfR8E/WFCSmzQBtNzd5KgYuCeelwr/8DyYytvN2BzCYZXp73gI1jF3YlW5jVn74\nOY6TwQ095digwo6Z0yuxopdIOApKgAkL9PRKgNrqAf3NAyMua6lOGifzjDojC3KU\nfylQmxMn4wKBgHp2B9O/H0dEBw5JQ8W0+JX6yWQz7mEjGiR2/1W+XXb8hQ1zr709\nw1r6Gb+EghRpnZ3fBpYGGbYOMFx8wKHM+N6qW3F0ReX8v2juFGE8aRSa5oYBrWzt\nU16Idjbv8hj84cZ1PJmdyvDtpYn9rpWHOZl4rxEbPvbqkIsOMyNVqdT5AoGAOSge\nmwIIU2le2FVeohbibXiToWTYKMuMmURZ5/r72AgKMmWJKbAPe+Q3wBG01/7FRBpQ\noU8Ma0HC8s6QJbliiEyIx9JwrJWd1vkdecBHONrtA4ibm/5zD2WcOllLF+FitLhi\n3qnX6+6F0IaFGFBPJrTzlv0P4dTz/OAdv52V7GECgYEA2TttOKBAqWllgOaZOkql\nLVMJVmgR7s6tLi1+cEP8ZcapV9aRbRzTAKXm4f8AEhtlG9F9kCOvHYCYGi6JaiWJ\nZkHjeex3T+eE6Di6y5Bm/Ift5jtVhJ4jCVwHOKTMej79NPUFTJfv8hCo29haBDv6\nRXFrv+T21KCcw8k3sJeJWWQ=\n-----END PRIVATE KEY-----";
|
|
13636
13455
|
/*
|
|
13637
13456
|
* The crypto algorithm used for importing key and signing string
|
|
13638
13457
|
*/
|
|
@@ -15431,18 +15250,18 @@ const buildFlagUserBody = (options) => {
|
|
|
15431
15250
|
/**
|
|
15432
15251
|
* ```js
|
|
15433
15252
|
* import { UserRepository } from '@amityco/ts-sdk'
|
|
15434
|
-
*
|
|
15435
|
-
* // Typeless report (supported).
|
|
15436
15253
|
* const flagged = await UserRepository.flagUser('userId')
|
|
15254
|
+
* const flaggedBehavior = await UserRepository.flagUser('userId', {
|
|
15255
|
+
* reportType: 'behavior',
|
|
15256
|
+
* reason: 'Harassment or bullying',
|
|
15257
|
+
* comment: 'optional free-text',
|
|
15258
|
+
* })
|
|
15437
15259
|
* ```
|
|
15438
15260
|
*
|
|
15439
|
-
* Flags a user. Two call shapes are accepted (see the overloads): id-only, which
|
|
15440
|
-
* sends no body and stays supported, and the deprecated structured options object,
|
|
15441
|
-
* whose request mapping is unchanged. New code reporting a profile field or behavior
|
|
15442
|
-
* should use `flagUserProfile` or `flagUserBehavior`.
|
|
15443
|
-
*
|
|
15444
15261
|
* @param userId The ID of the user to be flagged
|
|
15445
|
-
* @param options
|
|
15262
|
+
* @param options Optional report metadata forwarded to the server as the request
|
|
15263
|
+
* body: `reportType`, `reason`, `comment`. Only non-null fields are included.
|
|
15264
|
+
* All validation is server-side; a bodyless call produces a typeless report.
|
|
15446
15265
|
* @returns the flagged {@link Amity.User}
|
|
15447
15266
|
*
|
|
15448
15267
|
* @category User API
|
|
@@ -15463,156 +15282,6 @@ const flagUser = async (userId, options) => {
|
|
|
15463
15282
|
};
|
|
15464
15283
|
/* end_public_function */
|
|
15465
15284
|
|
|
15466
|
-
/**
|
|
15467
|
-
* Sends a validated split user report (`flagUserProfile` / `flagUserBehavior`) to the
|
|
15468
|
-
* same endpoint as `flagUser`, then persists the returned user and fires `user.flagged`
|
|
15469
|
-
* exactly as `flagUser` does, so all three calls share return, cache and event behaviour.
|
|
15470
|
-
*
|
|
15471
|
-
* Not exported from the public API.
|
|
15472
|
-
*/
|
|
15473
|
-
const submitUserReport = async (apiName, userId, body) => {
|
|
15474
|
-
var _a;
|
|
15475
|
-
const client = getActiveClient();
|
|
15476
|
-
client.log(`user/${apiName}`, { userId, body });
|
|
15477
|
-
const { data } = await client.http.post(`/api/v4/me/flags/${encodeURIComponent(userId)}`, body);
|
|
15478
|
-
const payload = prepareUserPayload(data);
|
|
15479
|
-
if (client.cache) {
|
|
15480
|
-
ingestInCache(payload);
|
|
15481
|
-
}
|
|
15482
|
-
fireEvent('user.flagged', data);
|
|
15483
|
-
return (_a = payload.users.find(user => user.userId === userId)) !== null && _a !== void 0 ? _a : payload.users[0];
|
|
15484
|
-
};
|
|
15485
|
-
|
|
15486
|
-
/** Maximum `comment` length, in string length units, after trimming. */
|
|
15487
|
-
const USER_REPORT_COMMENT_MAX_LENGTH = 300;
|
|
15488
|
-
const PROFILE_FIELDS = Object.values(exports.UserProfileFieldEnum);
|
|
15489
|
-
const BEHAVIOR_REASONS = Object.values(exports.ContentFlagReasonEnum);
|
|
15490
|
-
const assertOptionsObject = (apiName, options, shape) => {
|
|
15491
|
-
if (typeof options !== 'object' || options === null || Array.isArray(options)) {
|
|
15492
|
-
throw new ASCInvalidParameterError(`${apiName}: expected an options object \`${shape}\``);
|
|
15493
|
-
}
|
|
15494
|
-
return options;
|
|
15495
|
-
};
|
|
15496
|
-
/**
|
|
15497
|
-
* Normalizes an optional reporter `comment`: it must be a string when supplied (`null`
|
|
15498
|
-
* is not a valid supplied comment); it is trimmed; a blank result is omitted (the
|
|
15499
|
-
* backend rejects `""`); a result longer than 300 characters is rejected before any
|
|
15500
|
-
* request. Otherwise the trimmed text is returned unchanged.
|
|
15501
|
-
*
|
|
15502
|
-
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` for a non-string or over-length comment
|
|
15503
|
-
*/
|
|
15504
|
-
const normalizeUserReportComment = (apiName, comment) => {
|
|
15505
|
-
if (comment === undefined)
|
|
15506
|
-
return undefined;
|
|
15507
|
-
if (typeof comment !== 'string') {
|
|
15508
|
-
throw new ASCInvalidParameterError(`${apiName}: \`comment\` must be a string when supplied`);
|
|
15509
|
-
}
|
|
15510
|
-
const trimmed = comment.trim();
|
|
15511
|
-
if (trimmed.length === 0)
|
|
15512
|
-
return undefined;
|
|
15513
|
-
if (trimmed.length > USER_REPORT_COMMENT_MAX_LENGTH) {
|
|
15514
|
-
throw new ASCInvalidParameterError(`${apiName}: \`comment\` must be at most ${USER_REPORT_COMMENT_MAX_LENGTH} characters after trimming`);
|
|
15515
|
-
}
|
|
15516
|
-
return trimmed;
|
|
15517
|
-
};
|
|
15518
|
-
const withComment = (body, comment) => comment === undefined ? body : Object.assign(Object.assign({}, body), { comment });
|
|
15519
|
-
/**
|
|
15520
|
-
* Validates `flagUserProfile` options and builds its request body. Untyped callers can
|
|
15521
|
-
* pass anything at runtime, so nothing is trusted from the declared type. Any `reason`
|
|
15522
|
-
* key is ignored and never sent.
|
|
15523
|
-
*
|
|
15524
|
-
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when the options are malformed
|
|
15525
|
-
*/
|
|
15526
|
-
const toUserProfileReportBody = (options) => {
|
|
15527
|
-
const apiName = 'flagUserProfile';
|
|
15528
|
-
const { field, comment } = assertOptionsObject(apiName, options, '{ field, comment? }');
|
|
15529
|
-
if (typeof field !== 'string' || !PROFILE_FIELDS.includes(field)) {
|
|
15530
|
-
throw new ASCInvalidParameterError(`${apiName}: \`field\` must be a \`UserProfileFieldEnum\` value`);
|
|
15531
|
-
}
|
|
15532
|
-
return withComment({ reportType: field }, normalizeUserReportComment(apiName, comment));
|
|
15533
|
-
};
|
|
15534
|
-
/**
|
|
15535
|
-
* Validates `flagUserBehavior` options and builds its request body. `reason` must be one
|
|
15536
|
-
* of the nine `ContentFlagReasonEnum` values and is sent as that canonical label;
|
|
15537
|
-
* `reportType` is always `behavior`.
|
|
15538
|
-
*
|
|
15539
|
-
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when the options are malformed
|
|
15540
|
-
*/
|
|
15541
|
-
const toUserBehaviorReportBody = (options) => {
|
|
15542
|
-
const apiName = 'flagUserBehavior';
|
|
15543
|
-
const { reason, comment } = assertOptionsObject(apiName, options, '{ reason, comment? }');
|
|
15544
|
-
if (typeof reason !== 'string' || !BEHAVIOR_REASONS.includes(reason)) {
|
|
15545
|
-
throw new ASCInvalidParameterError(`${apiName}: \`reason\` must be a \`ContentFlagReasonEnum\` value`);
|
|
15546
|
-
}
|
|
15547
|
-
return withComment({ reportType: 'behavior', reason }, normalizeUserReportComment(apiName, comment));
|
|
15548
|
-
};
|
|
15549
|
-
|
|
15550
|
-
/* begin_public_function
|
|
15551
|
-
id: user.flag_profile
|
|
15552
|
-
*/
|
|
15553
|
-
/**
|
|
15554
|
-
* ```js
|
|
15555
|
-
* import { UserRepository, UserProfileFieldEnum } from '@amityco/ts-sdk'
|
|
15556
|
-
* const flagged = await UserRepository.flagUserProfile('userId', {
|
|
15557
|
-
* field: UserProfileFieldEnum.AVATAR,
|
|
15558
|
-
* comment: 'Nudity in profile photo',
|
|
15559
|
-
* })
|
|
15560
|
-
* ```
|
|
15561
|
-
*
|
|
15562
|
-
* Reports one of a user's profile fields (display name, description or avatar). The
|
|
15563
|
-
* call has no reason: profile reports never carry one, so the backend's reason rules
|
|
15564
|
-
* cannot be violated from here. A `reason` key passed at runtime is ignored and never sent.
|
|
15565
|
-
*
|
|
15566
|
-
* `comment` is trimmed; a blank comment is omitted from the request; a comment longer
|
|
15567
|
-
* than 300 characters after trimming is rejected before any request. Otherwise the
|
|
15568
|
-
* trimmed text is sent unchanged.
|
|
15569
|
-
*
|
|
15570
|
-
* Sends `POST /api/v4/me/flags/:userId` with `{ reportType: <field>, comment? }`.
|
|
15571
|
-
*
|
|
15572
|
-
* @param userId The ID of the user to be reported
|
|
15573
|
-
* @param options `field` is a `UserProfileFieldEnum` value; `comment` is optional free text
|
|
15574
|
-
* @returns the flagged {@link Amity.User}
|
|
15575
|
-
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is missing or malformed, or `comment` is over 300 characters, before any request is made
|
|
15576
|
-
*
|
|
15577
|
-
* @category User API
|
|
15578
|
-
* @async
|
|
15579
|
-
* */
|
|
15580
|
-
const flagUserProfile = async (userId, options) => submitUserReport('flagUserProfile', userId, toUserProfileReportBody(options));
|
|
15581
|
-
/* end_public_function */
|
|
15582
|
-
|
|
15583
|
-
/* begin_public_function
|
|
15584
|
-
id: user.flag_behavior
|
|
15585
|
-
*/
|
|
15586
|
-
/**
|
|
15587
|
-
* ```js
|
|
15588
|
-
* import { UserRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk'
|
|
15589
|
-
* const flagged = await UserRepository.flagUserBehavior('userId', {
|
|
15590
|
-
* reason: ContentFlagReasonEnum.Others,
|
|
15591
|
-
* comment: 'Impersonating our brand',
|
|
15592
|
-
* })
|
|
15593
|
-
* ```
|
|
15594
|
-
*
|
|
15595
|
-
* Reports a user's behavior. `reason` is required and is one of the nine
|
|
15596
|
-
* `ContentFlagReasonEnum` values, sent as its canonical label. Reporter text, including
|
|
15597
|
-
* the explanation for `Others`, always travels in `comment`; the reason never carries text.
|
|
15598
|
-
*
|
|
15599
|
-
* `comment` is trimmed; a blank comment is omitted from the request; a comment longer
|
|
15600
|
-
* than 300 characters after trimming is rejected before any request. Otherwise the
|
|
15601
|
-
* trimmed text is sent unchanged.
|
|
15602
|
-
*
|
|
15603
|
-
* Sends `POST /api/v4/me/flags/:userId` with `{ reportType: 'behavior', reason, comment? }`.
|
|
15604
|
-
*
|
|
15605
|
-
* @param userId The ID of the user to be reported
|
|
15606
|
-
* @param options `reason` is a `ContentFlagReasonEnum` value; `comment` is optional free text
|
|
15607
|
-
* @returns the flagged {@link Amity.User}
|
|
15608
|
-
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is missing or malformed, `reason` is missing or unknown, or `comment` is over 300 characters, before any request is made
|
|
15609
|
-
*
|
|
15610
|
-
* @category User API
|
|
15611
|
-
* @async
|
|
15612
|
-
* */
|
|
15613
|
-
const flagUserBehavior = async (userId, options) => submitUserReport('flagUserBehavior', userId, toUserBehaviorReportBody(options));
|
|
15614
|
-
/* end_public_function */
|
|
15615
|
-
|
|
15616
15285
|
/* begin_public_function
|
|
15617
15286
|
id: user.unflag
|
|
15618
15287
|
*/
|
|
@@ -16787,8 +16456,6 @@ var index$r = /*#__PURE__*/Object.freeze({
|
|
|
16787
16456
|
getUserByIds: getUserByIds,
|
|
16788
16457
|
updateUser: updateUser,
|
|
16789
16458
|
flagUser: flagUser,
|
|
16790
|
-
flagUserProfile: flagUserProfile,
|
|
16791
|
-
flagUserBehavior: flagUserBehavior,
|
|
16792
16459
|
unflagUser: unflagUser,
|
|
16793
16460
|
isUserFlaggedByMe: isUserFlaggedByMe,
|
|
16794
16461
|
getAllBlockedUsers: getAllBlockedUsers,
|
|
@@ -19827,7 +19494,7 @@ const getLocalId = () => `LOCAL_${uuid()}`;
|
|
|
19827
19494
|
// FIXME: temp solution
|
|
19828
19495
|
let uniqueId;
|
|
19829
19496
|
const createMessageOptimistic = (bundle) => {
|
|
19830
|
-
var _a, _b
|
|
19497
|
+
var _a, _b;
|
|
19831
19498
|
const client = getActiveClient();
|
|
19832
19499
|
if (!client.cache)
|
|
19833
19500
|
return;
|
|
@@ -19858,19 +19525,9 @@ const createMessageOptimistic = (bundle) => {
|
|
|
19858
19525
|
}
|
|
19859
19526
|
// as reused to update created and updated time, which should be the same
|
|
19860
19527
|
const createdTime = new Date().toISOString();
|
|
19861
|
-
const message = Object.assign({
|
|
19862
|
-
// The optimistic message must name its channel so the own-send update can
|
|
19863
|
-
// move lastActivity / lastMessageAt at send time. Take it from the cached
|
|
19864
|
-
// sub-channel; when that is not cached, fall back to the sub-channel id,
|
|
19865
|
-
// which for a channel's default sub-channel is the channel id
|
|
19866
|
-
// (ChannelActivityService migration row I2).
|
|
19867
|
-
channelId: (_b = subChannel === null || subChannel === void 0 ? void 0 : subChannel.data.channelId) !== null && _b !== void 0 ? _b : bundle.subChannelId, creatorId: client.userId, creatorPrivateId: getActiveUser()._id, channelSegment: ((_c = subChannel === null || subChannel === void 0 ? void 0 : subChannel.data.messageCount) !== null && _c !== void 0 ? _c : 0) + 1, childrenNumber: 0, createdAt: createdTime, updatedAt: createdTime, syncState: "syncing" /* Amity.SyncState.Syncing */, isDeleted: false }, bundleWithMessageId);
|
|
19528
|
+
const message = Object.assign({ creatorId: client.userId, creatorPrivateId: getActiveUser()._id, channelSegment: ((_b = subChannel === null || subChannel === void 0 ? void 0 : subChannel.data.messageCount) !== null && _b !== void 0 ? _b : 0) + 1, childrenNumber: 0, createdAt: createdTime, updatedAt: createdTime, syncState: "syncing" /* Amity.SyncState.Syncing */, isDeleted: false }, bundleWithMessageId);
|
|
19868
19529
|
const cachedAt = UNSYNCED_OBJECT_CACHED_AT_VALUE;
|
|
19869
19530
|
pushToCache(['message', 'get', message.messageId], message, { cachedAt });
|
|
19870
|
-
// Own-send update (ChannelActivityService row 1): move the channel at send
|
|
19871
|
-
// time, synchronously, so the confirmation on the send response always sees
|
|
19872
|
-
// this value rather than racing the scheduled local event below.
|
|
19873
|
-
updateChannelActivityTimestamps(message.channelId, message.createdAt);
|
|
19874
19531
|
fireEvent('local.message.created', { messages: [message] });
|
|
19875
19532
|
return message;
|
|
19876
19533
|
};
|
|
@@ -19910,9 +19567,6 @@ const createMessage = async (bundle) => {
|
|
|
19910
19567
|
if (client.cache) {
|
|
19911
19568
|
ingestInCache(data, { cachedAt });
|
|
19912
19569
|
}
|
|
19913
|
-
// The own-send update wrote the device-clock createdAt; replace it with the
|
|
19914
|
-
// server's now that the message is confirmed (ChannelActivityService REQ-009).
|
|
19915
|
-
confirmOwnMessage(optimisticData === null || optimisticData === void 0 ? void 0 : optimisticData.channelId, optimisticData === null || optimisticData === void 0 ? void 0 : optimisticData.createdAt, messages[0].createdAt);
|
|
19916
19570
|
fireEvent('local.message.created', {
|
|
19917
19571
|
messages: [Object.assign(Object.assign({}, messages[0]), { syncState: "synced" /* Amity.SyncState.Synced */ })],
|
|
19918
19572
|
});
|
|
@@ -20506,85 +20160,23 @@ getDeliveredUsers.locally = (query) => {
|
|
|
20506
20160
|
return { data: users, cachedAt, prevPage, nextPage };
|
|
20507
20161
|
};
|
|
20508
20162
|
|
|
20509
|
-
|
|
20510
|
-
|
|
20511
|
-
|
|
20512
|
-
* or nothing). Anything else is routed to the `Amity.ContentFlagOptions` path, whose
|
|
20513
|
-
* validation rejects malformed values before any request is made.
|
|
20514
|
-
*/
|
|
20515
|
-
const isLegacyContentFlagReason = (input) => input === undefined || typeof input === 'string';
|
|
20516
|
-
/**
|
|
20517
|
-
* Validates an `Amity.ContentFlagOptions` argument. Untyped (plain JS) callers can pass
|
|
20518
|
-
* anything at runtime, so the checks do not trust the declared type: the value must be a
|
|
20519
|
-
* plain object, `reason` must be one of the nine `ContentFlagReasonEnum` values and
|
|
20520
|
-
* `detail`, when supplied, must be a string (`null` is not a valid supplied detail).
|
|
20521
|
-
*
|
|
20522
|
-
* @param apiName used in the error message, e.g. `flagPost`
|
|
20523
|
-
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when the options are malformed
|
|
20524
|
-
*/
|
|
20525
|
-
const validateContentFlagOptions = (apiName, options) => {
|
|
20526
|
-
if (typeof options !== 'object' || options === null || Array.isArray(options)) {
|
|
20527
|
-
throw new ASCInvalidParameterError(`${apiName}: expected an options object \`{ reason, detail? }\``);
|
|
20528
|
-
}
|
|
20529
|
-
const { reason, detail } = options;
|
|
20530
|
-
if (typeof reason !== 'string' || !CONTENT_FLAG_REASONS.includes(reason)) {
|
|
20531
|
-
throw new ASCInvalidParameterError(`${apiName}: \`reason\` must be a \`ContentFlagReasonEnum\` value`);
|
|
20532
|
-
}
|
|
20533
|
-
if (detail !== undefined && typeof detail !== 'string') {
|
|
20534
|
-
throw new ASCInvalidParameterError(`${apiName}: \`detail\` must be a string when supplied`);
|
|
20535
|
-
}
|
|
20536
|
-
return { reason: reason, detail };
|
|
20537
|
-
};
|
|
20538
|
-
/**
|
|
20539
|
-
* Builds the request body for validated options. `detail` is forwarded unchanged (empty
|
|
20540
|
-
* and whitespace-only strings included) and omitted from the body when `undefined`; the
|
|
20541
|
-
* backend enforces the 300-character limit.
|
|
20542
|
-
*/
|
|
20543
|
-
const toContentFlagBody = ({ reason, detail }) => detail === undefined ? { reason } : { reason, detail };
|
|
20544
|
-
|
|
20545
|
-
/**
|
|
20546
|
-
* New `flagMessage(messageId, { reason, detail? })` implementation. Any category,
|
|
20547
|
-
* including `Others`, may carry a `detail`. `detail` is forwarded unchanged (empty and
|
|
20548
|
-
* whitespace-only strings included) and omitted from the request body when `undefined`;
|
|
20549
|
-
* the backend enforces the 300-character limit.
|
|
20550
|
-
*
|
|
20551
|
-
* Not exported from the public API. It is reached through the
|
|
20552
|
-
* `MessageRepository.flagMessage(messageId, options)` overload; see `api/flagMessage.ts`.
|
|
20553
|
-
*
|
|
20554
|
-
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
|
|
20555
|
-
*/
|
|
20556
|
-
const flagMessageWithOptions = async (messageId, options) => {
|
|
20557
|
-
// Validate first: an input error must surface as INVALID_PARAMETERS regardless of
|
|
20558
|
-
// whether a client is active, and validation needs nothing from the client.
|
|
20559
|
-
const body = toContentFlagBody(validateContentFlagOptions('flagMessage', options));
|
|
20560
|
-
const client = getActiveClient();
|
|
20561
|
-
client.log('message/flag', messageId);
|
|
20562
|
-
const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`, body);
|
|
20563
|
-
if (client.cache) {
|
|
20564
|
-
const messagePayload = await prepareMessagePayload(payload);
|
|
20565
|
-
ingestInCache(messagePayload);
|
|
20566
|
-
}
|
|
20567
|
-
fireEvent('message.flagged', payload);
|
|
20568
|
-
return !!payload;
|
|
20569
|
-
};
|
|
20570
|
-
|
|
20163
|
+
/* begin_public_function
|
|
20164
|
+
id: message.flag
|
|
20165
|
+
*/
|
|
20571
20166
|
/**
|
|
20572
|
-
*
|
|
20573
|
-
*
|
|
20574
|
-
*
|
|
20575
|
-
*
|
|
20576
|
-
* - any other non-empty string (including the literal `'Others'`) → `{ reason: 'Others', detail: <string> }`
|
|
20577
|
-
* - `undefined` or `''` → `{ reason: 'Others', detail: '' }`
|
|
20578
|
-
* (for `undefined` the message body carries `detail: undefined`, which JSON serialization omits)
|
|
20167
|
+
* ```js
|
|
20168
|
+
* import { MessageRepository } from '@amityco/ts-sdk'
|
|
20169
|
+
* const flagged = await MessageRepository.flagMessage(messageId, reason)
|
|
20170
|
+
* ```
|
|
20579
20171
|
*
|
|
20580
|
-
*
|
|
20581
|
-
*
|
|
20172
|
+
* @param messageId of the message to flag
|
|
20173
|
+
* @param reason the reason to flag the message
|
|
20174
|
+
* @returns the created report result
|
|
20582
20175
|
*
|
|
20583
|
-
*
|
|
20584
|
-
*
|
|
20585
|
-
*
|
|
20586
|
-
|
|
20587
|
-
const flagMessageWithReasonString = async (messageId, reason) => {
|
|
20176
|
+
* @category Message API
|
|
20177
|
+
* @async
|
|
20178
|
+
* */
|
|
20179
|
+
const flagMessage = async (messageId, reason) => {
|
|
20588
20180
|
const client = getActiveClient();
|
|
20589
20181
|
client.log('message/flag', messageId);
|
|
20590
20182
|
const isPredefinedReason = reason &&
|
|
@@ -20601,42 +20193,6 @@ const flagMessageWithReasonString = async (messageId, reason) => {
|
|
|
20601
20193
|
fireEvent('message.flagged', payload);
|
|
20602
20194
|
return !!payload;
|
|
20603
20195
|
};
|
|
20604
|
-
|
|
20605
|
-
/* begin_public_function
|
|
20606
|
-
id: message.flag
|
|
20607
|
-
*/
|
|
20608
|
-
/**
|
|
20609
|
-
* ```js
|
|
20610
|
-
* import { MessageRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk'
|
|
20611
|
-
*
|
|
20612
|
-
* // No reason.
|
|
20613
|
-
* await MessageRepository.flagMessage(messageId)
|
|
20614
|
-
*
|
|
20615
|
-
* // Category plus optional reporter context (any category, including Others).
|
|
20616
|
-
* await MessageRepository.flagMessage(messageId, {
|
|
20617
|
-
* reason: ContentFlagReasonEnum.SpamOrScams,
|
|
20618
|
-
* detail: 'Repeated promotional links',
|
|
20619
|
-
* })
|
|
20620
|
-
* ```
|
|
20621
|
-
*
|
|
20622
|
-
* Reports a message to moderation. Three call shapes are accepted (see the overloads):
|
|
20623
|
-
* id-only, an options object, and the deprecated legacy reason string. The public
|
|
20624
|
-
* name only dispatches on the input shape; the two implementations are kept separate
|
|
20625
|
-
* so the legacy path is untouched by the new contract:
|
|
20626
|
-
*
|
|
20627
|
-
* - `undefined` or a string → `flagMessageWithReasonString` (unchanged legacy mapping)
|
|
20628
|
-
* - anything else → `flagMessageWithOptions` (validated `{ reason, detail? }`)
|
|
20629
|
-
*
|
|
20630
|
-
* @param messageId The ID of the message to flag
|
|
20631
|
-
* @param input an options object `{ reason, detail? }`, a legacy reason string, or nothing
|
|
20632
|
-
* @returns `true` when the report was created
|
|
20633
|
-
*
|
|
20634
|
-
* @category Message API
|
|
20635
|
-
* @async
|
|
20636
|
-
* */
|
|
20637
|
-
const flagMessage = (messageId, input) => isLegacyContentFlagReason(input)
|
|
20638
|
-
? flagMessageWithReasonString(messageId, input)
|
|
20639
|
-
: flagMessageWithOptions(messageId, input);
|
|
20640
20196
|
/* end_public_function */
|
|
20641
20197
|
|
|
20642
20198
|
/* begin_public_function
|
|
@@ -22356,9 +21912,6 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
22356
21912
|
case 'lastCreated':
|
|
22357
21913
|
channels = channels.sort(sortByLastCreated);
|
|
22358
21914
|
break;
|
|
22359
|
-
case 'lastMessage':
|
|
22360
|
-
channels = channels.sort(sortByLastMessage);
|
|
22361
|
-
break;
|
|
22362
21915
|
case 'displayName':
|
|
22363
21916
|
/*
|
|
22364
21917
|
* The server returns channels with empty | null displayName's first before
|
|
@@ -22419,8 +21972,9 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
22419
21972
|
objectResolverEngine.resolve(message.channelId, "channel" /* Amity.ReferenceType.CHANNEL */);
|
|
22420
21973
|
}
|
|
22421
21974
|
else {
|
|
22422
|
-
|
|
22423
|
-
|
|
21975
|
+
updateChannelCache(channelCache, {
|
|
21976
|
+
lastActivity: message.createdAt,
|
|
21977
|
+
});
|
|
22424
21978
|
callback(message);
|
|
22425
21979
|
}
|
|
22426
21980
|
});
|
|
@@ -22438,7 +21992,9 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
22438
21992
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
22439
21993
|
if (!cacheData)
|
|
22440
21994
|
return;
|
|
22441
|
-
|
|
21995
|
+
updateChannelCache(cacheData, {
|
|
21996
|
+
lastActivity: message.createdAt,
|
|
21997
|
+
});
|
|
22442
21998
|
callback(message);
|
|
22443
21999
|
});
|
|
22444
22000
|
}, 'channelId', 'channel'),
|
|
@@ -23176,7 +22732,9 @@ class SearchChannelLiveCollectionController extends LiveCollectionController {
|
|
|
23176
22732
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
23177
22733
|
if (!cacheData)
|
|
23178
22734
|
return;
|
|
23179
|
-
|
|
22735
|
+
updateChannelCache(cacheData, {
|
|
22736
|
+
lastActivity: message.createdAt,
|
|
22737
|
+
});
|
|
23180
22738
|
callback(message);
|
|
23181
22739
|
});
|
|
23182
22740
|
}, 'channelId', 'channel'),
|
|
@@ -23193,7 +22751,9 @@ class SearchChannelLiveCollectionController extends LiveCollectionController {
|
|
|
23193
22751
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
23194
22752
|
if (!cacheData)
|
|
23195
22753
|
return;
|
|
23196
|
-
|
|
22754
|
+
updateChannelCache(cacheData, {
|
|
22755
|
+
lastActivity: message.createdAt,
|
|
22756
|
+
});
|
|
23197
22757
|
callback(message);
|
|
23198
22758
|
});
|
|
23199
22759
|
}, 'channelId', 'channel'),
|
|
@@ -27778,22 +27338,23 @@ const declineComment = async (commentId, reason) => {
|
|
|
27778
27338
|
};
|
|
27779
27339
|
/* end_public_function */
|
|
27780
27340
|
|
|
27341
|
+
/* begin_public_function
|
|
27342
|
+
id: comment.flag
|
|
27343
|
+
*/
|
|
27781
27344
|
/**
|
|
27782
|
-
*
|
|
27783
|
-
*
|
|
27784
|
-
*
|
|
27785
|
-
*
|
|
27786
|
-
* - any other non-empty string (including the literal `'Others'`) → `{ reason: 'Others', detail: <string> }`
|
|
27787
|
-
* - `undefined` or `''` → `{ reason: 'Others', detail: '' }`
|
|
27345
|
+
* ```js
|
|
27346
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
27347
|
+
* const flagged = await CommentRepository.flagComment(commentId, reason)
|
|
27348
|
+
* ```
|
|
27788
27349
|
*
|
|
27789
|
-
*
|
|
27790
|
-
*
|
|
27350
|
+
* @param commentId The ID of the comment to flag
|
|
27351
|
+
* @param reason the reason to flag the comment
|
|
27352
|
+
* @returns the created report result
|
|
27791
27353
|
*
|
|
27792
|
-
*
|
|
27793
|
-
*
|
|
27794
|
-
*
|
|
27795
|
-
|
|
27796
|
-
const flagCommentWithReasonString = async (commentId, reason) => {
|
|
27354
|
+
* @category Comment API
|
|
27355
|
+
* @async
|
|
27356
|
+
* */
|
|
27357
|
+
const flagComment = async (commentId, reason) => {
|
|
27797
27358
|
const client = getActiveClient();
|
|
27798
27359
|
client.log('comment/flagComment', commentId);
|
|
27799
27360
|
const isPredefinedReason = reason &&
|
|
@@ -27809,67 +27370,6 @@ const flagCommentWithReasonString = async (commentId, reason) => {
|
|
|
27809
27370
|
fireEvent('comment.flagged', payload);
|
|
27810
27371
|
return !!payload;
|
|
27811
27372
|
};
|
|
27812
|
-
|
|
27813
|
-
/**
|
|
27814
|
-
* New `flagComment(commentId, { reason, detail? })` implementation. Any category,
|
|
27815
|
-
* including `Others`, may carry a `detail`. `detail` is forwarded unchanged (empty and
|
|
27816
|
-
* whitespace-only strings included) and omitted from the request body when `undefined`;
|
|
27817
|
-
* the backend enforces the 300-character limit.
|
|
27818
|
-
*
|
|
27819
|
-
* Not exported from the public API. It is reached through the
|
|
27820
|
-
* `CommentRepository.flagComment(commentId, options)` overload; see `api/flagComment.ts`.
|
|
27821
|
-
*
|
|
27822
|
-
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
|
|
27823
|
-
*/
|
|
27824
|
-
const flagCommentWithOptions = async (commentId, options) => {
|
|
27825
|
-
// Validate first: an input error must surface as INVALID_PARAMETERS regardless of
|
|
27826
|
-
// whether a client is active, and validation needs nothing from the client.
|
|
27827
|
-
const body = toContentFlagBody(validateContentFlagOptions('flagComment', options));
|
|
27828
|
-
const client = getActiveClient();
|
|
27829
|
-
client.log('comment/flagComment', commentId);
|
|
27830
|
-
const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
|
|
27831
|
-
if (client.cache) {
|
|
27832
|
-
ingestInCache(payload);
|
|
27833
|
-
}
|
|
27834
|
-
fireEvent('comment.flagged', payload);
|
|
27835
|
-
return !!payload;
|
|
27836
|
-
};
|
|
27837
|
-
|
|
27838
|
-
/* begin_public_function
|
|
27839
|
-
id: comment.flag
|
|
27840
|
-
*/
|
|
27841
|
-
/**
|
|
27842
|
-
* ```js
|
|
27843
|
-
* import { CommentRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk'
|
|
27844
|
-
*
|
|
27845
|
-
* // No reason: sent as Others with an empty detail.
|
|
27846
|
-
* await CommentRepository.flagComment(commentId)
|
|
27847
|
-
*
|
|
27848
|
-
* // Category plus optional reporter context (any category, including Others).
|
|
27849
|
-
* await CommentRepository.flagComment(commentId, {
|
|
27850
|
-
* reason: ContentFlagReasonEnum.SpamOrScams,
|
|
27851
|
-
* detail: 'Repeated promotional links',
|
|
27852
|
-
* })
|
|
27853
|
-
* ```
|
|
27854
|
-
*
|
|
27855
|
-
* Reports a comment to moderation. Three call shapes are accepted (see the overloads):
|
|
27856
|
-
* id-only, an options object, and the deprecated legacy reason string. The public
|
|
27857
|
-
* name only dispatches on the input shape; the two implementations are kept separate
|
|
27858
|
-
* so the legacy path is untouched by the new contract:
|
|
27859
|
-
*
|
|
27860
|
-
* - `undefined` or a string → `flagCommentWithReasonString` (unchanged legacy mapping)
|
|
27861
|
-
* - anything else → `flagCommentWithOptions` (validated `{ reason, detail? }`)
|
|
27862
|
-
*
|
|
27863
|
-
* @param commentId The ID of the comment to flag
|
|
27864
|
-
* @param input an options object `{ reason, detail? }`, a legacy reason string, or nothing
|
|
27865
|
-
* @returns `true` when the report was created
|
|
27866
|
-
*
|
|
27867
|
-
* @category Comment API
|
|
27868
|
-
* @async
|
|
27869
|
-
* */
|
|
27870
|
-
const flagComment = (commentId, input) => isLegacyContentFlagReason(input)
|
|
27871
|
-
? flagCommentWithReasonString(commentId, input)
|
|
27872
|
-
: flagCommentWithOptions(commentId, input);
|
|
27873
27373
|
/* end_public_function */
|
|
27874
27374
|
|
|
27875
27375
|
/* begin_public_function
|
|
@@ -30223,47 +29723,23 @@ const declinePost = async (postId) => {
|
|
|
30223
29723
|
};
|
|
30224
29724
|
/* end_public_function */
|
|
30225
29725
|
|
|
29726
|
+
/* begin_public_function
|
|
29727
|
+
id: post.flag
|
|
29728
|
+
*/
|
|
30226
29729
|
/**
|
|
30227
|
-
*
|
|
30228
|
-
*
|
|
30229
|
-
*
|
|
30230
|
-
*
|
|
30231
|
-
*
|
|
30232
|
-
* Not exported from the public API. It is reached through the
|
|
30233
|
-
* `PostRepository.flagPost(postId, options)` overload; see `api/flagPost.ts`.
|
|
30234
|
-
*
|
|
30235
|
-
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
|
|
30236
|
-
*/
|
|
30237
|
-
const flagPostWithOptions = async (postId, options) => {
|
|
30238
|
-
// Validate first: an input error must surface as INVALID_PARAMETERS regardless of
|
|
30239
|
-
// whether a client is active, and validation needs nothing from the client.
|
|
30240
|
-
const body = toContentFlagBody(validateContentFlagOptions('flagPost', options));
|
|
30241
|
-
const client = getActiveClient();
|
|
30242
|
-
client.log('post/flagPost', postId);
|
|
30243
|
-
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
|
|
30244
|
-
if (client.cache) {
|
|
30245
|
-
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
30246
|
-
}
|
|
30247
|
-
fireEvent('post.flagged', payload);
|
|
30248
|
-
return !!payload;
|
|
30249
|
-
};
|
|
30250
|
-
|
|
30251
|
-
/**
|
|
30252
|
-
* Legacy `flagPost(postId, reason?)` implementation, kept verbatim so existing
|
|
30253
|
-
* callers keep the exact request body they had before the options contract existed:
|
|
30254
|
-
*
|
|
30255
|
-
* - predefined `ContentFlagReasonEnum` value → `{ reason: <value>, detail: '' }`
|
|
30256
|
-
* - any other non-empty string (including the literal `'Others'`) → `{ reason: 'Others', detail: <string> }`
|
|
30257
|
-
* - `undefined` or `''` → `{ reason: 'Others', detail: '' }`
|
|
29730
|
+
* ```js
|
|
29731
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
29732
|
+
* const flagged = await PostRepository.flagPost(postId, reason)
|
|
29733
|
+
* ```
|
|
30258
29734
|
*
|
|
30259
|
-
*
|
|
30260
|
-
*
|
|
29735
|
+
* @param postId of the post to flag
|
|
29736
|
+
* @param reason the reason to flag the post
|
|
29737
|
+
* @returns a boolean
|
|
30261
29738
|
*
|
|
30262
|
-
*
|
|
30263
|
-
*
|
|
30264
|
-
*
|
|
30265
|
-
|
|
30266
|
-
const flagPostWithReasonString = async (postId, reason) => {
|
|
29739
|
+
* @category Post API
|
|
29740
|
+
* @async
|
|
29741
|
+
* */
|
|
29742
|
+
const flagPost = async (postId, reason) => {
|
|
30267
29743
|
const client = getActiveClient();
|
|
30268
29744
|
client.log('post/flagPost', postId);
|
|
30269
29745
|
const isPredefinedReason = reason &&
|
|
@@ -30279,42 +29755,6 @@ const flagPostWithReasonString = async (postId, reason) => {
|
|
|
30279
29755
|
fireEvent('post.flagged', payload);
|
|
30280
29756
|
return !!payload;
|
|
30281
29757
|
};
|
|
30282
|
-
|
|
30283
|
-
/* begin_public_function
|
|
30284
|
-
id: post.flag
|
|
30285
|
-
*/
|
|
30286
|
-
/**
|
|
30287
|
-
* ```js
|
|
30288
|
-
* import { PostRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk'
|
|
30289
|
-
*
|
|
30290
|
-
* // No reason.
|
|
30291
|
-
* await PostRepository.flagPost(postId)
|
|
30292
|
-
*
|
|
30293
|
-
* // Category plus optional reporter context (any category, including Others).
|
|
30294
|
-
* await PostRepository.flagPost(postId, {
|
|
30295
|
-
* reason: ContentFlagReasonEnum.SpamOrScams,
|
|
30296
|
-
* detail: 'Repeated promotional links',
|
|
30297
|
-
* })
|
|
30298
|
-
* ```
|
|
30299
|
-
*
|
|
30300
|
-
* Reports a post to moderation. Three call shapes are accepted (see the overloads):
|
|
30301
|
-
* id-only, an options object, and the deprecated legacy reason string. The public
|
|
30302
|
-
* name only dispatches on the input shape; the two implementations are kept separate
|
|
30303
|
-
* so the legacy path is untouched by the new contract:
|
|
30304
|
-
*
|
|
30305
|
-
* - `undefined` or a string → `flagPostWithReasonString` (unchanged legacy mapping)
|
|
30306
|
-
* - anything else → `flagPostWithOptions` (validated `{ reason, detail? }`)
|
|
30307
|
-
*
|
|
30308
|
-
* @param postId The ID of the post to flag
|
|
30309
|
-
* @param input an options object `{ reason, detail? }`, a legacy reason string, or nothing
|
|
30310
|
-
* @returns `true` when the report was created
|
|
30311
|
-
*
|
|
30312
|
-
* @category Post API
|
|
30313
|
-
* @async
|
|
30314
|
-
* */
|
|
30315
|
-
const flagPost = (postId, input) => isLegacyContentFlagReason(input)
|
|
30316
|
-
? flagPostWithReasonString(postId, input)
|
|
30317
|
-
: flagPostWithOptions(postId, input);
|
|
30318
29758
|
/* end_public_function */
|
|
30319
29759
|
|
|
30320
29760
|
/* begin_public_function
|
|
@@ -37816,7 +37256,6 @@ exports.sortByFirstCreated = sortByFirstCreated;
|
|
|
37816
37256
|
exports.sortByFirstUpdated = sortByFirstUpdated;
|
|
37817
37257
|
exports.sortByLastActivity = sortByLastActivity;
|
|
37818
37258
|
exports.sortByLastCreated = sortByLastCreated;
|
|
37819
|
-
exports.sortByLastMessage = sortByLastMessage;
|
|
37820
37259
|
exports.sortByLastUpdated = sortByLastUpdated;
|
|
37821
37260
|
exports.sortByLocalSortingDate = sortByLocalSortingDate;
|
|
37822
37261
|
exports.sortByName = sortByName;
|