@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.cjs.js
CHANGED
|
@@ -74,6 +74,13 @@ exports.FileAccessTypeEnum = void 0;
|
|
|
74
74
|
FileAccessTypeEnum["NETWORK"] = "network";
|
|
75
75
|
})(exports.FileAccessTypeEnum || (exports.FileAccessTypeEnum = {}));
|
|
76
76
|
|
|
77
|
+
exports.AmityChannelNotificationModeEnum = void 0;
|
|
78
|
+
(function (AmityChannelNotificationModeEnum) {
|
|
79
|
+
AmityChannelNotificationModeEnum["Default"] = "default";
|
|
80
|
+
AmityChannelNotificationModeEnum["Silent"] = "silent";
|
|
81
|
+
AmityChannelNotificationModeEnum["Subscribe"] = "subscribe";
|
|
82
|
+
})(exports.AmityChannelNotificationModeEnum || (exports.AmityChannelNotificationModeEnum = {}));
|
|
83
|
+
|
|
77
84
|
const CommunityPostSettings = Object.freeze({
|
|
78
85
|
ONLY_ADMIN_CAN_POST: 'ONLY_ADMIN_CAN_POST',
|
|
79
86
|
ADMIN_REVIEW_POST_REQUIRED: 'ADMIN_REVIEW_POST_REQUIRED',
|
|
@@ -255,6 +262,39 @@ exports.AnalyticsSourceTypeEnum = void 0;
|
|
|
255
262
|
AnalyticsSourceTypeEnum["ROOM"] = "room";
|
|
256
263
|
})(exports.AnalyticsSourceTypeEnum || (exports.AnalyticsSourceTypeEnum = {}));
|
|
257
264
|
|
|
265
|
+
exports.UserNotificationModuleNameEnum = void 0;
|
|
266
|
+
(function (UserNotificationModuleNameEnum) {
|
|
267
|
+
UserNotificationModuleNameEnum["CHAT"] = "chat";
|
|
268
|
+
UserNotificationModuleNameEnum["SOCIAL"] = "social";
|
|
269
|
+
UserNotificationModuleNameEnum["VIDEO_STREAMING"] = "video-streaming";
|
|
270
|
+
})(exports.UserNotificationModuleNameEnum || (exports.UserNotificationModuleNameEnum = {}));
|
|
271
|
+
exports.CommunityNotificationEventNameEnum = void 0;
|
|
272
|
+
(function (CommunityNotificationEventNameEnum) {
|
|
273
|
+
CommunityNotificationEventNameEnum["POST_CREATED"] = "post.created";
|
|
274
|
+
CommunityNotificationEventNameEnum["POST_REACTED"] = "post.reacted";
|
|
275
|
+
CommunityNotificationEventNameEnum["COMMENT_CREATED"] = "comment.created";
|
|
276
|
+
CommunityNotificationEventNameEnum["COMMENT_REPLIED"] = "comment.replied";
|
|
277
|
+
CommunityNotificationEventNameEnum["COMMENT_REACTED"] = "comment.reacted";
|
|
278
|
+
CommunityNotificationEventNameEnum["STORY_CREATED"] = "story.created";
|
|
279
|
+
CommunityNotificationEventNameEnum["STORY_REACTED"] = "story.reacted";
|
|
280
|
+
CommunityNotificationEventNameEnum["STORY_COMMENT_CREATED"] = "story-comment.created";
|
|
281
|
+
CommunityNotificationEventNameEnum["LIVESTREAM_START"] = "video-streaming.didStart";
|
|
282
|
+
})(exports.CommunityNotificationEventNameEnum || (exports.CommunityNotificationEventNameEnum = {}));
|
|
283
|
+
exports.NotificationSettingsLevelEnum = void 0;
|
|
284
|
+
(function (NotificationSettingsLevelEnum) {
|
|
285
|
+
NotificationSettingsLevelEnum["USER"] = "user";
|
|
286
|
+
NotificationSettingsLevelEnum["COMMUNITY"] = "community";
|
|
287
|
+
NotificationSettingsLevelEnum["CHANNEL"] = "channel";
|
|
288
|
+
})(exports.NotificationSettingsLevelEnum || (exports.NotificationSettingsLevelEnum = {}));
|
|
289
|
+
/**
|
|
290
|
+
* `NOT` variant is intentionally excluded from public API (internal server-side use only).
|
|
291
|
+
*/
|
|
292
|
+
exports.NotificationRolesFilterTypeEnum = void 0;
|
|
293
|
+
(function (NotificationRolesFilterTypeEnum) {
|
|
294
|
+
NotificationRolesFilterTypeEnum["ALL"] = "all";
|
|
295
|
+
NotificationRolesFilterTypeEnum["ONLY"] = "only";
|
|
296
|
+
})(exports.NotificationRolesFilterTypeEnum || (exports.NotificationRolesFilterTypeEnum = {}));
|
|
297
|
+
|
|
258
298
|
function getVersion() {
|
|
259
299
|
try {
|
|
260
300
|
// the string ''v7.19.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
@@ -667,6 +707,7 @@ const idResolvers = {
|
|
|
667
707
|
channel: ({ channelInternalId }) => channelInternalId,
|
|
668
708
|
subChannel: ({ subChannelId }) => subChannelId,
|
|
669
709
|
channelUsers: ({ channelId, userId }) => `${channelId}#${userId}`,
|
|
710
|
+
archivedChannel: ({ channelId }) => channelId,
|
|
670
711
|
message: ({ messageId, referenceId }) => referenceId !== null && referenceId !== void 0 ? referenceId : messageId,
|
|
671
712
|
messagePreviewChannel: ({ channelId }) => `${channelId}`,
|
|
672
713
|
messagePreviewSubChannel: ({ subChannelId }) => `${subChannelId}`,
|
|
@@ -730,6 +771,7 @@ const PAYLOAD2MODEL = {
|
|
|
730
771
|
channels: 'channel',
|
|
731
772
|
messageFeeds: 'subChannel',
|
|
732
773
|
channelUsers: 'channelUsers',
|
|
774
|
+
archives: 'archivedChannel',
|
|
733
775
|
messages: 'message',
|
|
734
776
|
messagePreviewChannel: 'messagePreviewChannel',
|
|
735
777
|
messagePreviewSubChannel: 'messagePreviewSubChannel',
|
|
@@ -5952,24 +5994,43 @@ const preUpdateChannelCache = (rawPayload, options = { isMessagePreviewUpdated:
|
|
|
5952
5994
|
});
|
|
5953
5995
|
};
|
|
5954
5996
|
const updateChannelUnread = ({ currentUserId, channels, channelUsers, }) => {
|
|
5997
|
+
var _a, _b;
|
|
5955
5998
|
const channelsUnread = [];
|
|
5956
5999
|
for (let i = 0; i < channels.length; i += 1) {
|
|
5957
6000
|
if (isUnreadCountSupport(channels[i])) {
|
|
5958
6001
|
const cacheKey = ['channelUnread', 'get', channels[i].channelId];
|
|
5959
6002
|
const channelUser = channelUsers.find(channelUser => channelUser.channelId === channels[i].channelId && channelUser.userId === currentUserId);
|
|
5960
|
-
|
|
6003
|
+
// readToSegment, lastMentionedSegment and lastSegment are monotonically non-decreasing;
|
|
6004
|
+
// prefer cached values when ahead of the server so a refetch returning stale data cannot
|
|
6005
|
+
// revert updates already written by MessageReadReceiptSyncEngine.markRead (readToSegment)
|
|
6006
|
+
// or onMessageCreatedMqtt (lastSegment).
|
|
6007
|
+
const cached = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
6008
|
+
const lastSegment = Math.max((_b = cached === null || cached === void 0 ? void 0 : cached.lastSegment) !== null && _b !== void 0 ? _b : 0, channels[i].messageCount);
|
|
5961
6009
|
let readToSegment = null;
|
|
5962
6010
|
let lastMentionedSegment = null;
|
|
6011
|
+
let unreadCount = 0;
|
|
5963
6012
|
let isMentioned = false;
|
|
5964
6013
|
if (channelUser) {
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
6014
|
+
const serverRead = channelUser.readToSegment;
|
|
6015
|
+
const serverMention = channelUser.lastMentionedSegment;
|
|
6016
|
+
readToSegment =
|
|
6017
|
+
typeof (cached === null || cached === void 0 ? void 0 : cached.readToSegment) === 'number' &&
|
|
6018
|
+
(typeof serverRead !== 'number' || cached.readToSegment > serverRead)
|
|
6019
|
+
? cached.readToSegment
|
|
6020
|
+
: serverRead !== null && serverRead !== void 0 ? serverRead : null;
|
|
6021
|
+
lastMentionedSegment =
|
|
6022
|
+
typeof (cached === null || cached === void 0 ? void 0 : cached.lastMentionedSegment) === 'number' &&
|
|
6023
|
+
(typeof serverMention !== 'number' || cached.lastMentionedSegment > serverMention)
|
|
6024
|
+
? cached.lastMentionedSegment
|
|
6025
|
+
: serverMention !== null && serverMention !== void 0 ? serverMention : null;
|
|
6026
|
+
const readForCalc = readToSegment !== null && readToSegment !== void 0 ? readToSegment : 0;
|
|
6027
|
+
unreadCount = Math.max(lastSegment - readForCalc, 0);
|
|
6028
|
+
isMentioned =
|
|
6029
|
+
typeof lastMentionedSegment === 'number' && readForCalc < lastMentionedSegment;
|
|
5969
6030
|
}
|
|
5970
6031
|
const cacheChannelUnread = {
|
|
5971
6032
|
channelId: channels[i].channelId,
|
|
5972
|
-
lastSegment
|
|
6033
|
+
lastSegment,
|
|
5973
6034
|
readToSegment,
|
|
5974
6035
|
lastMentionedSegment,
|
|
5975
6036
|
unreadCount,
|
|
@@ -5979,6 +6040,8 @@ const updateChannelUnread = ({ currentUserId, channels, channelUsers, }) => {
|
|
|
5979
6040
|
pushToCache(cacheKey, cacheChannelUnread);
|
|
5980
6041
|
channelsUnread.push(cacheChannelUnread);
|
|
5981
6042
|
}
|
|
6043
|
+
}
|
|
6044
|
+
if (channelsUnread.length > 0) {
|
|
5982
6045
|
fireEvent('local.channelUnread.updated', channelsUnread);
|
|
5983
6046
|
}
|
|
5984
6047
|
};
|
|
@@ -6678,7 +6741,7 @@ const onChannelMemberRoleRemoved = (callback) => {
|
|
|
6678
6741
|
const client = getActiveClient();
|
|
6679
6742
|
const filter = async (payload) => {
|
|
6680
6743
|
const { channels, channelUsers } = payload;
|
|
6681
|
-
|
|
6744
|
+
callbacks$1.forEach(cb => cb(channels[0], channelUsers.find(channelUser => channelUser.membership === 'member')));
|
|
6682
6745
|
};
|
|
6683
6746
|
mainDisposer$1 = createEventSubscriber(client, 'onChannelMemberRoleRemoved', 'local.channel-moderator.role-removed', filter);
|
|
6684
6747
|
}
|
|
@@ -6686,6 +6749,39 @@ const onChannelMemberRoleRemoved = (callback) => {
|
|
|
6686
6749
|
return () => dispose$1(callback);
|
|
6687
6750
|
};
|
|
6688
6751
|
|
|
6752
|
+
/**
|
|
6753
|
+
* Fired when a {@link Amity.Channel} has been archived by the active user.
|
|
6754
|
+
*
|
|
6755
|
+
* @param callback The function to call when the event was fired
|
|
6756
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
6757
|
+
*
|
|
6758
|
+
* @category Channel Events
|
|
6759
|
+
*/
|
|
6760
|
+
const onChannelArchived = (callback) => {
|
|
6761
|
+
const client = getActiveClient();
|
|
6762
|
+
const filter = async (payload) => {
|
|
6763
|
+
callback(payload);
|
|
6764
|
+
};
|
|
6765
|
+
return createEventSubscriber(client, 'onChannelArchived', 'local.channel.archived', filter);
|
|
6766
|
+
};
|
|
6767
|
+
|
|
6768
|
+
/**
|
|
6769
|
+
* Fired when a previously archived {@link Amity.Channel} has been unarchived
|
|
6770
|
+
* by the active user.
|
|
6771
|
+
*
|
|
6772
|
+
* @param callback The function to call when the event was fired
|
|
6773
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
6774
|
+
*
|
|
6775
|
+
* @category Channel Events
|
|
6776
|
+
*/
|
|
6777
|
+
const onChannelUnarchived = (callback) => {
|
|
6778
|
+
const client = getActiveClient();
|
|
6779
|
+
const filter = async (payload) => {
|
|
6780
|
+
callback(payload);
|
|
6781
|
+
};
|
|
6782
|
+
return createEventSubscriber(client, 'onChannelUnarchived', 'local.channel.unarchived', filter);
|
|
6783
|
+
};
|
|
6784
|
+
|
|
6689
6785
|
const callbacks = [];
|
|
6690
6786
|
let mainDisposer = null;
|
|
6691
6787
|
const dispose = (cb) => {
|
|
@@ -6799,6 +6895,17 @@ const channelLinkedObject = (channel) => {
|
|
|
6799
6895
|
markAsRead: () => markAsRead(channel.channelInternalId),
|
|
6800
6896
|
previewMembers,
|
|
6801
6897
|
myMembership: (callback) => getMyMembership(channel.channelId, callback),
|
|
6898
|
+
get avatar() {
|
|
6899
|
+
var _a;
|
|
6900
|
+
if (!channel.avatarFileId)
|
|
6901
|
+
return undefined;
|
|
6902
|
+
const avatar = (_a = pullFromCache([
|
|
6903
|
+
'file',
|
|
6904
|
+
'get',
|
|
6905
|
+
`${channel.avatarFileId}`,
|
|
6906
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
6907
|
+
return avatar;
|
|
6908
|
+
},
|
|
6802
6909
|
});
|
|
6803
6910
|
};
|
|
6804
6911
|
|
|
@@ -8161,9 +8268,8 @@ class MessageReadReceiptSyncEngine {
|
|
|
8161
8268
|
// Step 1: Optimistic update of channelUnread.readToSegment to message.segment and update unreadCount value
|
|
8162
8269
|
const cacheKey = ['channelUnread', 'get', channelId];
|
|
8163
8270
|
const channelUnread = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
8164
|
-
if (
|
|
8165
|
-
channelUnread
|
|
8166
|
-
segment > channelUnread.readToSegment) {
|
|
8271
|
+
if (channelUnread &&
|
|
8272
|
+
(typeof channelUnread.readToSegment !== 'number' || segment > channelUnread.readToSegment)) {
|
|
8167
8273
|
channelUnread.readToSegment = segment;
|
|
8168
8274
|
channelUnread.unreadCount = Math.max(channelUnread.lastSegment - segment, 0);
|
|
8169
8275
|
pushToCache(cacheKey, channelUnread);
|
|
@@ -9921,16 +10027,13 @@ const onMessageCreatedMqtt = (callback) => {
|
|
|
9921
10027
|
}
|
|
9922
10028
|
if (client.useLegacyUnreadCount) {
|
|
9923
10029
|
rawPayload.messages.forEach(message => {
|
|
9924
|
-
var _a, _b;
|
|
10030
|
+
var _a, _b, _c;
|
|
9925
10031
|
const channelUnread = (_a = pullFromCache([
|
|
9926
10032
|
'channelUnread',
|
|
9927
10033
|
'get',
|
|
9928
10034
|
message.channelId,
|
|
9929
10035
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
9930
|
-
if (!channelUnread ||
|
|
9931
|
-
channelUnread.lastSegment >= message.segment ||
|
|
9932
|
-
typeof channelUnread.readToSegment !== 'number' ||
|
|
9933
|
-
typeof channelUnread.lastMentionedSegment !== 'number')
|
|
10036
|
+
if (!channelUnread || channelUnread.lastSegment >= message.segment)
|
|
9934
10037
|
return;
|
|
9935
10038
|
const lastSegment = message.segment;
|
|
9936
10039
|
const isMentionedInMessage = (_b = message.mentionedUsers) === null || _b === void 0 ? void 0 : _b.some(mention => {
|
|
@@ -9942,7 +10045,8 @@ const onMessageCreatedMqtt = (callback) => {
|
|
|
9942
10045
|
const lastMentionedSegment = isMentionedInMessage
|
|
9943
10046
|
? message.segment
|
|
9944
10047
|
: channelUnread.lastMentionedSegment;
|
|
9945
|
-
const
|
|
10048
|
+
const readToSegment = (_c = channelUnread.readToSegment) !== null && _c !== void 0 ? _c : 0;
|
|
10049
|
+
const updatedChannelUnread = Object.assign(Object.assign({}, channelUnread), { lastSegment, unreadCount: Math.max(lastSegment - readToSegment, 0), lastMentionedSegment, isMentioned: typeof lastMentionedSegment === 'number' && readToSegment < lastMentionedSegment });
|
|
9946
10050
|
pushToCache(['channelUnread', 'get', message.channelId], updatedChannelUnread);
|
|
9947
10051
|
fireEvent('local.channelUnread.updated', [updatedChannelUnread]);
|
|
9948
10052
|
});
|
|
@@ -10788,6 +10892,140 @@ const setAccessTokenHandler = (accessTokenHandler) => {
|
|
|
10788
10892
|
client.accessTokenHandler = accessTokenHandler;
|
|
10789
10893
|
};
|
|
10790
10894
|
|
|
10895
|
+
function parseRolesFilter(listenFromRoleIds, ignoreFromRoleIds) {
|
|
10896
|
+
if (ignoreFromRoleIds && ignoreFromRoleIds.length > 0) {
|
|
10897
|
+
return { type: 'not', roleIds: ignoreFromRoleIds };
|
|
10898
|
+
}
|
|
10899
|
+
if (listenFromRoleIds && listenFromRoleIds.length > 0) {
|
|
10900
|
+
return { type: exports.NotificationRolesFilterTypeEnum.ONLY, roleIds: listenFromRoleIds };
|
|
10901
|
+
}
|
|
10902
|
+
return { type: exports.NotificationRolesFilterTypeEnum.ALL };
|
|
10903
|
+
}
|
|
10904
|
+
function serializeRolesFilter(rolesFilter) {
|
|
10905
|
+
if ((rolesFilter === null || rolesFilter === void 0 ? void 0 : rolesFilter.type) === exports.NotificationRolesFilterTypeEnum.ONLY) {
|
|
10906
|
+
return { listenFromRoleIds: rolesFilter.roleIds };
|
|
10907
|
+
}
|
|
10908
|
+
return { listenFromRoleIds: [] };
|
|
10909
|
+
}
|
|
10910
|
+
class ChannelNotifications {
|
|
10911
|
+
constructor(channelId) {
|
|
10912
|
+
this.channelId = channelId;
|
|
10913
|
+
}
|
|
10914
|
+
async enable() {
|
|
10915
|
+
const client = getActiveClient();
|
|
10916
|
+
const body = {
|
|
10917
|
+
level: exports.NotificationSettingsLevelEnum.CHANNEL,
|
|
10918
|
+
channelId: this.channelId,
|
|
10919
|
+
isPushNotifiable: true,
|
|
10920
|
+
};
|
|
10921
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
10922
|
+
}
|
|
10923
|
+
async disable() {
|
|
10924
|
+
const client = getActiveClient();
|
|
10925
|
+
const body = {
|
|
10926
|
+
level: exports.NotificationSettingsLevelEnum.CHANNEL,
|
|
10927
|
+
channelId: this.channelId,
|
|
10928
|
+
isPushNotifiable: false,
|
|
10929
|
+
};
|
|
10930
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
10931
|
+
}
|
|
10932
|
+
async getSettings() {
|
|
10933
|
+
const client = getActiveClient();
|
|
10934
|
+
const { data } = await client.http.get(`/api/v3/notification/setting?level=${exports.NotificationSettingsLevelEnum.CHANNEL}&channelId=${encodeURIComponent(this.channelId)}`);
|
|
10935
|
+
return { isEnabled: data.isPushNotifiable };
|
|
10936
|
+
}
|
|
10937
|
+
}
|
|
10938
|
+
class UserNotifications {
|
|
10939
|
+
async enable(modules) {
|
|
10940
|
+
var _a;
|
|
10941
|
+
const client = getActiveClient();
|
|
10942
|
+
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 : [];
|
|
10943
|
+
const body = {
|
|
10944
|
+
level: exports.NotificationSettingsLevelEnum.USER,
|
|
10945
|
+
isPushNotifiable: true,
|
|
10946
|
+
notifiableEvents,
|
|
10947
|
+
};
|
|
10948
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
10949
|
+
}
|
|
10950
|
+
async disableAllNotifications() {
|
|
10951
|
+
const client = getActiveClient();
|
|
10952
|
+
const body = {
|
|
10953
|
+
level: exports.NotificationSettingsLevelEnum.USER,
|
|
10954
|
+
isPushNotifiable: false,
|
|
10955
|
+
notifiableEvents: [],
|
|
10956
|
+
};
|
|
10957
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
10958
|
+
}
|
|
10959
|
+
async getSettings() {
|
|
10960
|
+
var _a;
|
|
10961
|
+
const client = getActiveClient();
|
|
10962
|
+
const { data } = await client.http.get(`/api/v3/notification/setting?level=${exports.NotificationSettingsLevelEnum.USER}`);
|
|
10963
|
+
const validModuleNames = Object.values(exports.UserNotificationModuleNameEnum);
|
|
10964
|
+
const modules = ((_a = data.notifiableEvents) !== null && _a !== void 0 ? _a : [])
|
|
10965
|
+
.filter(e => e.moduleName != null && validModuleNames.includes(e.moduleName))
|
|
10966
|
+
.map(e => ({
|
|
10967
|
+
moduleName: e.moduleName,
|
|
10968
|
+
isEnabled: e.isPushNotifiable,
|
|
10969
|
+
rolesFilter: parseRolesFilter(e.listenFromRoleIds, e.ignoreFromRoleIds),
|
|
10970
|
+
}));
|
|
10971
|
+
return { isEnabled: data.isPushNotifiable, modules };
|
|
10972
|
+
}
|
|
10973
|
+
}
|
|
10974
|
+
class CommunityNotifications {
|
|
10975
|
+
constructor(communityId) {
|
|
10976
|
+
this.communityId = communityId;
|
|
10977
|
+
}
|
|
10978
|
+
async enable(events) {
|
|
10979
|
+
var _a;
|
|
10980
|
+
const client = getActiveClient();
|
|
10981
|
+
const notifiableEvents = (_a = events === null || events === void 0 ? void 0 : events.map(event => (Object.assign({ moduleName: exports.UserNotificationModuleNameEnum.SOCIAL, name: event.eventName, isPushNotifiable: event.isEnabled }, serializeRolesFilter(event.rolesFilter))))) !== null && _a !== void 0 ? _a : [];
|
|
10982
|
+
const body = {
|
|
10983
|
+
level: exports.NotificationSettingsLevelEnum.COMMUNITY,
|
|
10984
|
+
communityId: this.communityId,
|
|
10985
|
+
isPushNotifiable: true,
|
|
10986
|
+
notifiableEvents,
|
|
10987
|
+
};
|
|
10988
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
10989
|
+
}
|
|
10990
|
+
async disable() {
|
|
10991
|
+
const client = getActiveClient();
|
|
10992
|
+
const body = {
|
|
10993
|
+
level: exports.NotificationSettingsLevelEnum.COMMUNITY,
|
|
10994
|
+
communityId: this.communityId,
|
|
10995
|
+
isPushNotifiable: false,
|
|
10996
|
+
notifiableEvents: [],
|
|
10997
|
+
};
|
|
10998
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
10999
|
+
}
|
|
11000
|
+
async getSettings() {
|
|
11001
|
+
var _a;
|
|
11002
|
+
const client = getActiveClient();
|
|
11003
|
+
const { data } = await client.http.get(`/api/v3/notification/setting?level=${exports.NotificationSettingsLevelEnum.COMMUNITY}&communityId=${encodeURIComponent(this.communityId)}`);
|
|
11004
|
+
const validEventNames = Object.values(exports.CommunityNotificationEventNameEnum);
|
|
11005
|
+
const events = ((_a = data.notifiableEvents) !== null && _a !== void 0 ? _a : [])
|
|
11006
|
+
.filter(e => e.name != null && validEventNames.includes(e.name))
|
|
11007
|
+
.map(e => ({
|
|
11008
|
+
eventName: e.name,
|
|
11009
|
+
isEnabled: e.isPushNotifiable,
|
|
11010
|
+
isNetworkEnabled: e.isNetworkEnabled,
|
|
11011
|
+
rolesFilter: parseRolesFilter(e.listenFromRoleIds, e.ignoreFromRoleIds),
|
|
11012
|
+
}));
|
|
11013
|
+
return { isEnabled: data.isPushNotifiable, events };
|
|
11014
|
+
}
|
|
11015
|
+
}
|
|
11016
|
+
class Notifications {
|
|
11017
|
+
user() {
|
|
11018
|
+
return new UserNotifications();
|
|
11019
|
+
}
|
|
11020
|
+
community(communityId) {
|
|
11021
|
+
return new CommunityNotifications(communityId);
|
|
11022
|
+
}
|
|
11023
|
+
channel(channelId) {
|
|
11024
|
+
return new ChannelNotifications(channelId);
|
|
11025
|
+
}
|
|
11026
|
+
}
|
|
11027
|
+
const notifications = () => new Notifications();
|
|
11028
|
+
|
|
10791
11029
|
/**
|
|
10792
11030
|
* ```js
|
|
10793
11031
|
* import { onChannelMarkerFetched } from '@amityco/ts-sdk'
|
|
@@ -11168,6 +11406,8 @@ var index$s = /*#__PURE__*/Object.freeze({
|
|
|
11168
11406
|
getCurrentUserType: getCurrentUserType,
|
|
11169
11407
|
setCurrentUserType: setCurrentUserType,
|
|
11170
11408
|
setAccessTokenHandler: setAccessTokenHandler,
|
|
11409
|
+
getChatSettings: getChatSettings,
|
|
11410
|
+
notifications: notifications,
|
|
11171
11411
|
onConnectionError: onConnectionError,
|
|
11172
11412
|
onClientDisconnected: onClientDisconnected,
|
|
11173
11413
|
onClientBanned: onClientBanned,
|
|
@@ -13203,7 +13443,7 @@ const getWatchSessionStorage = () => {
|
|
|
13203
13443
|
return storageInstance;
|
|
13204
13444
|
};
|
|
13205
13445
|
|
|
13206
|
-
const privateKey = "
|
|
13446
|
+
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=";
|
|
13207
13447
|
/*
|
|
13208
13448
|
* The crypto algorithm used for importing key and signing string
|
|
13209
13449
|
*/
|
|
@@ -14714,6 +14954,11 @@ const addReaction$1 = async (referenceType, referenceId, reactionName, reference
|
|
|
14714
14954
|
});
|
|
14715
14955
|
return true;
|
|
14716
14956
|
}
|
|
14957
|
+
if (referenceType === 'message') {
|
|
14958
|
+
upsertInCache(['message', 'get', referenceId], updatedModel);
|
|
14959
|
+
fireEvent('local.message.updated', { messages: [updatedModel] });
|
|
14960
|
+
return true;
|
|
14961
|
+
}
|
|
14717
14962
|
}
|
|
14718
14963
|
return true;
|
|
14719
14964
|
};
|
|
@@ -14792,7 +15037,7 @@ const removeReaction$1 = async (referenceType, referenceId, reactionName, refere
|
|
|
14792
15037
|
return true;
|
|
14793
15038
|
}
|
|
14794
15039
|
if (referenceType === 'story') {
|
|
14795
|
-
fireEvent('local.story.
|
|
15040
|
+
fireEvent('local.story.reactionRemoved', {
|
|
14796
15041
|
story: updatedModel,
|
|
14797
15042
|
reactor: {
|
|
14798
15043
|
userId: client.userId,
|
|
@@ -14802,6 +15047,11 @@ const removeReaction$1 = async (referenceType, referenceId, reactionName, refere
|
|
|
14802
15047
|
});
|
|
14803
15048
|
return true;
|
|
14804
15049
|
}
|
|
15050
|
+
if (referenceType === 'message') {
|
|
15051
|
+
upsertInCache(['message', 'get', referenceId], updatedModel);
|
|
15052
|
+
fireEvent('local.message.updated', { messages: [updatedModel] });
|
|
15053
|
+
return true;
|
|
15054
|
+
}
|
|
14805
15055
|
}
|
|
14806
15056
|
return true;
|
|
14807
15057
|
};
|
|
@@ -17725,7 +17975,7 @@ const removeReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
17725
17975
|
return true;
|
|
17726
17976
|
}
|
|
17727
17977
|
if (referenceType === 'story') {
|
|
17728
|
-
fireEvent('local.story.
|
|
17978
|
+
fireEvent('local.story.reactionRemoved', {
|
|
17729
17979
|
story: updatedModel,
|
|
17730
17980
|
reactor: {
|
|
17731
17981
|
userId: client.userId,
|
|
@@ -19309,6 +19559,104 @@ const unmuteChannel = async (channelId) => {
|
|
|
19309
19559
|
};
|
|
19310
19560
|
/* end_public_function */
|
|
19311
19561
|
|
|
19562
|
+
/* begin_public_function
|
|
19563
|
+
id: channel.archive
|
|
19564
|
+
*/
|
|
19565
|
+
/**
|
|
19566
|
+
* ```js
|
|
19567
|
+
* import { ChannelRepository } from '@amityco/ts-sdk'
|
|
19568
|
+
* const success = await ChannelRepository.archiveChannel('foobar')
|
|
19569
|
+
* ```
|
|
19570
|
+
*
|
|
19571
|
+
* Archive a {@link Amity.Channel}.
|
|
19572
|
+
*
|
|
19573
|
+
* @param channelId The id of the {@link Amity.Channel} to archive
|
|
19574
|
+
* @returns A success boolean
|
|
19575
|
+
*
|
|
19576
|
+
* @category Channel API
|
|
19577
|
+
* @async
|
|
19578
|
+
*/
|
|
19579
|
+
const archiveChannel = async (channelId) => {
|
|
19580
|
+
const client = getActiveClient();
|
|
19581
|
+
client.log('channel/archiveChannel', channelId);
|
|
19582
|
+
await client.http.post(`/api/v1/archives/channels/${encodeURIComponent(channelId)}`);
|
|
19583
|
+
const archive = {
|
|
19584
|
+
channelId,
|
|
19585
|
+
archivedAt: new Date().toISOString(),
|
|
19586
|
+
};
|
|
19587
|
+
if (client.cache) {
|
|
19588
|
+
pushToCache(['archivedChannel', 'get', getResolver('archivedChannel')(archive)], archive);
|
|
19589
|
+
}
|
|
19590
|
+
fireEvent('local.channel.archived', { archives: [archive] });
|
|
19591
|
+
};
|
|
19592
|
+
/* end_public_function */
|
|
19593
|
+
|
|
19594
|
+
/* begin_public_function
|
|
19595
|
+
id: channel.unarchive
|
|
19596
|
+
*/
|
|
19597
|
+
/**
|
|
19598
|
+
* ```js
|
|
19599
|
+
* import { ChannelRepository } from '@amityco/ts-sdk'
|
|
19600
|
+
* const success = await ChannelRepository.unarchiveChannel('foobar')
|
|
19601
|
+
* ```
|
|
19602
|
+
*
|
|
19603
|
+
* Unarchive a previously archived {@link Amity.Channel}.
|
|
19604
|
+
*
|
|
19605
|
+
* @param channelId The id of the {@link Amity.Channel} to unarchive
|
|
19606
|
+
* @returns A success boolean
|
|
19607
|
+
*
|
|
19608
|
+
* @category Channel API
|
|
19609
|
+
* @async
|
|
19610
|
+
*/
|
|
19611
|
+
const unarchiveChannel = async (channelId) => {
|
|
19612
|
+
var _a;
|
|
19613
|
+
const client = getActiveClient();
|
|
19614
|
+
client.log('channel/unarchiveChannel', channelId);
|
|
19615
|
+
await client.http.delete(`/api/v1/archives/channels/${encodeURIComponent(channelId)}`);
|
|
19616
|
+
const cached = (_a = pullFromCache(['archivedChannel', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
19617
|
+
const archive = cached !== null && cached !== void 0 ? cached : {
|
|
19618
|
+
channelId,
|
|
19619
|
+
archivedAt: new Date().toISOString(),
|
|
19620
|
+
};
|
|
19621
|
+
if (client.cache) {
|
|
19622
|
+
dropFromCache(['archivedChannel', 'get', channelId], true);
|
|
19623
|
+
}
|
|
19624
|
+
fireEvent('local.channel.unarchived', { archives: [archive] });
|
|
19625
|
+
};
|
|
19626
|
+
/* end_public_function */
|
|
19627
|
+
|
|
19628
|
+
/* begin_public_function
|
|
19629
|
+
id: channel.archive.ids
|
|
19630
|
+
*/
|
|
19631
|
+
/**
|
|
19632
|
+
* ```js
|
|
19633
|
+
* import { ChannelRepository } from '@amityco/ts-sdk'
|
|
19634
|
+
* const ids = await ChannelRepository.getArchivedChannelIds()
|
|
19635
|
+
* ```
|
|
19636
|
+
*
|
|
19637
|
+
* @returns A list of archived channel ids sorted by `archivedAt` descending.
|
|
19638
|
+
*
|
|
19639
|
+
* @category Channel API
|
|
19640
|
+
* @async
|
|
19641
|
+
*/
|
|
19642
|
+
const getArchivedChannelIds = async () => {
|
|
19643
|
+
var _a;
|
|
19644
|
+
const client = getActiveClient();
|
|
19645
|
+
client.log('channel/getArchivedChannelIds');
|
|
19646
|
+
const { data: payload } = await client.http.get(`/api/v1/archives/channels`);
|
|
19647
|
+
const archives = (_a = payload.archives) !== null && _a !== void 0 ? _a : [];
|
|
19648
|
+
if (client.cache) {
|
|
19649
|
+
dropFromCache(['archivedChannel', 'get']);
|
|
19650
|
+
archives.forEach(archive => {
|
|
19651
|
+
if (!archive.channelId)
|
|
19652
|
+
return;
|
|
19653
|
+
pushToCache(['archivedChannel', 'get', archive.channelId], archive);
|
|
19654
|
+
});
|
|
19655
|
+
}
|
|
19656
|
+
return archives.map(entry => entry.channelId).filter(channelId => !!channelId);
|
|
19657
|
+
};
|
|
19658
|
+
/* end_public_function */
|
|
19659
|
+
|
|
19312
19660
|
/**
|
|
19313
19661
|
* ```js
|
|
19314
19662
|
* import { onMessageUpdated } from '@amityco/ts-sdk'
|
|
@@ -20687,6 +21035,160 @@ const getMessages = (params, callback, config) => {
|
|
|
20687
21035
|
};
|
|
20688
21036
|
/* end_public_function */
|
|
20689
21037
|
|
|
21038
|
+
class SearchMessagePaginationController extends PaginationController {
|
|
21039
|
+
async getRequest(queryParams, token) {
|
|
21040
|
+
const { query, exactMatch, channelId, messageFeedId, userIds, tags, types, sortBy, orderBy, limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, } = queryParams;
|
|
21041
|
+
const options = token ? { token } : { limit, sortBy, orderBy };
|
|
21042
|
+
const { data: queryResponse } = await this.http.get(`/api/v2/search/messages`, {
|
|
21043
|
+
params: {
|
|
21044
|
+
query,
|
|
21045
|
+
exactMatch,
|
|
21046
|
+
channelId,
|
|
21047
|
+
messageFeedId,
|
|
21048
|
+
userIds,
|
|
21049
|
+
tags,
|
|
21050
|
+
types,
|
|
21051
|
+
options,
|
|
21052
|
+
},
|
|
21053
|
+
});
|
|
21054
|
+
return queryResponse;
|
|
21055
|
+
}
|
|
21056
|
+
}
|
|
21057
|
+
|
|
21058
|
+
class SearchMessageQueryStreamController extends QueryStreamController {
|
|
21059
|
+
constructor(query, cacheKey, notifyChange) {
|
|
21060
|
+
super(query, cacheKey);
|
|
21061
|
+
this.notifyChange = notifyChange;
|
|
21062
|
+
}
|
|
21063
|
+
async saveToMainDB(response) {
|
|
21064
|
+
var _a;
|
|
21065
|
+
const processedPayload = await prepareMessagePayload(response);
|
|
21066
|
+
const client = getActiveClient();
|
|
21067
|
+
const cachedAt = client.cache && Date.now();
|
|
21068
|
+
if (client.cache) {
|
|
21069
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
21070
|
+
if ((_a = response.channels) === null || _a === void 0 ? void 0 : _a.length) {
|
|
21071
|
+
response.channels.forEach(channel => {
|
|
21072
|
+
pushToCache(['channel', 'get', channel.channelId], channel, { cachedAt });
|
|
21073
|
+
});
|
|
21074
|
+
}
|
|
21075
|
+
}
|
|
21076
|
+
}
|
|
21077
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
21078
|
+
var _a, _b;
|
|
21079
|
+
if (refresh) {
|
|
21080
|
+
pushToCache(this.cacheKey, {
|
|
21081
|
+
data: response.messages.map(getResolver('message')),
|
|
21082
|
+
});
|
|
21083
|
+
return;
|
|
21084
|
+
}
|
|
21085
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
21086
|
+
const existing = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
21087
|
+
const incoming = response.messages.map(getResolver('message'));
|
|
21088
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: direction === "prev" /* Amity.LiveCollectionPageDirection.PREV */
|
|
21089
|
+
? [...new Set([...incoming, ...existing])]
|
|
21090
|
+
: [...new Set([...existing, ...incoming])] }));
|
|
21091
|
+
}
|
|
21092
|
+
}
|
|
21093
|
+
|
|
21094
|
+
class SearchMessageLiveCollectionController extends LiveCollectionController {
|
|
21095
|
+
constructor(query, callback) {
|
|
21096
|
+
const queryStreamId = hash__default["default"](query);
|
|
21097
|
+
const cacheKey = ['message', 'search', queryStreamId];
|
|
21098
|
+
const paginationController = new SearchMessagePaginationController(query);
|
|
21099
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
21100
|
+
this.queryStreamController = new SearchMessageQueryStreamController(query, this.cacheKey, this.notifyChange.bind(this));
|
|
21101
|
+
this.callback = callback.bind(this);
|
|
21102
|
+
this.loadPage({ initial: true });
|
|
21103
|
+
}
|
|
21104
|
+
startSubscription() {
|
|
21105
|
+
return [];
|
|
21106
|
+
}
|
|
21107
|
+
notifyChange({ origin, loading, error }) {
|
|
21108
|
+
var _a, _b;
|
|
21109
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
21110
|
+
if (!collection)
|
|
21111
|
+
return;
|
|
21112
|
+
const data = (_b = collection.data
|
|
21113
|
+
.map(messageId => getMessageFromMainDB(messageId))
|
|
21114
|
+
.filter(isNonNullable)
|
|
21115
|
+
.map(message => LinkedObject.message(message))) !== null && _b !== void 0 ? _b : [];
|
|
21116
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
21117
|
+
return;
|
|
21118
|
+
this.callback({
|
|
21119
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
21120
|
+
data,
|
|
21121
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
21122
|
+
loading,
|
|
21123
|
+
error,
|
|
21124
|
+
});
|
|
21125
|
+
}
|
|
21126
|
+
setup() {
|
|
21127
|
+
var _a;
|
|
21128
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
21129
|
+
if (!collection) {
|
|
21130
|
+
pushToCache(this.cacheKey, {
|
|
21131
|
+
data: [],
|
|
21132
|
+
params: {},
|
|
21133
|
+
});
|
|
21134
|
+
}
|
|
21135
|
+
}
|
|
21136
|
+
async persistModel(response) {
|
|
21137
|
+
await this.queryStreamController.saveToMainDB(response);
|
|
21138
|
+
}
|
|
21139
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
21140
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
21141
|
+
}
|
|
21142
|
+
}
|
|
21143
|
+
|
|
21144
|
+
/* begin_public_function
|
|
21145
|
+
id: message.search
|
|
21146
|
+
*/
|
|
21147
|
+
/**
|
|
21148
|
+
* ```js
|
|
21149
|
+
* import { MessageRepository } from '@amityco/ts-sdk';
|
|
21150
|
+
*
|
|
21151
|
+
* let messages = [];
|
|
21152
|
+
*
|
|
21153
|
+
* const unsubscribe = MessageRepository.searchMessage(
|
|
21154
|
+
* { query: 'hello' },
|
|
21155
|
+
* response => merge(messages, response.data),
|
|
21156
|
+
* );
|
|
21157
|
+
* ```
|
|
21158
|
+
*
|
|
21159
|
+
* Live collection of {@link Amity.Message}s matching the search query. Backed
|
|
21160
|
+
* by `GET /api/v2/search/messages`. The first emission delivers the first
|
|
21161
|
+
* page; pagination is driven by `response.onNextPage()`.
|
|
21162
|
+
*
|
|
21163
|
+
* @param params Search parameters. `query` is required.
|
|
21164
|
+
* @param callback Called whenever new data are available.
|
|
21165
|
+
* @returns An {@link Amity.Unsubscriber} function to stop observing.
|
|
21166
|
+
*
|
|
21167
|
+
* @category Message Live Collection
|
|
21168
|
+
*/
|
|
21169
|
+
const searchMessage = (params, callback) => {
|
|
21170
|
+
if (!params.query || params.query.trim().length === 0) {
|
|
21171
|
+
throw new Error('Query is required for message search');
|
|
21172
|
+
}
|
|
21173
|
+
const { log, cache } = getActiveClient();
|
|
21174
|
+
if (!cache) {
|
|
21175
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
21176
|
+
}
|
|
21177
|
+
const timestamp = Date.now();
|
|
21178
|
+
log(`searchMessage(tmpid: ${timestamp}) > listen`);
|
|
21179
|
+
const controller = new SearchMessageLiveCollectionController(params, callback);
|
|
21180
|
+
const disposers = controller.startSubscription();
|
|
21181
|
+
const cacheKey = controller.getCacheKey();
|
|
21182
|
+
disposers.push(() => {
|
|
21183
|
+
dropFromCache(cacheKey);
|
|
21184
|
+
});
|
|
21185
|
+
return () => {
|
|
21186
|
+
log(`searchMessage(tmpid: ${timestamp}) > dispose`);
|
|
21187
|
+
disposers.forEach(fn => fn());
|
|
21188
|
+
};
|
|
21189
|
+
};
|
|
21190
|
+
/* end_public_function */
|
|
21191
|
+
|
|
20690
21192
|
var index$n = /*#__PURE__*/Object.freeze({
|
|
20691
21193
|
__proto__: null,
|
|
20692
21194
|
createMessage: createMessage,
|
|
@@ -20712,6 +21214,7 @@ var index$n = /*#__PURE__*/Object.freeze({
|
|
|
20712
21214
|
onMessageFetched: onMessageFetched,
|
|
20713
21215
|
getMessage: getMessage,
|
|
20714
21216
|
getMessages: getMessages,
|
|
21217
|
+
searchMessage: searchMessage,
|
|
20715
21218
|
convertFromRaw: convertFromRaw$1,
|
|
20716
21219
|
prepareMessagePayload: prepareMessagePayload,
|
|
20717
21220
|
convertParams: convertParams,
|
|
@@ -21559,6 +22062,7 @@ class ChannelQueryStreamController extends QueryStreamController {
|
|
|
21559
22062
|
"onCreate" /* Amity.ChannelActionType.OnCreate */,
|
|
21560
22063
|
"onJoin" /* Amity.ChannelActionType.OnJoin */,
|
|
21561
22064
|
"onResolveChannel" /* Amity.ChannelActionType.OnResolveChannel */,
|
|
22065
|
+
"onUnarchived" /* Amity.ChannelActionType.OnUnarchived */,
|
|
21562
22066
|
].includes(action)) {
|
|
21563
22067
|
if (Array.isArray(payload)) {
|
|
21564
22068
|
collection.data = [
|
|
@@ -21568,6 +22072,12 @@ class ChannelQueryStreamController extends QueryStreamController {
|
|
|
21568
22072
|
else
|
|
21569
22073
|
collection.data = [...new Set([payload.channelInternalId, ...collection.data])];
|
|
21570
22074
|
}
|
|
22075
|
+
if (action === "onArchived" /* Amity.ChannelActionType.OnArchived */) {
|
|
22076
|
+
const ids = Array.isArray(payload)
|
|
22077
|
+
? payload.map(getResolver('channel'))
|
|
22078
|
+
: [getResolver('channel')(payload)];
|
|
22079
|
+
collection.data = collection.data.filter(channelInternalId => !ids.includes(channelInternalId));
|
|
22080
|
+
}
|
|
21571
22081
|
pushToCache(this.cacheKey, collection);
|
|
21572
22082
|
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
21573
22083
|
};
|
|
@@ -21834,6 +22344,32 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
21834
22344
|
},
|
|
21835
22345
|
{ fn: onChannelMemberAdded, action: "onMemberAdded" /* Amity.ChannelActionType.OnMemberAdded */ },
|
|
21836
22346
|
{ fn: onChannelMemberRemoved, action: "onMemberRemoved" /* Amity.ChannelActionType.OnMemberRemoved */ },
|
|
22347
|
+
{
|
|
22348
|
+
fn: (reactor) => onChannelArchived(payload => {
|
|
22349
|
+
const channels = payload.archives
|
|
22350
|
+
.map(archive => {
|
|
22351
|
+
var _a;
|
|
22352
|
+
return (_a = pullFromCache(['channel', 'get', archive.channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
22353
|
+
})
|
|
22354
|
+
.filter((c) => Boolean(c));
|
|
22355
|
+
if (channels.length > 0)
|
|
22356
|
+
reactor(channels);
|
|
22357
|
+
}),
|
|
22358
|
+
action: "onArchived" /* Amity.ChannelActionType.OnArchived */,
|
|
22359
|
+
},
|
|
22360
|
+
{
|
|
22361
|
+
fn: (reactor) => onChannelUnarchived(payload => {
|
|
22362
|
+
const channels = payload.archives
|
|
22363
|
+
.map(archive => {
|
|
22364
|
+
var _a;
|
|
22365
|
+
return (_a = pullFromCache(['channel', 'get', archive.channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
22366
|
+
})
|
|
22367
|
+
.filter((c) => Boolean(c));
|
|
22368
|
+
if (channels.length > 0)
|
|
22369
|
+
reactor(channels);
|
|
22370
|
+
}),
|
|
22371
|
+
action: "onUnarchived" /* Amity.ChannelActionType.OnUnarchived */,
|
|
22372
|
+
},
|
|
21837
22373
|
{
|
|
21838
22374
|
fn: convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel'),
|
|
21839
22375
|
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
@@ -22187,6 +22723,192 @@ const getTotalChannelsUnread = (callback) => {
|
|
|
22187
22723
|
};
|
|
22188
22724
|
};
|
|
22189
22725
|
|
|
22726
|
+
class ArchivedChannelPaginationController extends PaginationController {
|
|
22727
|
+
async getRequest(queryParams, token) {
|
|
22728
|
+
var _a, _b;
|
|
22729
|
+
const limit = (_a = queryParams.limit) !== null && _a !== void 0 ? _a : COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
22730
|
+
const pageIndex = token ? Number.parseInt(token, 10) : 0;
|
|
22731
|
+
if (pageIndex === 0) {
|
|
22732
|
+
await getArchivedChannelIds();
|
|
22733
|
+
}
|
|
22734
|
+
const cached = (_b = queryCache(['archivedChannel', 'get'])) !== null && _b !== void 0 ? _b : [];
|
|
22735
|
+
const archives = cached
|
|
22736
|
+
.map(entry => entry.data)
|
|
22737
|
+
.slice()
|
|
22738
|
+
.sort((a, b) => Number(new Date(b.archivedAt)) - Number(new Date(a.archivedAt)));
|
|
22739
|
+
const start = pageIndex * limit;
|
|
22740
|
+
const end = start + limit;
|
|
22741
|
+
const slice = archives.slice(start, end);
|
|
22742
|
+
const hasMore = end < archives.length;
|
|
22743
|
+
if (slice.length > 0) {
|
|
22744
|
+
await getChannelByIds$1(slice.map(archive => archive.channelId));
|
|
22745
|
+
}
|
|
22746
|
+
return {
|
|
22747
|
+
archives: slice,
|
|
22748
|
+
paging: {
|
|
22749
|
+
next: hasMore ? String(pageIndex + 1) : undefined,
|
|
22750
|
+
previous: undefined,
|
|
22751
|
+
},
|
|
22752
|
+
};
|
|
22753
|
+
}
|
|
22754
|
+
}
|
|
22755
|
+
|
|
22756
|
+
class ArchivedChannelQueryStreamController extends QueryStreamController {
|
|
22757
|
+
constructor(query, cacheKey, notifyChange) {
|
|
22758
|
+
super(query, cacheKey);
|
|
22759
|
+
this.notifyChange = notifyChange;
|
|
22760
|
+
}
|
|
22761
|
+
async saveToMainDB(_response) {
|
|
22762
|
+
//
|
|
22763
|
+
}
|
|
22764
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
22765
|
+
var _a, _b;
|
|
22766
|
+
const channelIds = response.archives.map(archive => archive.channelId);
|
|
22767
|
+
if (refresh) {
|
|
22768
|
+
pushToCache(this.cacheKey, {
|
|
22769
|
+
data: channelIds,
|
|
22770
|
+
params: {},
|
|
22771
|
+
});
|
|
22772
|
+
return;
|
|
22773
|
+
}
|
|
22774
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22775
|
+
const existing = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
22776
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: direction === "prev" /* Amity.LiveCollectionPageDirection.PREV */
|
|
22777
|
+
? [...new Set([...channelIds, ...existing])]
|
|
22778
|
+
: [...new Set([...existing, ...channelIds])] }));
|
|
22779
|
+
}
|
|
22780
|
+
reactor(action) {
|
|
22781
|
+
return (channelIds) => {
|
|
22782
|
+
var _a;
|
|
22783
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22784
|
+
if (!collection)
|
|
22785
|
+
return;
|
|
22786
|
+
if (action === "onArchived" /* Amity.ChannelActionType.OnArchived */) {
|
|
22787
|
+
const filtered = collection.data.filter(id => !channelIds.includes(id));
|
|
22788
|
+
collection.data = [...channelIds, ...filtered];
|
|
22789
|
+
}
|
|
22790
|
+
if (action === "onUnarchived" /* Amity.ChannelActionType.OnUnarchived */ ||
|
|
22791
|
+
action === "onDelete" /* Amity.ChannelActionType.OnDelete */) {
|
|
22792
|
+
collection.data = collection.data.filter(id => !channelIds.includes(id));
|
|
22793
|
+
}
|
|
22794
|
+
pushToCache(this.cacheKey, collection);
|
|
22795
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
22796
|
+
};
|
|
22797
|
+
}
|
|
22798
|
+
subscribeRTE(createSubscriber) {
|
|
22799
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
22800
|
+
}
|
|
22801
|
+
}
|
|
22802
|
+
|
|
22803
|
+
class ArchivedChannelLiveCollectionController extends LiveCollectionController {
|
|
22804
|
+
constructor(query, callback) {
|
|
22805
|
+
const queryStreamId = hash__default["default"](query);
|
|
22806
|
+
const cacheKey = ['archivedChannel', 'collection', queryStreamId];
|
|
22807
|
+
const paginationController = new ArchivedChannelPaginationController(query);
|
|
22808
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
22809
|
+
this.queryStreamController = new ArchivedChannelQueryStreamController(query, this.cacheKey, this.notifyChange.bind(this));
|
|
22810
|
+
this.callback = callback.bind(this);
|
|
22811
|
+
this.loadPage({ initial: true });
|
|
22812
|
+
}
|
|
22813
|
+
setup() {
|
|
22814
|
+
var _a;
|
|
22815
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22816
|
+
if (!collection) {
|
|
22817
|
+
pushToCache(this.cacheKey, {
|
|
22818
|
+
data: [],
|
|
22819
|
+
params: {},
|
|
22820
|
+
});
|
|
22821
|
+
}
|
|
22822
|
+
}
|
|
22823
|
+
async persistModel(response) {
|
|
22824
|
+
await this.queryStreamController.saveToMainDB(response);
|
|
22825
|
+
}
|
|
22826
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
22827
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
22828
|
+
}
|
|
22829
|
+
startSubscription() {
|
|
22830
|
+
return this.queryStreamController.subscribeRTE([
|
|
22831
|
+
{
|
|
22832
|
+
fn: reactor => onChannelArchived(payload => reactor(payload.archives.map(archive => archive.channelId))),
|
|
22833
|
+
action: "onArchived" /* Amity.ChannelActionType.OnArchived */,
|
|
22834
|
+
},
|
|
22835
|
+
{
|
|
22836
|
+
fn: reactor => onChannelUnarchived(payload => reactor(payload.archives.map(archive => archive.channelId))),
|
|
22837
|
+
action: "onUnarchived" /* Amity.ChannelActionType.OnUnarchived */,
|
|
22838
|
+
},
|
|
22839
|
+
{
|
|
22840
|
+
fn: reactor => onChannelUpdated(channel => reactor([channel.channelId])),
|
|
22841
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
22842
|
+
},
|
|
22843
|
+
{
|
|
22844
|
+
fn: reactor => onChannelDeleted(channel => reactor([channel.channelId])),
|
|
22845
|
+
action: "onDelete" /* Amity.ChannelActionType.OnDelete */,
|
|
22846
|
+
},
|
|
22847
|
+
]);
|
|
22848
|
+
}
|
|
22849
|
+
notifyChange({ origin, loading, error }) {
|
|
22850
|
+
var _a, _b;
|
|
22851
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22852
|
+
if (!collection)
|
|
22853
|
+
return;
|
|
22854
|
+
const data = (_b = collection.data
|
|
22855
|
+
.map(channelId => pullFromCache(['channel', 'get', channelId]))
|
|
22856
|
+
.filter((entry) => Boolean(entry))
|
|
22857
|
+
.map(({ data: channel }) => channel)
|
|
22858
|
+
.map(constructChannelObject)) !== null && _b !== void 0 ? _b : [];
|
|
22859
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
22860
|
+
return;
|
|
22861
|
+
this.callback({
|
|
22862
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
22863
|
+
data,
|
|
22864
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
22865
|
+
loading,
|
|
22866
|
+
error,
|
|
22867
|
+
});
|
|
22868
|
+
}
|
|
22869
|
+
}
|
|
22870
|
+
|
|
22871
|
+
/* begin_public_function
|
|
22872
|
+
id: channel.archive.collection
|
|
22873
|
+
*/
|
|
22874
|
+
/**
|
|
22875
|
+
* ```js
|
|
22876
|
+
* import { ChannelRepository } from '@amityco/ts-sdk'
|
|
22877
|
+
*
|
|
22878
|
+
* let channels = []
|
|
22879
|
+
* const unsub = ChannelRepository.getArchivedChannels(params, response => merge(channels, response.data))
|
|
22880
|
+
* ```
|
|
22881
|
+
*
|
|
22882
|
+
* Live collection of {@link Amity.Channel}s archived by the active user.
|
|
22883
|
+
*
|
|
22884
|
+
* @param params Live collection parameters (only `limit` is honored; the
|
|
22885
|
+
* archive list takes no other filters).
|
|
22886
|
+
* @param callback the function to call when new data are available
|
|
22887
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to
|
|
22888
|
+
* stop observing.
|
|
22889
|
+
*
|
|
22890
|
+
* @category Channel Live Collection
|
|
22891
|
+
*/
|
|
22892
|
+
const getArchivedChannels = (params, callback) => {
|
|
22893
|
+
const { log, cache } = getActiveClient();
|
|
22894
|
+
if (!cache) {
|
|
22895
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
22896
|
+
}
|
|
22897
|
+
const timestamp = Date.now();
|
|
22898
|
+
log(`getArchivedChannels(tmpid: ${timestamp}) > listen`);
|
|
22899
|
+
const controller = new ArchivedChannelLiveCollectionController(params, callback);
|
|
22900
|
+
const disposers = controller.startSubscription();
|
|
22901
|
+
const cacheKey = controller.getCacheKey();
|
|
22902
|
+
disposers.push(() => {
|
|
22903
|
+
dropFromCache(cacheKey);
|
|
22904
|
+
});
|
|
22905
|
+
return () => {
|
|
22906
|
+
log(`getArchivedChannels(tmpid: ${timestamp}) > dispose`);
|
|
22907
|
+
disposers.forEach(fn => fn());
|
|
22908
|
+
};
|
|
22909
|
+
};
|
|
22910
|
+
/* end_public_function */
|
|
22911
|
+
|
|
22190
22912
|
/* begin_public_function
|
|
22191
22913
|
id: channel.member.add
|
|
22192
22914
|
*/
|
|
@@ -22318,7 +23040,9 @@ class ChannelMemberQueryStreamController extends QueryStreamController {
|
|
|
22318
23040
|
channelId: this.query.channelId,
|
|
22319
23041
|
userId: channelMember.userId,
|
|
22320
23042
|
});
|
|
22321
|
-
|
|
23043
|
+
const membershipFilter = this.query.memberships;
|
|
23044
|
+
const isInFilter = !membershipFilter || membershipFilter.includes(channelMember.membership);
|
|
23045
|
+
if (channelMember.membership === 'none' || !isInFilter) {
|
|
22322
23046
|
collection.data = collection.data.filter(m => m !== channelMemberCacheId);
|
|
22323
23047
|
}
|
|
22324
23048
|
else if (!collection.data.includes(channelMemberCacheId)) {
|
|
@@ -22654,6 +23378,7 @@ const banMembers$1 = async (channelId, userIds) => {
|
|
|
22654
23378
|
const cachedAt = client.cache && Date.now();
|
|
22655
23379
|
if (client.cache)
|
|
22656
23380
|
ingestInCache(preparedPayload, { cachedAt });
|
|
23381
|
+
fireEvent('channel.banned', payload);
|
|
22657
23382
|
return {
|
|
22658
23383
|
data: channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(user => user.membership === 'banned'),
|
|
22659
23384
|
cachedAt,
|
|
@@ -22688,6 +23413,7 @@ const unbanMembers$1 = async (channelId, userIds) => {
|
|
|
22688
23413
|
const cachedAt = client.cache && Date.now();
|
|
22689
23414
|
if (client.cache)
|
|
22690
23415
|
ingestInCache(preparedPayload, { cachedAt });
|
|
23416
|
+
fireEvent('channel.unbanned', payload);
|
|
22691
23417
|
const { channelUsers } = preparedPayload;
|
|
22692
23418
|
return {
|
|
22693
23419
|
data: channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(user => user.membership === 'member'),
|
|
@@ -22716,6 +23442,7 @@ const MUTE_FOREVER = -1;
|
|
|
22716
23442
|
* @async
|
|
22717
23443
|
* */
|
|
22718
23444
|
const muteMembers = async (channelId, userIds, mutePeriod = MUTE_FOREVER) => {
|
|
23445
|
+
var _a;
|
|
22719
23446
|
const client = getActiveClient();
|
|
22720
23447
|
client.log('channel/muteMembers', { userIds, channelId, mutePeriod });
|
|
22721
23448
|
const { data } = await client.http.put(`/api/v2/channel/${channelId}/users/mute`, {
|
|
@@ -22723,6 +23450,15 @@ const muteMembers = async (channelId, userIds, mutePeriod = MUTE_FOREVER) => {
|
|
|
22723
23450
|
mutePeriod: mutePeriod === MUTE_FOREVER ? mutePeriod : mutePeriod * 1000,
|
|
22724
23451
|
});
|
|
22725
23452
|
const { success } = data;
|
|
23453
|
+
const muteTimeout = mutePeriod === MUTE_FOREVER
|
|
23454
|
+
? new Date('9999-12-31T23:59:59.999Z').toISOString()
|
|
23455
|
+
: new Date(Date.now() + mutePeriod * 1000).toISOString();
|
|
23456
|
+
fireEvent('channel.setMutedUsers', {
|
|
23457
|
+
channelId,
|
|
23458
|
+
userIds,
|
|
23459
|
+
muteTimeout,
|
|
23460
|
+
actor: (_a = client.userId) !== null && _a !== void 0 ? _a : '',
|
|
23461
|
+
});
|
|
22726
23462
|
return success;
|
|
22727
23463
|
};
|
|
22728
23464
|
/* end_public_function */
|
|
@@ -22745,6 +23481,7 @@ const muteMembers = async (channelId, userIds, mutePeriod = MUTE_FOREVER) => {
|
|
|
22745
23481
|
* @async
|
|
22746
23482
|
* */
|
|
22747
23483
|
const unmuteMembers = async (channelId, userIds) => {
|
|
23484
|
+
var _a;
|
|
22748
23485
|
const client = getActiveClient();
|
|
22749
23486
|
client.log('channel/unmuteMembers', { userIds, channelId });
|
|
22750
23487
|
const { data } = await client.http.put(`/api/v2/channel/${encodeURIComponent(channelId)}/users/mute`, {
|
|
@@ -22752,6 +23489,12 @@ const unmuteMembers = async (channelId, userIds) => {
|
|
|
22752
23489
|
mutePeriod: 0,
|
|
22753
23490
|
});
|
|
22754
23491
|
const { success } = data;
|
|
23492
|
+
fireEvent('channel.setMutedUsers', {
|
|
23493
|
+
channelId,
|
|
23494
|
+
userIds,
|
|
23495
|
+
muteTimeout: new Date(0).toISOString(),
|
|
23496
|
+
actor: (_a = client.userId) !== null && _a !== void 0 ? _a : '',
|
|
23497
|
+
});
|
|
22755
23498
|
return success;
|
|
22756
23499
|
};
|
|
22757
23500
|
/* end_public_function */
|
|
@@ -22778,6 +23521,9 @@ var index$j = /*#__PURE__*/Object.freeze({
|
|
|
22778
23521
|
leaveChannel: leaveChannel,
|
|
22779
23522
|
muteChannel: muteChannel,
|
|
22780
23523
|
unmuteChannel: unmuteChannel,
|
|
23524
|
+
archiveChannel: archiveChannel,
|
|
23525
|
+
unarchiveChannel: unarchiveChannel,
|
|
23526
|
+
getArchivedChannelIds: getArchivedChannelIds,
|
|
22781
23527
|
onChannelCreated: onChannelCreated,
|
|
22782
23528
|
onChannelUpdated: onChannelUpdated,
|
|
22783
23529
|
onChannelDeleted: onChannelDeleted,
|
|
@@ -22790,9 +23536,12 @@ var index$j = /*#__PURE__*/Object.freeze({
|
|
|
22790
23536
|
onChannelMemberUnbanned: onChannelMemberUnbanned,
|
|
22791
23537
|
onChannelMemberRoleAdded: onChannelMemberRoleAdded,
|
|
22792
23538
|
onChannelMemberRoleRemoved: onChannelMemberRoleRemoved,
|
|
23539
|
+
onChannelArchived: onChannelArchived,
|
|
23540
|
+
onChannelUnarchived: onChannelUnarchived,
|
|
22793
23541
|
getChannel: getChannel,
|
|
22794
23542
|
getChannels: getChannels,
|
|
22795
23543
|
getTotalChannelsUnread: getTotalChannelsUnread,
|
|
23544
|
+
getArchivedChannels: getArchivedChannels,
|
|
22796
23545
|
MARKER_INCLUDED_CHANNEL_TYPE: MARKER_INCLUDED_CHANNEL_TYPE,
|
|
22797
23546
|
isUnreadCountSupport: isUnreadCountSupport,
|
|
22798
23547
|
convertFromRaw: convertFromRaw,
|