@amityco/ts-sdk 7.19.0 → 7.19.1-0e4fcc82.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/events.d.ts +2 -0
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +2 -0
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +7 -0
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +20 -0
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/client.d.ts +1 -0
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/message.d.ts +16 -0
- package/dist/@types/domains/message.d.ts.map +1 -1
- package/dist/@types/domains/notificationSettings.d.ts +101 -0
- package/dist/@types/domains/notificationSettings.d.ts.map +1 -0
- package/dist/@types/index.d.ts +2 -1
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/channelRepository/api/archiveChannel.d.ts +16 -0
- package/dist/channelRepository/api/archiveChannel.d.ts.map +1 -0
- package/dist/channelRepository/api/getArchivedChannelIds.d.ts +13 -0
- package/dist/channelRepository/api/getArchivedChannelIds.d.ts.map +1 -0
- package/dist/channelRepository/api/index.d.ts +3 -0
- package/dist/channelRepository/api/index.d.ts.map +1 -1
- package/dist/channelRepository/api/unarchiveChannel.d.ts +16 -0
- package/dist/channelRepository/api/unarchiveChannel.d.ts.map +1 -0
- package/dist/channelRepository/api/updateChannel.d.ts +1 -1
- package/dist/channelRepository/api/updateChannel.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/getMembers/ChannelMemberQueryStreamController.d.ts.map +1 -1
- package/dist/channelRepository/channelModeration/api/banMembers.d.ts.map +1 -1
- package/dist/channelRepository/channelModeration/api/muteMembers.d.ts.map +1 -1
- package/dist/channelRepository/channelModeration/api/unbanMembers.d.ts.map +1 -1
- package/dist/channelRepository/channelModeration/api/unmuteMembers.d.ts.map +1 -1
- package/dist/channelRepository/events/index.d.ts +2 -0
- package/dist/channelRepository/events/index.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelArchived.d.ts +10 -0
- package/dist/channelRepository/events/onChannelArchived.d.ts.map +1 -0
- package/dist/channelRepository/events/onChannelMemberRoleRemoved.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelUnarchived.d.ts +11 -0
- package/dist/channelRepository/events/onChannelUnarchived.d.ts.map +1 -0
- package/dist/channelRepository/observers/getArchivedChannels/ArchivedChannelLiveCollectionController.d.ts +12 -0
- package/dist/channelRepository/observers/getArchivedChannels/ArchivedChannelLiveCollectionController.d.ts.map +1 -0
- package/dist/channelRepository/observers/getArchivedChannels/ArchivedChannelPaginationController.d.ts +11 -0
- package/dist/channelRepository/observers/getArchivedChannels/ArchivedChannelPaginationController.d.ts.map +1 -0
- package/dist/channelRepository/observers/getArchivedChannels/ArchivedChannelQueryStreamController.d.ts +13 -0
- package/dist/channelRepository/observers/getArchivedChannels/ArchivedChannelQueryStreamController.d.ts.map +1 -0
- package/dist/channelRepository/observers/getArchivedChannels/getArchivedChannels.d.ts +20 -0
- package/dist/channelRepository/observers/getArchivedChannels/getArchivedChannels.d.ts.map +1 -0
- package/dist/channelRepository/observers/getArchivedChannels/index.d.ts +2 -0
- package/dist/channelRepository/observers/getArchivedChannels/index.d.ts.map +1 -0
- package/dist/channelRepository/observers/getChannels/ChannelLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/observers/getChannels/ChannelQueryStreamController.d.ts.map +1 -1
- package/dist/channelRepository/observers/index.d.ts +1 -0
- package/dist/channelRepository/observers/index.d.ts.map +1 -1
- package/dist/channelRepository/utils/prepareChannelPayload.d.ts.map +1 -1
- package/dist/client/api/index.d.ts +2 -0
- package/dist/client/api/index.d.ts.map +1 -1
- package/dist/client/api/notifications.d.ts +27 -0
- package/dist/client/api/notifications.d.ts.map +1 -0
- package/dist/client/api/tests/notifications.integration.test.d.ts +2 -0
- package/dist/client/api/tests/notifications.integration.test.d.ts.map +1 -0
- package/dist/client/services/ReadReceiptSync/readReceiptSyncEngine.d.ts.map +1 -1
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/index.cjs.js +769 -20
- package/dist/index.esm.js +770 -21
- package/dist/index.umd.js +3 -3
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +1 -0
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts.map +1 -1
- package/dist/messageRepository/events/onMessageCreated.d.ts.map +1 -1
- package/dist/messageRepository/observers/index.d.ts +1 -0
- package/dist/messageRepository/observers/index.d.ts.map +1 -1
- package/dist/messageRepository/observers/searchMessage/SearchMessageLiveCollectionController.d.ts +12 -0
- package/dist/messageRepository/observers/searchMessage/SearchMessageLiveCollectionController.d.ts.map +1 -0
- package/dist/messageRepository/observers/searchMessage/SearchMessagePaginationController.d.ts +10 -0
- package/dist/messageRepository/observers/searchMessage/SearchMessagePaginationController.d.ts.map +1 -0
- package/dist/messageRepository/observers/searchMessage/SearchMessageQueryStreamController.d.ts +8 -0
- package/dist/messageRepository/observers/searchMessage/SearchMessageQueryStreamController.d.ts.map +1 -0
- package/dist/messageRepository/observers/searchMessage/index.d.ts +2 -0
- package/dist/messageRepository/observers/searchMessage/index.d.ts.map +1 -0
- package/dist/messageRepository/observers/searchMessage/searchMessage.d.ts +24 -0
- package/dist/messageRepository/observers/searchMessage/searchMessage.d.ts.map +1 -0
- package/dist/reactionRepository/internalApi/addReaction.d.ts.map +1 -1
- package/dist/reactionRepository/internalApi/removeReaction.d.ts.map +1 -1
- package/dist/utils/linkedObject/channelLinkedObject.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -59,6 +59,13 @@ var FileAccessTypeEnum;
|
|
|
59
59
|
FileAccessTypeEnum["NETWORK"] = "network";
|
|
60
60
|
})(FileAccessTypeEnum || (FileAccessTypeEnum = {}));
|
|
61
61
|
|
|
62
|
+
var AmityChannelNotificationModeEnum;
|
|
63
|
+
(function (AmityChannelNotificationModeEnum) {
|
|
64
|
+
AmityChannelNotificationModeEnum["Default"] = "default";
|
|
65
|
+
AmityChannelNotificationModeEnum["Silent"] = "silent";
|
|
66
|
+
AmityChannelNotificationModeEnum["Subscribe"] = "subscribe";
|
|
67
|
+
})(AmityChannelNotificationModeEnum || (AmityChannelNotificationModeEnum = {}));
|
|
68
|
+
|
|
62
69
|
const CommunityPostSettings = Object.freeze({
|
|
63
70
|
ONLY_ADMIN_CAN_POST: 'ONLY_ADMIN_CAN_POST',
|
|
64
71
|
ADMIN_REVIEW_POST_REQUIRED: 'ADMIN_REVIEW_POST_REQUIRED',
|
|
@@ -240,6 +247,39 @@ var AnalyticsSourceTypeEnum;
|
|
|
240
247
|
AnalyticsSourceTypeEnum["ROOM"] = "room";
|
|
241
248
|
})(AnalyticsSourceTypeEnum || (AnalyticsSourceTypeEnum = {}));
|
|
242
249
|
|
|
250
|
+
var UserNotificationModuleNameEnum;
|
|
251
|
+
(function (UserNotificationModuleNameEnum) {
|
|
252
|
+
UserNotificationModuleNameEnum["CHAT"] = "chat";
|
|
253
|
+
UserNotificationModuleNameEnum["SOCIAL"] = "social";
|
|
254
|
+
UserNotificationModuleNameEnum["VIDEO_STREAMING"] = "video-streaming";
|
|
255
|
+
})(UserNotificationModuleNameEnum || (UserNotificationModuleNameEnum = {}));
|
|
256
|
+
var CommunityNotificationEventNameEnum;
|
|
257
|
+
(function (CommunityNotificationEventNameEnum) {
|
|
258
|
+
CommunityNotificationEventNameEnum["POST_CREATED"] = "post.created";
|
|
259
|
+
CommunityNotificationEventNameEnum["POST_REACTED"] = "post.reacted";
|
|
260
|
+
CommunityNotificationEventNameEnum["COMMENT_CREATED"] = "comment.created";
|
|
261
|
+
CommunityNotificationEventNameEnum["COMMENT_REPLIED"] = "comment.replied";
|
|
262
|
+
CommunityNotificationEventNameEnum["COMMENT_REACTED"] = "comment.reacted";
|
|
263
|
+
CommunityNotificationEventNameEnum["STORY_CREATED"] = "story.created";
|
|
264
|
+
CommunityNotificationEventNameEnum["STORY_REACTED"] = "story.reacted";
|
|
265
|
+
CommunityNotificationEventNameEnum["STORY_COMMENT_CREATED"] = "story-comment.created";
|
|
266
|
+
CommunityNotificationEventNameEnum["LIVESTREAM_START"] = "video-streaming.didStart";
|
|
267
|
+
})(CommunityNotificationEventNameEnum || (CommunityNotificationEventNameEnum = {}));
|
|
268
|
+
var NotificationSettingsLevelEnum;
|
|
269
|
+
(function (NotificationSettingsLevelEnum) {
|
|
270
|
+
NotificationSettingsLevelEnum["USER"] = "user";
|
|
271
|
+
NotificationSettingsLevelEnum["COMMUNITY"] = "community";
|
|
272
|
+
NotificationSettingsLevelEnum["CHANNEL"] = "channel";
|
|
273
|
+
})(NotificationSettingsLevelEnum || (NotificationSettingsLevelEnum = {}));
|
|
274
|
+
/**
|
|
275
|
+
* `NOT` variant is intentionally excluded from public API (internal server-side use only).
|
|
276
|
+
*/
|
|
277
|
+
var NotificationRolesFilterTypeEnum;
|
|
278
|
+
(function (NotificationRolesFilterTypeEnum) {
|
|
279
|
+
NotificationRolesFilterTypeEnum["ALL"] = "all";
|
|
280
|
+
NotificationRolesFilterTypeEnum["ONLY"] = "only";
|
|
281
|
+
})(NotificationRolesFilterTypeEnum || (NotificationRolesFilterTypeEnum = {}));
|
|
282
|
+
|
|
243
283
|
function getVersion() {
|
|
244
284
|
try {
|
|
245
285
|
// the string ''v7.19.0-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
@@ -652,6 +692,7 @@ const idResolvers = {
|
|
|
652
692
|
channel: ({ channelInternalId }) => channelInternalId,
|
|
653
693
|
subChannel: ({ subChannelId }) => subChannelId,
|
|
654
694
|
channelUsers: ({ channelId, userId }) => `${channelId}#${userId}`,
|
|
695
|
+
archivedChannel: ({ channelId }) => channelId,
|
|
655
696
|
message: ({ messageId, referenceId }) => referenceId !== null && referenceId !== void 0 ? referenceId : messageId,
|
|
656
697
|
messagePreviewChannel: ({ channelId }) => `${channelId}`,
|
|
657
698
|
messagePreviewSubChannel: ({ subChannelId }) => `${subChannelId}`,
|
|
@@ -715,6 +756,7 @@ const PAYLOAD2MODEL = {
|
|
|
715
756
|
channels: 'channel',
|
|
716
757
|
messageFeeds: 'subChannel',
|
|
717
758
|
channelUsers: 'channelUsers',
|
|
759
|
+
archives: 'archivedChannel',
|
|
718
760
|
messages: 'message',
|
|
719
761
|
messagePreviewChannel: 'messagePreviewChannel',
|
|
720
762
|
messagePreviewSubChannel: 'messagePreviewSubChannel',
|
|
@@ -22044,24 +22086,43 @@ const preUpdateChannelCache = (rawPayload, options = { isMessagePreviewUpdated:
|
|
|
22044
22086
|
});
|
|
22045
22087
|
};
|
|
22046
22088
|
const updateChannelUnread = ({ currentUserId, channels, channelUsers, }) => {
|
|
22089
|
+
var _a, _b;
|
|
22047
22090
|
const channelsUnread = [];
|
|
22048
22091
|
for (let i = 0; i < channels.length; i += 1) {
|
|
22049
22092
|
if (isUnreadCountSupport(channels[i])) {
|
|
22050
22093
|
const cacheKey = ['channelUnread', 'get', channels[i].channelId];
|
|
22051
22094
|
const channelUser = channelUsers.find(channelUser => channelUser.channelId === channels[i].channelId && channelUser.userId === currentUserId);
|
|
22052
|
-
|
|
22095
|
+
// readToSegment, lastMentionedSegment and lastSegment are monotonically non-decreasing;
|
|
22096
|
+
// prefer cached values when ahead of the server so a refetch returning stale data cannot
|
|
22097
|
+
// revert updates already written by MessageReadReceiptSyncEngine.markRead (readToSegment)
|
|
22098
|
+
// or onMessageCreatedMqtt (lastSegment).
|
|
22099
|
+
const cached = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22100
|
+
const lastSegment = Math.max((_b = cached === null || cached === void 0 ? void 0 : cached.lastSegment) !== null && _b !== void 0 ? _b : 0, channels[i].messageCount);
|
|
22053
22101
|
let readToSegment = null;
|
|
22054
22102
|
let lastMentionedSegment = null;
|
|
22103
|
+
let unreadCount = 0;
|
|
22055
22104
|
let isMentioned = false;
|
|
22056
22105
|
if (channelUser) {
|
|
22057
|
-
|
|
22058
|
-
|
|
22059
|
-
|
|
22060
|
-
|
|
22106
|
+
const serverRead = channelUser.readToSegment;
|
|
22107
|
+
const serverMention = channelUser.lastMentionedSegment;
|
|
22108
|
+
readToSegment =
|
|
22109
|
+
typeof (cached === null || cached === void 0 ? void 0 : cached.readToSegment) === 'number' &&
|
|
22110
|
+
(typeof serverRead !== 'number' || cached.readToSegment > serverRead)
|
|
22111
|
+
? cached.readToSegment
|
|
22112
|
+
: serverRead !== null && serverRead !== void 0 ? serverRead : null;
|
|
22113
|
+
lastMentionedSegment =
|
|
22114
|
+
typeof (cached === null || cached === void 0 ? void 0 : cached.lastMentionedSegment) === 'number' &&
|
|
22115
|
+
(typeof serverMention !== 'number' || cached.lastMentionedSegment > serverMention)
|
|
22116
|
+
? cached.lastMentionedSegment
|
|
22117
|
+
: serverMention !== null && serverMention !== void 0 ? serverMention : null;
|
|
22118
|
+
const readForCalc = readToSegment !== null && readToSegment !== void 0 ? readToSegment : 0;
|
|
22119
|
+
unreadCount = Math.max(lastSegment - readForCalc, 0);
|
|
22120
|
+
isMentioned =
|
|
22121
|
+
typeof lastMentionedSegment === 'number' && readForCalc < lastMentionedSegment;
|
|
22061
22122
|
}
|
|
22062
22123
|
const cacheChannelUnread = {
|
|
22063
22124
|
channelId: channels[i].channelId,
|
|
22064
|
-
lastSegment
|
|
22125
|
+
lastSegment,
|
|
22065
22126
|
readToSegment,
|
|
22066
22127
|
lastMentionedSegment,
|
|
22067
22128
|
unreadCount,
|
|
@@ -22071,6 +22132,8 @@ const updateChannelUnread = ({ currentUserId, channels, channelUsers, }) => {
|
|
|
22071
22132
|
pushToCache(cacheKey, cacheChannelUnread);
|
|
22072
22133
|
channelsUnread.push(cacheChannelUnread);
|
|
22073
22134
|
}
|
|
22135
|
+
}
|
|
22136
|
+
if (channelsUnread.length > 0) {
|
|
22074
22137
|
fireEvent('local.channelUnread.updated', channelsUnread);
|
|
22075
22138
|
}
|
|
22076
22139
|
};
|
|
@@ -22770,7 +22833,7 @@ const onChannelMemberRoleRemoved = (callback) => {
|
|
|
22770
22833
|
const client = getActiveClient();
|
|
22771
22834
|
const filter = async (payload) => {
|
|
22772
22835
|
const { channels, channelUsers } = payload;
|
|
22773
|
-
|
|
22836
|
+
callbacks$1.forEach(cb => cb(channels[0], channelUsers.find(channelUser => channelUser.membership === 'member')));
|
|
22774
22837
|
};
|
|
22775
22838
|
mainDisposer$1 = createEventSubscriber(client, 'onChannelMemberRoleRemoved', 'local.channel-moderator.role-removed', filter);
|
|
22776
22839
|
}
|
|
@@ -22778,6 +22841,39 @@ const onChannelMemberRoleRemoved = (callback) => {
|
|
|
22778
22841
|
return () => dispose$1(callback);
|
|
22779
22842
|
};
|
|
22780
22843
|
|
|
22844
|
+
/**
|
|
22845
|
+
* Fired when a {@link Amity.Channel} has been archived by the active user.
|
|
22846
|
+
*
|
|
22847
|
+
* @param callback The function to call when the event was fired
|
|
22848
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
22849
|
+
*
|
|
22850
|
+
* @category Channel Events
|
|
22851
|
+
*/
|
|
22852
|
+
const onChannelArchived = (callback) => {
|
|
22853
|
+
const client = getActiveClient();
|
|
22854
|
+
const filter = async (payload) => {
|
|
22855
|
+
callback(payload);
|
|
22856
|
+
};
|
|
22857
|
+
return createEventSubscriber(client, 'onChannelArchived', 'local.channel.archived', filter);
|
|
22858
|
+
};
|
|
22859
|
+
|
|
22860
|
+
/**
|
|
22861
|
+
* Fired when a previously archived {@link Amity.Channel} has been unarchived
|
|
22862
|
+
* by the active user.
|
|
22863
|
+
*
|
|
22864
|
+
* @param callback The function to call when the event was fired
|
|
22865
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
22866
|
+
*
|
|
22867
|
+
* @category Channel Events
|
|
22868
|
+
*/
|
|
22869
|
+
const onChannelUnarchived = (callback) => {
|
|
22870
|
+
const client = getActiveClient();
|
|
22871
|
+
const filter = async (payload) => {
|
|
22872
|
+
callback(payload);
|
|
22873
|
+
};
|
|
22874
|
+
return createEventSubscriber(client, 'onChannelUnarchived', 'local.channel.unarchived', filter);
|
|
22875
|
+
};
|
|
22876
|
+
|
|
22781
22877
|
const callbacks = [];
|
|
22782
22878
|
let mainDisposer = null;
|
|
22783
22879
|
const dispose = (cb) => {
|
|
@@ -22891,6 +22987,17 @@ const channelLinkedObject = (channel) => {
|
|
|
22891
22987
|
markAsRead: () => markAsRead(channel.channelInternalId),
|
|
22892
22988
|
previewMembers,
|
|
22893
22989
|
myMembership: (callback) => getMyMembership(channel.channelId, callback),
|
|
22990
|
+
get avatar() {
|
|
22991
|
+
var _a;
|
|
22992
|
+
if (!channel.avatarFileId)
|
|
22993
|
+
return undefined;
|
|
22994
|
+
const avatar = (_a = pullFromCache([
|
|
22995
|
+
'file',
|
|
22996
|
+
'get',
|
|
22997
|
+
`${channel.avatarFileId}`,
|
|
22998
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
22999
|
+
return avatar;
|
|
23000
|
+
},
|
|
22894
23001
|
});
|
|
22895
23002
|
};
|
|
22896
23003
|
|
|
@@ -24253,9 +24360,8 @@ class MessageReadReceiptSyncEngine {
|
|
|
24253
24360
|
// Step 1: Optimistic update of channelUnread.readToSegment to message.segment and update unreadCount value
|
|
24254
24361
|
const cacheKey = ['channelUnread', 'get', channelId];
|
|
24255
24362
|
const channelUnread = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24256
|
-
if (
|
|
24257
|
-
channelUnread
|
|
24258
|
-
segment > channelUnread.readToSegment) {
|
|
24363
|
+
if (channelUnread &&
|
|
24364
|
+
(typeof channelUnread.readToSegment !== 'number' || segment > channelUnread.readToSegment)) {
|
|
24259
24365
|
channelUnread.readToSegment = segment;
|
|
24260
24366
|
channelUnread.unreadCount = Math.max(channelUnread.lastSegment - segment, 0);
|
|
24261
24367
|
pushToCache(cacheKey, channelUnread);
|
|
@@ -26013,16 +26119,13 @@ const onMessageCreatedMqtt = (callback) => {
|
|
|
26013
26119
|
}
|
|
26014
26120
|
if (client.useLegacyUnreadCount) {
|
|
26015
26121
|
rawPayload.messages.forEach(message => {
|
|
26016
|
-
var _a, _b;
|
|
26122
|
+
var _a, _b, _c;
|
|
26017
26123
|
const channelUnread = (_a = pullFromCache([
|
|
26018
26124
|
'channelUnread',
|
|
26019
26125
|
'get',
|
|
26020
26126
|
message.channelId,
|
|
26021
26127
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
26022
|
-
if (!channelUnread ||
|
|
26023
|
-
channelUnread.lastSegment >= message.segment ||
|
|
26024
|
-
typeof channelUnread.readToSegment !== 'number' ||
|
|
26025
|
-
typeof channelUnread.lastMentionedSegment !== 'number')
|
|
26128
|
+
if (!channelUnread || channelUnread.lastSegment >= message.segment)
|
|
26026
26129
|
return;
|
|
26027
26130
|
const lastSegment = message.segment;
|
|
26028
26131
|
const isMentionedInMessage = (_b = message.mentionedUsers) === null || _b === void 0 ? void 0 : _b.some(mention => {
|
|
@@ -26034,7 +26137,8 @@ const onMessageCreatedMqtt = (callback) => {
|
|
|
26034
26137
|
const lastMentionedSegment = isMentionedInMessage
|
|
26035
26138
|
? message.segment
|
|
26036
26139
|
: channelUnread.lastMentionedSegment;
|
|
26037
|
-
const
|
|
26140
|
+
const readToSegment = (_c = channelUnread.readToSegment) !== null && _c !== void 0 ? _c : 0;
|
|
26141
|
+
const updatedChannelUnread = Object.assign(Object.assign({}, channelUnread), { lastSegment, unreadCount: Math.max(lastSegment - readToSegment, 0), lastMentionedSegment, isMentioned: typeof lastMentionedSegment === 'number' && readToSegment < lastMentionedSegment });
|
|
26038
26142
|
pushToCache(['channelUnread', 'get', message.channelId], updatedChannelUnread);
|
|
26039
26143
|
fireEvent('local.channelUnread.updated', [updatedChannelUnread]);
|
|
26040
26144
|
});
|
|
@@ -26880,6 +26984,140 @@ const setAccessTokenHandler = (accessTokenHandler) => {
|
|
|
26880
26984
|
client.accessTokenHandler = accessTokenHandler;
|
|
26881
26985
|
};
|
|
26882
26986
|
|
|
26987
|
+
function parseRolesFilter(listenFromRoleIds, ignoreFromRoleIds) {
|
|
26988
|
+
if (ignoreFromRoleIds && ignoreFromRoleIds.length > 0) {
|
|
26989
|
+
return { type: 'not', roleIds: ignoreFromRoleIds };
|
|
26990
|
+
}
|
|
26991
|
+
if (listenFromRoleIds && listenFromRoleIds.length > 0) {
|
|
26992
|
+
return { type: NotificationRolesFilterTypeEnum.ONLY, roleIds: listenFromRoleIds };
|
|
26993
|
+
}
|
|
26994
|
+
return { type: NotificationRolesFilterTypeEnum.ALL };
|
|
26995
|
+
}
|
|
26996
|
+
function serializeRolesFilter(rolesFilter) {
|
|
26997
|
+
if ((rolesFilter === null || rolesFilter === void 0 ? void 0 : rolesFilter.type) === NotificationRolesFilterTypeEnum.ONLY) {
|
|
26998
|
+
return { listenFromRoleIds: rolesFilter.roleIds };
|
|
26999
|
+
}
|
|
27000
|
+
return { listenFromRoleIds: [] };
|
|
27001
|
+
}
|
|
27002
|
+
class ChannelNotifications {
|
|
27003
|
+
constructor(channelId) {
|
|
27004
|
+
this.channelId = channelId;
|
|
27005
|
+
}
|
|
27006
|
+
async enable() {
|
|
27007
|
+
const client = getActiveClient();
|
|
27008
|
+
const body = {
|
|
27009
|
+
level: NotificationSettingsLevelEnum.CHANNEL,
|
|
27010
|
+
channelId: this.channelId,
|
|
27011
|
+
isPushNotifiable: true,
|
|
27012
|
+
};
|
|
27013
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
27014
|
+
}
|
|
27015
|
+
async disable() {
|
|
27016
|
+
const client = getActiveClient();
|
|
27017
|
+
const body = {
|
|
27018
|
+
level: NotificationSettingsLevelEnum.CHANNEL,
|
|
27019
|
+
channelId: this.channelId,
|
|
27020
|
+
isPushNotifiable: false,
|
|
27021
|
+
};
|
|
27022
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
27023
|
+
}
|
|
27024
|
+
async getSettings() {
|
|
27025
|
+
const client = getActiveClient();
|
|
27026
|
+
const { data } = await client.http.get(`/api/v3/notification/setting?level=${NotificationSettingsLevelEnum.CHANNEL}&channelId=${encodeURIComponent(this.channelId)}`);
|
|
27027
|
+
return { isEnabled: data.isPushNotifiable };
|
|
27028
|
+
}
|
|
27029
|
+
}
|
|
27030
|
+
class UserNotifications {
|
|
27031
|
+
async enable(modules) {
|
|
27032
|
+
var _a;
|
|
27033
|
+
const client = getActiveClient();
|
|
27034
|
+
const notifiableEvents = (_a = modules === null || modules === void 0 ? void 0 : modules.map(module => (Object.assign({ moduleName: module.moduleName, isPushNotifiable: module.isEnabled }, serializeRolesFilter(module.rolesFilter))))) !== null && _a !== void 0 ? _a : [];
|
|
27035
|
+
const body = {
|
|
27036
|
+
level: NotificationSettingsLevelEnum.USER,
|
|
27037
|
+
isPushNotifiable: true,
|
|
27038
|
+
notifiableEvents,
|
|
27039
|
+
};
|
|
27040
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
27041
|
+
}
|
|
27042
|
+
async disableAllNotifications() {
|
|
27043
|
+
const client = getActiveClient();
|
|
27044
|
+
const body = {
|
|
27045
|
+
level: NotificationSettingsLevelEnum.USER,
|
|
27046
|
+
isPushNotifiable: false,
|
|
27047
|
+
notifiableEvents: [],
|
|
27048
|
+
};
|
|
27049
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
27050
|
+
}
|
|
27051
|
+
async getSettings() {
|
|
27052
|
+
var _a;
|
|
27053
|
+
const client = getActiveClient();
|
|
27054
|
+
const { data } = await client.http.get(`/api/v3/notification/setting?level=${NotificationSettingsLevelEnum.USER}`);
|
|
27055
|
+
const validModuleNames = Object.values(UserNotificationModuleNameEnum);
|
|
27056
|
+
const modules = ((_a = data.notifiableEvents) !== null && _a !== void 0 ? _a : [])
|
|
27057
|
+
.filter(e => e.moduleName != null && validModuleNames.includes(e.moduleName))
|
|
27058
|
+
.map(e => ({
|
|
27059
|
+
moduleName: e.moduleName,
|
|
27060
|
+
isEnabled: e.isPushNotifiable,
|
|
27061
|
+
rolesFilter: parseRolesFilter(e.listenFromRoleIds, e.ignoreFromRoleIds),
|
|
27062
|
+
}));
|
|
27063
|
+
return { isEnabled: data.isPushNotifiable, modules };
|
|
27064
|
+
}
|
|
27065
|
+
}
|
|
27066
|
+
class CommunityNotifications {
|
|
27067
|
+
constructor(communityId) {
|
|
27068
|
+
this.communityId = communityId;
|
|
27069
|
+
}
|
|
27070
|
+
async enable(events) {
|
|
27071
|
+
var _a;
|
|
27072
|
+
const client = getActiveClient();
|
|
27073
|
+
const notifiableEvents = (_a = events === null || events === void 0 ? void 0 : events.map(event => (Object.assign({ moduleName: UserNotificationModuleNameEnum.SOCIAL, name: event.eventName, isPushNotifiable: event.isEnabled }, serializeRolesFilter(event.rolesFilter))))) !== null && _a !== void 0 ? _a : [];
|
|
27074
|
+
const body = {
|
|
27075
|
+
level: NotificationSettingsLevelEnum.COMMUNITY,
|
|
27076
|
+
communityId: this.communityId,
|
|
27077
|
+
isPushNotifiable: true,
|
|
27078
|
+
notifiableEvents,
|
|
27079
|
+
};
|
|
27080
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
27081
|
+
}
|
|
27082
|
+
async disable() {
|
|
27083
|
+
const client = getActiveClient();
|
|
27084
|
+
const body = {
|
|
27085
|
+
level: NotificationSettingsLevelEnum.COMMUNITY,
|
|
27086
|
+
communityId: this.communityId,
|
|
27087
|
+
isPushNotifiable: false,
|
|
27088
|
+
notifiableEvents: [],
|
|
27089
|
+
};
|
|
27090
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
27091
|
+
}
|
|
27092
|
+
async getSettings() {
|
|
27093
|
+
var _a;
|
|
27094
|
+
const client = getActiveClient();
|
|
27095
|
+
const { data } = await client.http.get(`/api/v3/notification/setting?level=${NotificationSettingsLevelEnum.COMMUNITY}&communityId=${encodeURIComponent(this.communityId)}`);
|
|
27096
|
+
const validEventNames = Object.values(CommunityNotificationEventNameEnum);
|
|
27097
|
+
const events = ((_a = data.notifiableEvents) !== null && _a !== void 0 ? _a : [])
|
|
27098
|
+
.filter(e => e.name != null && validEventNames.includes(e.name))
|
|
27099
|
+
.map(e => ({
|
|
27100
|
+
eventName: e.name,
|
|
27101
|
+
isEnabled: e.isPushNotifiable,
|
|
27102
|
+
isNetworkEnabled: e.isNetworkEnabled,
|
|
27103
|
+
rolesFilter: parseRolesFilter(e.listenFromRoleIds, e.ignoreFromRoleIds),
|
|
27104
|
+
}));
|
|
27105
|
+
return { isEnabled: data.isPushNotifiable, events };
|
|
27106
|
+
}
|
|
27107
|
+
}
|
|
27108
|
+
class Notifications {
|
|
27109
|
+
user() {
|
|
27110
|
+
return new UserNotifications();
|
|
27111
|
+
}
|
|
27112
|
+
community(communityId) {
|
|
27113
|
+
return new CommunityNotifications(communityId);
|
|
27114
|
+
}
|
|
27115
|
+
channel(channelId) {
|
|
27116
|
+
return new ChannelNotifications(channelId);
|
|
27117
|
+
}
|
|
27118
|
+
}
|
|
27119
|
+
const notifications = () => new Notifications();
|
|
27120
|
+
|
|
26883
27121
|
/**
|
|
26884
27122
|
* ```js
|
|
26885
27123
|
* import { onChannelMarkerFetched } from '@amityco/ts-sdk'
|
|
@@ -27260,6 +27498,8 @@ var index$s = /*#__PURE__*/Object.freeze({
|
|
|
27260
27498
|
getCurrentUserType: getCurrentUserType,
|
|
27261
27499
|
setCurrentUserType: setCurrentUserType,
|
|
27262
27500
|
setAccessTokenHandler: setAccessTokenHandler,
|
|
27501
|
+
getChatSettings: getChatSettings,
|
|
27502
|
+
notifications: notifications,
|
|
27263
27503
|
onConnectionError: onConnectionError,
|
|
27264
27504
|
onClientDisconnected: onClientDisconnected,
|
|
27265
27505
|
onClientBanned: onClientBanned,
|
|
@@ -29295,7 +29535,7 @@ const getWatchSessionStorage = () => {
|
|
|
29295
29535
|
return storageInstance;
|
|
29296
29536
|
};
|
|
29297
29537
|
|
|
29298
|
-
const privateKey = "
|
|
29538
|
+
const privateKey = "MIIEpQIBAAKCAQEAwAEc/oZgYIvKSUG/C3mONYLR4ZPgAjMEX4bJ+xqqakUDRtqlNO+eZs2blQ1Ko0DBkqPExyQezvjibH5W2UZBV5RaBTlTcNVKTToMBEGesAfaEcM3qUyQHxdbFYZv6P4sb14dcwxTQ8usmaV8ooiR1Fcaso5ZWYcZ8Hb46FbQ7OoVumsBtPWwfZ4f003o5VCl6AIM6lcLv9UDLlFVYhE+PeXpRHtfWlGqxMvqC9oinlwhL6nWv6VjQXW4nhcib72dPBzfHT7k/PMKto2SxALYdb68ENiAGuJLWi3AUHSyYCJK2w7wIlWfJUAI0v26ub10IpExr6D5QuW2577jjP93iwIDAQABAoIBAFWfqXhwIIatkFY+9Z1+ZcbDQimgsmMIsUiQaX6Lk7e0cxOj6czDlxYtVtaPiNtow2pLkjNkjkCqiP7tEHnwdK9DvylZOTa2R15NJpK3WLcTqVIGhsn/FL5owfvFah6zSsmXZParZm5zY9NZE03ALZhOB9/cz0e3kf/EbpfeL2mW7MApyiUt5i09ycchroOpcWp73ipIxvgigtZyUGFmsQicWhUs28F0D7w4Qfk76yG3nqXeb+BAMhCaIaa/k/aAxhiZG/ygEQWQrcC8gfe+jyicMAQPDEVS9YuUMGsLjIjKuVLZzp2xirQnhc2i2zVNEIvG6soprPOBEMQugzrtX5ECgYEA3b7KAbBIbDl1e4ZSCWhHdHkiWVZHaopsR/LhqDDNhXjWjq3AesgV6k0j9EdziMn/HmmOso0bz99GTV3JZf4A9ztTLumJlkHbdVtlgOqSjrFLj12rH9KXTheyIhWSpUmm8+WB1xasFbqpvJaGo7F3pd2Fqj1XR4mp5BO7c/t7LJ0CgYEA3aouEzXQ9THRKYocdfY69EI1Il1t/d/RSqqd9BxEjxBgxkM13ZiYIn/R4WW/nCUrlmhxG44Aa2Gob4Ahfsui2xKTg/g/3Zk/rAxAEGkfOLGoenaJMD41fH4wUq3FRYwkvnaMb9Hd6f/TlBHslIRa2NN58bSBGJCyBP2b59+2+EcCgYEAixDVRXvV37GlYUOa/XVdosk5Zoe6oDGRuQm0xbNdoUBoZvDHDvme7ONWEiQha/8qtVsD+CyQ7awcPfb8kK9c0bBt+bTS6d4BkTcxkEkMgtrkBVR8Nqfu5jXsLH4VCv4G61zbMhZw8+ut+az5YX2yCN7Frj9sFlxapMRPQmzMEe0CgYEAumsAzM8ZqNv4mAK65Mnr0rhLj1cbxcKRdUYACOgtEFQpzxN/HZnTeFAe5nx3pI3uFlRHq3DFEYnT6dHMWaJQmAULYpVIwMi9L6gtyJ9fzoI6uqMtxRDMUqKdaSsTGOY/kJ6KhQ/unXi1K3XXjR+yd1+C0q+HUm1+CYxvrZYLfskCgYEArsEy+IQOiqniJ0NE2vVUF+UK/IRZaic9YKcpov5Ot7Vvzm/MnnW4N1ljVskocETBWMmPUvNSExVjPebi+rxd8fa5kY8BJScPTzMFbunZn/wjtGdcM10qdlVQ9doG61A/9P3ezFKCfS4AvF/H/59LcSx2Bh28fp3/efiVIOpVd4Y=";
|
|
29299
29539
|
/*
|
|
29300
29540
|
* The crypto algorithm used for importing key and signing string
|
|
29301
29541
|
*/
|
|
@@ -30806,6 +31046,11 @@ const addReaction$1 = async (referenceType, referenceId, reactionName, reference
|
|
|
30806
31046
|
});
|
|
30807
31047
|
return true;
|
|
30808
31048
|
}
|
|
31049
|
+
if (referenceType === 'message') {
|
|
31050
|
+
upsertInCache(['message', 'get', referenceId], updatedModel);
|
|
31051
|
+
fireEvent('local.message.updated', { messages: [updatedModel] });
|
|
31052
|
+
return true;
|
|
31053
|
+
}
|
|
30809
31054
|
}
|
|
30810
31055
|
return true;
|
|
30811
31056
|
};
|
|
@@ -30884,7 +31129,7 @@ const removeReaction$1 = async (referenceType, referenceId, reactionName, refere
|
|
|
30884
31129
|
return true;
|
|
30885
31130
|
}
|
|
30886
31131
|
if (referenceType === 'story') {
|
|
30887
|
-
fireEvent('local.story.
|
|
31132
|
+
fireEvent('local.story.reactionRemoved', {
|
|
30888
31133
|
story: updatedModel,
|
|
30889
31134
|
reactor: {
|
|
30890
31135
|
userId: client.userId,
|
|
@@ -30894,6 +31139,11 @@ const removeReaction$1 = async (referenceType, referenceId, reactionName, refere
|
|
|
30894
31139
|
});
|
|
30895
31140
|
return true;
|
|
30896
31141
|
}
|
|
31142
|
+
if (referenceType === 'message') {
|
|
31143
|
+
upsertInCache(['message', 'get', referenceId], updatedModel);
|
|
31144
|
+
fireEvent('local.message.updated', { messages: [updatedModel] });
|
|
31145
|
+
return true;
|
|
31146
|
+
}
|
|
30897
31147
|
}
|
|
30898
31148
|
return true;
|
|
30899
31149
|
};
|
|
@@ -33817,7 +34067,7 @@ const removeReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
33817
34067
|
return true;
|
|
33818
34068
|
}
|
|
33819
34069
|
if (referenceType === 'story') {
|
|
33820
|
-
fireEvent('local.story.
|
|
34070
|
+
fireEvent('local.story.reactionRemoved', {
|
|
33821
34071
|
story: updatedModel,
|
|
33822
34072
|
reactor: {
|
|
33823
34073
|
userId: client.userId,
|
|
@@ -35401,6 +35651,104 @@ const unmuteChannel = async (channelId) => {
|
|
|
35401
35651
|
};
|
|
35402
35652
|
/* end_public_function */
|
|
35403
35653
|
|
|
35654
|
+
/* begin_public_function
|
|
35655
|
+
id: channel.archive
|
|
35656
|
+
*/
|
|
35657
|
+
/**
|
|
35658
|
+
* ```js
|
|
35659
|
+
* import { ChannelRepository } from '@amityco/ts-sdk'
|
|
35660
|
+
* const success = await ChannelRepository.archiveChannel('foobar')
|
|
35661
|
+
* ```
|
|
35662
|
+
*
|
|
35663
|
+
* Archive a {@link Amity.Channel}.
|
|
35664
|
+
*
|
|
35665
|
+
* @param channelId The id of the {@link Amity.Channel} to archive
|
|
35666
|
+
* @returns A success boolean
|
|
35667
|
+
*
|
|
35668
|
+
* @category Channel API
|
|
35669
|
+
* @async
|
|
35670
|
+
*/
|
|
35671
|
+
const archiveChannel = async (channelId) => {
|
|
35672
|
+
const client = getActiveClient();
|
|
35673
|
+
client.log('channel/archiveChannel', channelId);
|
|
35674
|
+
await client.http.post(`/api/v1/archives/channels/${encodeURIComponent(channelId)}`);
|
|
35675
|
+
const archive = {
|
|
35676
|
+
channelId,
|
|
35677
|
+
archivedAt: new Date().toISOString(),
|
|
35678
|
+
};
|
|
35679
|
+
if (client.cache) {
|
|
35680
|
+
pushToCache(['archivedChannel', 'get', getResolver('archivedChannel')(archive)], archive);
|
|
35681
|
+
}
|
|
35682
|
+
fireEvent('local.channel.archived', { archives: [archive] });
|
|
35683
|
+
};
|
|
35684
|
+
/* end_public_function */
|
|
35685
|
+
|
|
35686
|
+
/* begin_public_function
|
|
35687
|
+
id: channel.unarchive
|
|
35688
|
+
*/
|
|
35689
|
+
/**
|
|
35690
|
+
* ```js
|
|
35691
|
+
* import { ChannelRepository } from '@amityco/ts-sdk'
|
|
35692
|
+
* const success = await ChannelRepository.unarchiveChannel('foobar')
|
|
35693
|
+
* ```
|
|
35694
|
+
*
|
|
35695
|
+
* Unarchive a previously archived {@link Amity.Channel}.
|
|
35696
|
+
*
|
|
35697
|
+
* @param channelId The id of the {@link Amity.Channel} to unarchive
|
|
35698
|
+
* @returns A success boolean
|
|
35699
|
+
*
|
|
35700
|
+
* @category Channel API
|
|
35701
|
+
* @async
|
|
35702
|
+
*/
|
|
35703
|
+
const unarchiveChannel = async (channelId) => {
|
|
35704
|
+
var _a;
|
|
35705
|
+
const client = getActiveClient();
|
|
35706
|
+
client.log('channel/unarchiveChannel', channelId);
|
|
35707
|
+
await client.http.delete(`/api/v1/archives/channels/${encodeURIComponent(channelId)}`);
|
|
35708
|
+
const cached = (_a = pullFromCache(['archivedChannel', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
35709
|
+
const archive = cached !== null && cached !== void 0 ? cached : {
|
|
35710
|
+
channelId,
|
|
35711
|
+
archivedAt: new Date().toISOString(),
|
|
35712
|
+
};
|
|
35713
|
+
if (client.cache) {
|
|
35714
|
+
dropFromCache(['archivedChannel', 'get', channelId], true);
|
|
35715
|
+
}
|
|
35716
|
+
fireEvent('local.channel.unarchived', { archives: [archive] });
|
|
35717
|
+
};
|
|
35718
|
+
/* end_public_function */
|
|
35719
|
+
|
|
35720
|
+
/* begin_public_function
|
|
35721
|
+
id: channel.archive.ids
|
|
35722
|
+
*/
|
|
35723
|
+
/**
|
|
35724
|
+
* ```js
|
|
35725
|
+
* import { ChannelRepository } from '@amityco/ts-sdk'
|
|
35726
|
+
* const ids = await ChannelRepository.getArchivedChannelIds()
|
|
35727
|
+
* ```
|
|
35728
|
+
*
|
|
35729
|
+
* @returns A list of archived channel ids sorted by `archivedAt` descending.
|
|
35730
|
+
*
|
|
35731
|
+
* @category Channel API
|
|
35732
|
+
* @async
|
|
35733
|
+
*/
|
|
35734
|
+
const getArchivedChannelIds = async () => {
|
|
35735
|
+
var _a;
|
|
35736
|
+
const client = getActiveClient();
|
|
35737
|
+
client.log('channel/getArchivedChannelIds');
|
|
35738
|
+
const { data: payload } = await client.http.get(`/api/v1/archives/channels`);
|
|
35739
|
+
const archives = (_a = payload.archives) !== null && _a !== void 0 ? _a : [];
|
|
35740
|
+
if (client.cache) {
|
|
35741
|
+
dropFromCache(['archivedChannel', 'get']);
|
|
35742
|
+
archives.forEach(archive => {
|
|
35743
|
+
if (!archive.channelId)
|
|
35744
|
+
return;
|
|
35745
|
+
pushToCache(['archivedChannel', 'get', archive.channelId], archive);
|
|
35746
|
+
});
|
|
35747
|
+
}
|
|
35748
|
+
return archives.map(entry => entry.channelId).filter(channelId => !!channelId);
|
|
35749
|
+
};
|
|
35750
|
+
/* end_public_function */
|
|
35751
|
+
|
|
35404
35752
|
/**
|
|
35405
35753
|
* ```js
|
|
35406
35754
|
* import { onMessageUpdated } from '@amityco/ts-sdk'
|
|
@@ -36779,6 +37127,160 @@ const getMessages = (params, callback, config) => {
|
|
|
36779
37127
|
};
|
|
36780
37128
|
/* end_public_function */
|
|
36781
37129
|
|
|
37130
|
+
class SearchMessagePaginationController extends PaginationController {
|
|
37131
|
+
async getRequest(queryParams, token) {
|
|
37132
|
+
const { query, exactMatch, channelId, messageFeedId, userIds, tags, types, sortBy, orderBy, limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, } = queryParams;
|
|
37133
|
+
const options = token ? { token } : { limit, sortBy, orderBy };
|
|
37134
|
+
const { data: queryResponse } = await this.http.get(`/api/v2/search/messages`, {
|
|
37135
|
+
params: {
|
|
37136
|
+
query,
|
|
37137
|
+
exactMatch,
|
|
37138
|
+
channelId,
|
|
37139
|
+
messageFeedId,
|
|
37140
|
+
userIds,
|
|
37141
|
+
tags,
|
|
37142
|
+
types,
|
|
37143
|
+
options,
|
|
37144
|
+
},
|
|
37145
|
+
});
|
|
37146
|
+
return queryResponse;
|
|
37147
|
+
}
|
|
37148
|
+
}
|
|
37149
|
+
|
|
37150
|
+
class SearchMessageQueryStreamController extends QueryStreamController {
|
|
37151
|
+
constructor(query, cacheKey, notifyChange) {
|
|
37152
|
+
super(query, cacheKey);
|
|
37153
|
+
this.notifyChange = notifyChange;
|
|
37154
|
+
}
|
|
37155
|
+
async saveToMainDB(response) {
|
|
37156
|
+
var _a;
|
|
37157
|
+
const processedPayload = await prepareMessagePayload(response);
|
|
37158
|
+
const client = getActiveClient();
|
|
37159
|
+
const cachedAt = client.cache && Date.now();
|
|
37160
|
+
if (client.cache) {
|
|
37161
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
37162
|
+
if ((_a = response.channels) === null || _a === void 0 ? void 0 : _a.length) {
|
|
37163
|
+
response.channels.forEach(channel => {
|
|
37164
|
+
pushToCache(['channel', 'get', channel.channelId], channel, { cachedAt });
|
|
37165
|
+
});
|
|
37166
|
+
}
|
|
37167
|
+
}
|
|
37168
|
+
}
|
|
37169
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
37170
|
+
var _a, _b;
|
|
37171
|
+
if (refresh) {
|
|
37172
|
+
pushToCache(this.cacheKey, {
|
|
37173
|
+
data: response.messages.map(getResolver('message')),
|
|
37174
|
+
});
|
|
37175
|
+
return;
|
|
37176
|
+
}
|
|
37177
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
37178
|
+
const existing = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
37179
|
+
const incoming = response.messages.map(getResolver('message'));
|
|
37180
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: direction === "prev" /* Amity.LiveCollectionPageDirection.PREV */
|
|
37181
|
+
? [...new Set([...incoming, ...existing])]
|
|
37182
|
+
: [...new Set([...existing, ...incoming])] }));
|
|
37183
|
+
}
|
|
37184
|
+
}
|
|
37185
|
+
|
|
37186
|
+
class SearchMessageLiveCollectionController extends LiveCollectionController {
|
|
37187
|
+
constructor(query, callback) {
|
|
37188
|
+
const queryStreamId = hash(query);
|
|
37189
|
+
const cacheKey = ['message', 'search', queryStreamId];
|
|
37190
|
+
const paginationController = new SearchMessagePaginationController(query);
|
|
37191
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
37192
|
+
this.queryStreamController = new SearchMessageQueryStreamController(query, this.cacheKey, this.notifyChange.bind(this));
|
|
37193
|
+
this.callback = callback.bind(this);
|
|
37194
|
+
this.loadPage({ initial: true });
|
|
37195
|
+
}
|
|
37196
|
+
startSubscription() {
|
|
37197
|
+
return [];
|
|
37198
|
+
}
|
|
37199
|
+
notifyChange({ origin, loading, error }) {
|
|
37200
|
+
var _a, _b;
|
|
37201
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
37202
|
+
if (!collection)
|
|
37203
|
+
return;
|
|
37204
|
+
const data = (_b = collection.data
|
|
37205
|
+
.map(messageId => getMessageFromMainDB(messageId))
|
|
37206
|
+
.filter(isNonNullable)
|
|
37207
|
+
.map(message => LinkedObject.message(message))) !== null && _b !== void 0 ? _b : [];
|
|
37208
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
37209
|
+
return;
|
|
37210
|
+
this.callback({
|
|
37211
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
37212
|
+
data,
|
|
37213
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
37214
|
+
loading,
|
|
37215
|
+
error,
|
|
37216
|
+
});
|
|
37217
|
+
}
|
|
37218
|
+
setup() {
|
|
37219
|
+
var _a;
|
|
37220
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
37221
|
+
if (!collection) {
|
|
37222
|
+
pushToCache(this.cacheKey, {
|
|
37223
|
+
data: [],
|
|
37224
|
+
params: {},
|
|
37225
|
+
});
|
|
37226
|
+
}
|
|
37227
|
+
}
|
|
37228
|
+
async persistModel(response) {
|
|
37229
|
+
await this.queryStreamController.saveToMainDB(response);
|
|
37230
|
+
}
|
|
37231
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
37232
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
37233
|
+
}
|
|
37234
|
+
}
|
|
37235
|
+
|
|
37236
|
+
/* begin_public_function
|
|
37237
|
+
id: message.search
|
|
37238
|
+
*/
|
|
37239
|
+
/**
|
|
37240
|
+
* ```js
|
|
37241
|
+
* import { MessageRepository } from '@amityco/ts-sdk';
|
|
37242
|
+
*
|
|
37243
|
+
* let messages = [];
|
|
37244
|
+
*
|
|
37245
|
+
* const unsubscribe = MessageRepository.searchMessage(
|
|
37246
|
+
* { query: 'hello' },
|
|
37247
|
+
* response => merge(messages, response.data),
|
|
37248
|
+
* );
|
|
37249
|
+
* ```
|
|
37250
|
+
*
|
|
37251
|
+
* Live collection of {@link Amity.Message}s matching the search query. Backed
|
|
37252
|
+
* by `GET /api/v2/search/messages`. The first emission delivers the first
|
|
37253
|
+
* page; pagination is driven by `response.onNextPage()`.
|
|
37254
|
+
*
|
|
37255
|
+
* @param params Search parameters. `query` is required.
|
|
37256
|
+
* @param callback Called whenever new data are available.
|
|
37257
|
+
* @returns An {@link Amity.Unsubscriber} function to stop observing.
|
|
37258
|
+
*
|
|
37259
|
+
* @category Message Live Collection
|
|
37260
|
+
*/
|
|
37261
|
+
const searchMessage = (params, callback) => {
|
|
37262
|
+
if (!params.query || params.query.trim().length === 0) {
|
|
37263
|
+
throw new Error('Query is required for message search');
|
|
37264
|
+
}
|
|
37265
|
+
const { log, cache } = getActiveClient();
|
|
37266
|
+
if (!cache) {
|
|
37267
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
37268
|
+
}
|
|
37269
|
+
const timestamp = Date.now();
|
|
37270
|
+
log(`searchMessage(tmpid: ${timestamp}) > listen`);
|
|
37271
|
+
const controller = new SearchMessageLiveCollectionController(params, callback);
|
|
37272
|
+
const disposers = controller.startSubscription();
|
|
37273
|
+
const cacheKey = controller.getCacheKey();
|
|
37274
|
+
disposers.push(() => {
|
|
37275
|
+
dropFromCache(cacheKey);
|
|
37276
|
+
});
|
|
37277
|
+
return () => {
|
|
37278
|
+
log(`searchMessage(tmpid: ${timestamp}) > dispose`);
|
|
37279
|
+
disposers.forEach(fn => fn());
|
|
37280
|
+
};
|
|
37281
|
+
};
|
|
37282
|
+
/* end_public_function */
|
|
37283
|
+
|
|
36782
37284
|
var index$n = /*#__PURE__*/Object.freeze({
|
|
36783
37285
|
__proto__: null,
|
|
36784
37286
|
createMessage: createMessage,
|
|
@@ -36804,6 +37306,7 @@ var index$n = /*#__PURE__*/Object.freeze({
|
|
|
36804
37306
|
onMessageFetched: onMessageFetched,
|
|
36805
37307
|
getMessage: getMessage,
|
|
36806
37308
|
getMessages: getMessages,
|
|
37309
|
+
searchMessage: searchMessage,
|
|
36807
37310
|
convertFromRaw: convertFromRaw$1,
|
|
36808
37311
|
prepareMessagePayload: prepareMessagePayload,
|
|
36809
37312
|
convertParams: convertParams,
|
|
@@ -37651,6 +38154,7 @@ class ChannelQueryStreamController extends QueryStreamController {
|
|
|
37651
38154
|
"onCreate" /* Amity.ChannelActionType.OnCreate */,
|
|
37652
38155
|
"onJoin" /* Amity.ChannelActionType.OnJoin */,
|
|
37653
38156
|
"onResolveChannel" /* Amity.ChannelActionType.OnResolveChannel */,
|
|
38157
|
+
"onUnarchived" /* Amity.ChannelActionType.OnUnarchived */,
|
|
37654
38158
|
].includes(action)) {
|
|
37655
38159
|
if (Array.isArray(payload)) {
|
|
37656
38160
|
collection.data = [
|
|
@@ -37660,6 +38164,12 @@ class ChannelQueryStreamController extends QueryStreamController {
|
|
|
37660
38164
|
else
|
|
37661
38165
|
collection.data = [...new Set([payload.channelInternalId, ...collection.data])];
|
|
37662
38166
|
}
|
|
38167
|
+
if (action === "onArchived" /* Amity.ChannelActionType.OnArchived */) {
|
|
38168
|
+
const ids = Array.isArray(payload)
|
|
38169
|
+
? payload.map(getResolver('channel'))
|
|
38170
|
+
: [getResolver('channel')(payload)];
|
|
38171
|
+
collection.data = collection.data.filter(channelInternalId => !ids.includes(channelInternalId));
|
|
38172
|
+
}
|
|
37663
38173
|
pushToCache(this.cacheKey, collection);
|
|
37664
38174
|
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
37665
38175
|
};
|
|
@@ -37926,6 +38436,32 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
37926
38436
|
},
|
|
37927
38437
|
{ fn: onChannelMemberAdded, action: "onMemberAdded" /* Amity.ChannelActionType.OnMemberAdded */ },
|
|
37928
38438
|
{ fn: onChannelMemberRemoved, action: "onMemberRemoved" /* Amity.ChannelActionType.OnMemberRemoved */ },
|
|
38439
|
+
{
|
|
38440
|
+
fn: (reactor) => onChannelArchived(payload => {
|
|
38441
|
+
const channels = payload.archives
|
|
38442
|
+
.map(archive => {
|
|
38443
|
+
var _a;
|
|
38444
|
+
return (_a = pullFromCache(['channel', 'get', archive.channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
38445
|
+
})
|
|
38446
|
+
.filter((c) => Boolean(c));
|
|
38447
|
+
if (channels.length > 0)
|
|
38448
|
+
reactor(channels);
|
|
38449
|
+
}),
|
|
38450
|
+
action: "onArchived" /* Amity.ChannelActionType.OnArchived */,
|
|
38451
|
+
},
|
|
38452
|
+
{
|
|
38453
|
+
fn: (reactor) => onChannelUnarchived(payload => {
|
|
38454
|
+
const channels = payload.archives
|
|
38455
|
+
.map(archive => {
|
|
38456
|
+
var _a;
|
|
38457
|
+
return (_a = pullFromCache(['channel', 'get', archive.channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
38458
|
+
})
|
|
38459
|
+
.filter((c) => Boolean(c));
|
|
38460
|
+
if (channels.length > 0)
|
|
38461
|
+
reactor(channels);
|
|
38462
|
+
}),
|
|
38463
|
+
action: "onUnarchived" /* Amity.ChannelActionType.OnUnarchived */,
|
|
38464
|
+
},
|
|
37929
38465
|
{
|
|
37930
38466
|
fn: convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel'),
|
|
37931
38467
|
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
@@ -38279,6 +38815,192 @@ const getTotalChannelsUnread = (callback) => {
|
|
|
38279
38815
|
};
|
|
38280
38816
|
};
|
|
38281
38817
|
|
|
38818
|
+
class ArchivedChannelPaginationController extends PaginationController {
|
|
38819
|
+
async getRequest(queryParams, token) {
|
|
38820
|
+
var _a, _b;
|
|
38821
|
+
const limit = (_a = queryParams.limit) !== null && _a !== void 0 ? _a : COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
38822
|
+
const pageIndex = token ? Number.parseInt(token, 10) : 0;
|
|
38823
|
+
if (pageIndex === 0) {
|
|
38824
|
+
await getArchivedChannelIds();
|
|
38825
|
+
}
|
|
38826
|
+
const cached = (_b = queryCache(['archivedChannel', 'get'])) !== null && _b !== void 0 ? _b : [];
|
|
38827
|
+
const archives = cached
|
|
38828
|
+
.map(entry => entry.data)
|
|
38829
|
+
.slice()
|
|
38830
|
+
.sort((a, b) => Number(new Date(b.archivedAt)) - Number(new Date(a.archivedAt)));
|
|
38831
|
+
const start = pageIndex * limit;
|
|
38832
|
+
const end = start + limit;
|
|
38833
|
+
const slice = archives.slice(start, end);
|
|
38834
|
+
const hasMore = end < archives.length;
|
|
38835
|
+
if (slice.length > 0) {
|
|
38836
|
+
await getChannelByIds$1(slice.map(archive => archive.channelId));
|
|
38837
|
+
}
|
|
38838
|
+
return {
|
|
38839
|
+
archives: slice,
|
|
38840
|
+
paging: {
|
|
38841
|
+
next: hasMore ? String(pageIndex + 1) : undefined,
|
|
38842
|
+
previous: undefined,
|
|
38843
|
+
},
|
|
38844
|
+
};
|
|
38845
|
+
}
|
|
38846
|
+
}
|
|
38847
|
+
|
|
38848
|
+
class ArchivedChannelQueryStreamController extends QueryStreamController {
|
|
38849
|
+
constructor(query, cacheKey, notifyChange) {
|
|
38850
|
+
super(query, cacheKey);
|
|
38851
|
+
this.notifyChange = notifyChange;
|
|
38852
|
+
}
|
|
38853
|
+
async saveToMainDB(_response) {
|
|
38854
|
+
//
|
|
38855
|
+
}
|
|
38856
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
38857
|
+
var _a, _b;
|
|
38858
|
+
const channelIds = response.archives.map(archive => archive.channelId);
|
|
38859
|
+
if (refresh) {
|
|
38860
|
+
pushToCache(this.cacheKey, {
|
|
38861
|
+
data: channelIds,
|
|
38862
|
+
params: {},
|
|
38863
|
+
});
|
|
38864
|
+
return;
|
|
38865
|
+
}
|
|
38866
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
38867
|
+
const existing = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
38868
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: direction === "prev" /* Amity.LiveCollectionPageDirection.PREV */
|
|
38869
|
+
? [...new Set([...channelIds, ...existing])]
|
|
38870
|
+
: [...new Set([...existing, ...channelIds])] }));
|
|
38871
|
+
}
|
|
38872
|
+
reactor(action) {
|
|
38873
|
+
return (channelIds) => {
|
|
38874
|
+
var _a;
|
|
38875
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
38876
|
+
if (!collection)
|
|
38877
|
+
return;
|
|
38878
|
+
if (action === "onArchived" /* Amity.ChannelActionType.OnArchived */) {
|
|
38879
|
+
const filtered = collection.data.filter(id => !channelIds.includes(id));
|
|
38880
|
+
collection.data = [...channelIds, ...filtered];
|
|
38881
|
+
}
|
|
38882
|
+
if (action === "onUnarchived" /* Amity.ChannelActionType.OnUnarchived */ ||
|
|
38883
|
+
action === "onDelete" /* Amity.ChannelActionType.OnDelete */) {
|
|
38884
|
+
collection.data = collection.data.filter(id => !channelIds.includes(id));
|
|
38885
|
+
}
|
|
38886
|
+
pushToCache(this.cacheKey, collection);
|
|
38887
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
38888
|
+
};
|
|
38889
|
+
}
|
|
38890
|
+
subscribeRTE(createSubscriber) {
|
|
38891
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
38892
|
+
}
|
|
38893
|
+
}
|
|
38894
|
+
|
|
38895
|
+
class ArchivedChannelLiveCollectionController extends LiveCollectionController {
|
|
38896
|
+
constructor(query, callback) {
|
|
38897
|
+
const queryStreamId = hash(query);
|
|
38898
|
+
const cacheKey = ['archivedChannel', 'collection', queryStreamId];
|
|
38899
|
+
const paginationController = new ArchivedChannelPaginationController(query);
|
|
38900
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
38901
|
+
this.queryStreamController = new ArchivedChannelQueryStreamController(query, this.cacheKey, this.notifyChange.bind(this));
|
|
38902
|
+
this.callback = callback.bind(this);
|
|
38903
|
+
this.loadPage({ initial: true });
|
|
38904
|
+
}
|
|
38905
|
+
setup() {
|
|
38906
|
+
var _a;
|
|
38907
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
38908
|
+
if (!collection) {
|
|
38909
|
+
pushToCache(this.cacheKey, {
|
|
38910
|
+
data: [],
|
|
38911
|
+
params: {},
|
|
38912
|
+
});
|
|
38913
|
+
}
|
|
38914
|
+
}
|
|
38915
|
+
async persistModel(response) {
|
|
38916
|
+
await this.queryStreamController.saveToMainDB(response);
|
|
38917
|
+
}
|
|
38918
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
38919
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
38920
|
+
}
|
|
38921
|
+
startSubscription() {
|
|
38922
|
+
return this.queryStreamController.subscribeRTE([
|
|
38923
|
+
{
|
|
38924
|
+
fn: reactor => onChannelArchived(payload => reactor(payload.archives.map(archive => archive.channelId))),
|
|
38925
|
+
action: "onArchived" /* Amity.ChannelActionType.OnArchived */,
|
|
38926
|
+
},
|
|
38927
|
+
{
|
|
38928
|
+
fn: reactor => onChannelUnarchived(payload => reactor(payload.archives.map(archive => archive.channelId))),
|
|
38929
|
+
action: "onUnarchived" /* Amity.ChannelActionType.OnUnarchived */,
|
|
38930
|
+
},
|
|
38931
|
+
{
|
|
38932
|
+
fn: reactor => onChannelUpdated(channel => reactor([channel.channelId])),
|
|
38933
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
38934
|
+
},
|
|
38935
|
+
{
|
|
38936
|
+
fn: reactor => onChannelDeleted(channel => reactor([channel.channelId])),
|
|
38937
|
+
action: "onDelete" /* Amity.ChannelActionType.OnDelete */,
|
|
38938
|
+
},
|
|
38939
|
+
]);
|
|
38940
|
+
}
|
|
38941
|
+
notifyChange({ origin, loading, error }) {
|
|
38942
|
+
var _a, _b;
|
|
38943
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
38944
|
+
if (!collection)
|
|
38945
|
+
return;
|
|
38946
|
+
const data = (_b = collection.data
|
|
38947
|
+
.map(channelId => pullFromCache(['channel', 'get', channelId]))
|
|
38948
|
+
.filter((entry) => Boolean(entry))
|
|
38949
|
+
.map(({ data: channel }) => channel)
|
|
38950
|
+
.map(constructChannelObject)) !== null && _b !== void 0 ? _b : [];
|
|
38951
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
38952
|
+
return;
|
|
38953
|
+
this.callback({
|
|
38954
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
38955
|
+
data,
|
|
38956
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
38957
|
+
loading,
|
|
38958
|
+
error,
|
|
38959
|
+
});
|
|
38960
|
+
}
|
|
38961
|
+
}
|
|
38962
|
+
|
|
38963
|
+
/* begin_public_function
|
|
38964
|
+
id: channel.archive.collection
|
|
38965
|
+
*/
|
|
38966
|
+
/**
|
|
38967
|
+
* ```js
|
|
38968
|
+
* import { ChannelRepository } from '@amityco/ts-sdk'
|
|
38969
|
+
*
|
|
38970
|
+
* let channels = []
|
|
38971
|
+
* const unsub = ChannelRepository.getArchivedChannels(params, response => merge(channels, response.data))
|
|
38972
|
+
* ```
|
|
38973
|
+
*
|
|
38974
|
+
* Live collection of {@link Amity.Channel}s archived by the active user.
|
|
38975
|
+
*
|
|
38976
|
+
* @param params Live collection parameters (only `limit` is honored; the
|
|
38977
|
+
* archive list takes no other filters).
|
|
38978
|
+
* @param callback the function to call when new data are available
|
|
38979
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to
|
|
38980
|
+
* stop observing.
|
|
38981
|
+
*
|
|
38982
|
+
* @category Channel Live Collection
|
|
38983
|
+
*/
|
|
38984
|
+
const getArchivedChannels = (params, callback) => {
|
|
38985
|
+
const { log, cache } = getActiveClient();
|
|
38986
|
+
if (!cache) {
|
|
38987
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
38988
|
+
}
|
|
38989
|
+
const timestamp = Date.now();
|
|
38990
|
+
log(`getArchivedChannels(tmpid: ${timestamp}) > listen`);
|
|
38991
|
+
const controller = new ArchivedChannelLiveCollectionController(params, callback);
|
|
38992
|
+
const disposers = controller.startSubscription();
|
|
38993
|
+
const cacheKey = controller.getCacheKey();
|
|
38994
|
+
disposers.push(() => {
|
|
38995
|
+
dropFromCache(cacheKey);
|
|
38996
|
+
});
|
|
38997
|
+
return () => {
|
|
38998
|
+
log(`getArchivedChannels(tmpid: ${timestamp}) > dispose`);
|
|
38999
|
+
disposers.forEach(fn => fn());
|
|
39000
|
+
};
|
|
39001
|
+
};
|
|
39002
|
+
/* end_public_function */
|
|
39003
|
+
|
|
38282
39004
|
/* begin_public_function
|
|
38283
39005
|
id: channel.member.add
|
|
38284
39006
|
*/
|
|
@@ -38410,7 +39132,9 @@ class ChannelMemberQueryStreamController extends QueryStreamController {
|
|
|
38410
39132
|
channelId: this.query.channelId,
|
|
38411
39133
|
userId: channelMember.userId,
|
|
38412
39134
|
});
|
|
38413
|
-
|
|
39135
|
+
const membershipFilter = this.query.memberships;
|
|
39136
|
+
const isInFilter = !membershipFilter || membershipFilter.includes(channelMember.membership);
|
|
39137
|
+
if (channelMember.membership === 'none' || !isInFilter) {
|
|
38414
39138
|
collection.data = collection.data.filter(m => m !== channelMemberCacheId);
|
|
38415
39139
|
}
|
|
38416
39140
|
else if (!collection.data.includes(channelMemberCacheId)) {
|
|
@@ -38746,6 +39470,7 @@ const banMembers$1 = async (channelId, userIds) => {
|
|
|
38746
39470
|
const cachedAt = client.cache && Date.now();
|
|
38747
39471
|
if (client.cache)
|
|
38748
39472
|
ingestInCache(preparedPayload, { cachedAt });
|
|
39473
|
+
fireEvent('channel.banned', payload);
|
|
38749
39474
|
return {
|
|
38750
39475
|
data: channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(user => user.membership === 'banned'),
|
|
38751
39476
|
cachedAt,
|
|
@@ -38780,6 +39505,7 @@ const unbanMembers$1 = async (channelId, userIds) => {
|
|
|
38780
39505
|
const cachedAt = client.cache && Date.now();
|
|
38781
39506
|
if (client.cache)
|
|
38782
39507
|
ingestInCache(preparedPayload, { cachedAt });
|
|
39508
|
+
fireEvent('channel.unbanned', payload);
|
|
38783
39509
|
const { channelUsers } = preparedPayload;
|
|
38784
39510
|
return {
|
|
38785
39511
|
data: channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(user => user.membership === 'member'),
|
|
@@ -38808,6 +39534,7 @@ const MUTE_FOREVER = -1;
|
|
|
38808
39534
|
* @async
|
|
38809
39535
|
* */
|
|
38810
39536
|
const muteMembers = async (channelId, userIds, mutePeriod = MUTE_FOREVER) => {
|
|
39537
|
+
var _a;
|
|
38811
39538
|
const client = getActiveClient();
|
|
38812
39539
|
client.log('channel/muteMembers', { userIds, channelId, mutePeriod });
|
|
38813
39540
|
const { data } = await client.http.put(`/api/v2/channel/${channelId}/users/mute`, {
|
|
@@ -38815,6 +39542,15 @@ const muteMembers = async (channelId, userIds, mutePeriod = MUTE_FOREVER) => {
|
|
|
38815
39542
|
mutePeriod: mutePeriod === MUTE_FOREVER ? mutePeriod : mutePeriod * 1000,
|
|
38816
39543
|
});
|
|
38817
39544
|
const { success } = data;
|
|
39545
|
+
const muteTimeout = mutePeriod === MUTE_FOREVER
|
|
39546
|
+
? new Date('9999-12-31T23:59:59.999Z').toISOString()
|
|
39547
|
+
: new Date(Date.now() + mutePeriod * 1000).toISOString();
|
|
39548
|
+
fireEvent('channel.setMutedUsers', {
|
|
39549
|
+
channelId,
|
|
39550
|
+
userIds,
|
|
39551
|
+
muteTimeout,
|
|
39552
|
+
actor: (_a = client.userId) !== null && _a !== void 0 ? _a : '',
|
|
39553
|
+
});
|
|
38818
39554
|
return success;
|
|
38819
39555
|
};
|
|
38820
39556
|
/* end_public_function */
|
|
@@ -38837,6 +39573,7 @@ const muteMembers = async (channelId, userIds, mutePeriod = MUTE_FOREVER) => {
|
|
|
38837
39573
|
* @async
|
|
38838
39574
|
* */
|
|
38839
39575
|
const unmuteMembers = async (channelId, userIds) => {
|
|
39576
|
+
var _a;
|
|
38840
39577
|
const client = getActiveClient();
|
|
38841
39578
|
client.log('channel/unmuteMembers', { userIds, channelId });
|
|
38842
39579
|
const { data } = await client.http.put(`/api/v2/channel/${encodeURIComponent(channelId)}/users/mute`, {
|
|
@@ -38844,6 +39581,12 @@ const unmuteMembers = async (channelId, userIds) => {
|
|
|
38844
39581
|
mutePeriod: 0,
|
|
38845
39582
|
});
|
|
38846
39583
|
const { success } = data;
|
|
39584
|
+
fireEvent('channel.setMutedUsers', {
|
|
39585
|
+
channelId,
|
|
39586
|
+
userIds,
|
|
39587
|
+
muteTimeout: new Date(0).toISOString(),
|
|
39588
|
+
actor: (_a = client.userId) !== null && _a !== void 0 ? _a : '',
|
|
39589
|
+
});
|
|
38847
39590
|
return success;
|
|
38848
39591
|
};
|
|
38849
39592
|
/* end_public_function */
|
|
@@ -38870,6 +39613,9 @@ var index$j = /*#__PURE__*/Object.freeze({
|
|
|
38870
39613
|
leaveChannel: leaveChannel,
|
|
38871
39614
|
muteChannel: muteChannel,
|
|
38872
39615
|
unmuteChannel: unmuteChannel,
|
|
39616
|
+
archiveChannel: archiveChannel,
|
|
39617
|
+
unarchiveChannel: unarchiveChannel,
|
|
39618
|
+
getArchivedChannelIds: getArchivedChannelIds,
|
|
38873
39619
|
onChannelCreated: onChannelCreated,
|
|
38874
39620
|
onChannelUpdated: onChannelUpdated,
|
|
38875
39621
|
onChannelDeleted: onChannelDeleted,
|
|
@@ -38882,9 +39628,12 @@ var index$j = /*#__PURE__*/Object.freeze({
|
|
|
38882
39628
|
onChannelMemberUnbanned: onChannelMemberUnbanned,
|
|
38883
39629
|
onChannelMemberRoleAdded: onChannelMemberRoleAdded,
|
|
38884
39630
|
onChannelMemberRoleRemoved: onChannelMemberRoleRemoved,
|
|
39631
|
+
onChannelArchived: onChannelArchived,
|
|
39632
|
+
onChannelUnarchived: onChannelUnarchived,
|
|
38885
39633
|
getChannel: getChannel,
|
|
38886
39634
|
getChannels: getChannels,
|
|
38887
39635
|
getTotalChannelsUnread: getTotalChannelsUnread,
|
|
39636
|
+
getArchivedChannels: getArchivedChannels,
|
|
38888
39637
|
MARKER_INCLUDED_CHANNEL_TYPE: MARKER_INCLUDED_CHANNEL_TYPE,
|
|
38889
39638
|
isUnreadCountSupport: isUnreadCountSupport,
|
|
38890
39639
|
convertFromRaw: convertFromRaw,
|
|
@@ -51579,4 +52328,4 @@ class AmityAttachmentProductTags {
|
|
|
51579
52328
|
}
|
|
51580
52329
|
}
|
|
51581
52330
|
|
|
51582
|
-
export { API_REGIONS, index$5 as AdRepository, AmityAttachmentProductTags, AmityCommunityType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, AnalyticsSourceTypeEnum, index$f as CategoryRepository, index$j as ChannelRepository, index$s as Client, index$e as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$g as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index$1 as EventRepository, FeedDataTypeEnum, index$d as FeedRepository, FeedSortByEnum, FeedSourceEnum, FeedTypeEnum, FileAccessTypeEnum, index$p as FileRepository, FileType, GET_WATCHER_URLS, index$3 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$2 as LiveReactionRepository, index$7 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$n as MessageRepository, index$8 as PollRepository, PostContentType, index$b as PostRepository, PostStructureType, index as ProductRepository, index$o as ReactionRepository, index$9 as RoomPresenceRepository, index$c as RoomRepository, SearchUsersByEnum, index$6 as StoryRepository, index$a as StreamRepository, index$m as SubChannelRepository, SubscriptionLevels, index$q as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, exceedsUntilAtBoundary, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, filterByUntilAt, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getRoomStreamerTopic, getRoomWatcherTopic, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$4 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, validateUntilAt, wipeCache };
|
|
52331
|
+
export { API_REGIONS, index$5 as AdRepository, AmityAttachmentProductTags, AmityChannelNotificationModeEnum, AmityCommunityType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, AnalyticsSourceTypeEnum, index$f as CategoryRepository, index$j as ChannelRepository, index$s as Client, index$e as CommentRepository, CommunityNotificationEventNameEnum, CommunityPostSettingMaps, CommunityPostSettings, index$g as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index$1 as EventRepository, FeedDataTypeEnum, index$d as FeedRepository, FeedSortByEnum, FeedSourceEnum, FeedTypeEnum, FileAccessTypeEnum, index$p as FileRepository, FileType, GET_WATCHER_URLS, index$3 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$2 as LiveReactionRepository, index$7 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$n as MessageRepository, NotificationRolesFilterTypeEnum, NotificationSettingsLevelEnum, index$8 as PollRepository, PostContentType, index$b as PostRepository, PostStructureType, index as ProductRepository, index$o as ReactionRepository, index$9 as RoomPresenceRepository, index$c as RoomRepository, SearchUsersByEnum, index$6 as StoryRepository, index$a as StreamRepository, index$m as SubChannelRepository, SubscriptionLevels, UserNotificationModuleNameEnum, index$q as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, exceedsUntilAtBoundary, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, filterByUntilAt, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getRoomStreamerTopic, getRoomWatcherTopic, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$4 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, validateUntilAt, wipeCache };
|