@amityco/ts-sdk 7.6.1-1a687cb5.0 → 7.6.1-2841ad2c.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 +6 -1
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +26 -1
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +6 -0
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/content.d.ts +2 -8
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/@types/domains/feed.d.ts +1 -2
- package/dist/@types/domains/feed.d.ts.map +1 -1
- package/dist/@types/domains/file.d.ts +1 -3
- package/dist/@types/domains/file.d.ts.map +1 -1
- package/dist/@types/domains/liveReaction.d.ts +20 -0
- package/dist/@types/domains/liveReaction.d.ts.map +1 -0
- package/dist/@types/domains/post.d.ts +3 -3
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/stream.d.ts +9 -1
- package/dist/@types/domains/stream.d.ts.map +1 -1
- package/dist/@types/index.d.ts +1 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/channelRepository/api/createChannel.d.ts +3 -1
- package/dist/channelRepository/api/createChannel.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/events/index.d.ts +1 -1
- package/dist/channelRepository/events/index.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelSetMuted.d.ts +2 -0
- package/dist/channelRepository/events/onChannelSetMuted.d.ts.map +1 -0
- package/dist/channelRepository/events/onChannelSetUserMuted.d.ts +2 -0
- package/dist/channelRepository/events/onChannelSetUserMuted.d.ts.map +1 -0
- package/dist/channelRepository/internalApi/getChannel.d.ts.map +1 -1
- package/dist/channelRepository/internalApi/getMyMembership.d.ts +11 -0
- package/dist/channelRepository/internalApi/getMyMembership.d.ts.map +1 -0
- package/dist/channelRepository/observers/getChannels/ChannelLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/observers/getMyMembership.d.ts +2 -0
- package/dist/channelRepository/observers/getMyMembership.d.ts.map +1 -0
- package/dist/client/api/login.d.ts.map +1 -1
- package/dist/communityRepository/api/getCommunity.d.ts +1 -1
- package/dist/communityRepository/api/getCommunity.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/subscription.d.ts +2 -1
- package/dist/core/subscription.d.ts.map +1 -1
- package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts +1 -1
- package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +1 -1
- package/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
- package/dist/fileRepository/api/index.d.ts +0 -1
- package/dist/fileRepository/api/index.d.ts.map +1 -1
- package/dist/index.cjs.js +6323 -5744
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +6258 -5681
- package/dist/index.umd.js +3 -3
- package/dist/liveReactionRepository/api/createReaction.d.ts +20 -0
- package/dist/liveReactionRepository/api/createReaction.d.ts.map +1 -0
- package/dist/liveReactionRepository/api/index.d.ts +2 -0
- package/dist/liveReactionRepository/api/index.d.ts.map +1 -0
- package/dist/liveReactionRepository/events/index.d.ts +2 -0
- package/dist/liveReactionRepository/events/index.d.ts.map +1 -0
- package/dist/liveReactionRepository/events/onLiveReactionCreated.d.ts +17 -0
- package/dist/liveReactionRepository/events/onLiveReactionCreated.d.ts.map +1 -0
- package/dist/liveReactionRepository/events/onLiveReactionCreatedLocal.d.ts +17 -0
- package/dist/liveReactionRepository/events/onLiveReactionCreatedLocal.d.ts.map +1 -0
- package/dist/liveReactionRepository/index.d.ts +4 -0
- package/dist/liveReactionRepository/index.d.ts.map +1 -0
- package/dist/liveReactionRepository/internalApi/createLiveReaction.d.ts +20 -0
- package/dist/liveReactionRepository/internalApi/createLiveReaction.d.ts.map +1 -0
- package/dist/liveReactionRepository/observers/getReactions.d.ts +19 -0
- package/dist/liveReactionRepository/observers/getReactions.d.ts.map +1 -0
- package/dist/liveReactionRepository/observers/index.d.ts +2 -0
- package/dist/liveReactionRepository/observers/index.d.ts.map +1 -0
- package/dist/liveReactionRepository/service/ReactionSyncEngine.d.ts +26 -0
- package/dist/liveReactionRepository/service/ReactionSyncEngine.d.ts.map +1 -0
- package/dist/liveReactionRepository/utils/ReactionSyncEngineOnLoginHandler.d.ts +3 -0
- package/dist/liveReactionRepository/utils/ReactionSyncEngineOnLoginHandler.d.ts.map +1 -0
- package/dist/liveStreamPlayer/utils/eventRegister.d.ts +2 -1
- package/dist/liveStreamPlayer/utils/eventRegister.d.ts.map +1 -1
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +4 -0
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts.map +1 -1
- package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
- package/dist/messageRepository/api/deleteMessage.d.ts.map +1 -1
- package/dist/messageRepository/observers/getMessage.d.ts.map +1 -1
- package/dist/messageRepository/observers/getMessages/MessageLiveCollectionController.d.ts.map +1 -1
- package/dist/messageRepository/observers/getMessages/MessageQueryStreamController.d.ts.map +1 -1
- package/dist/postRepository/api/createPost.d.ts.map +1 -1
- package/dist/postRepository/api/index.d.ts +0 -1
- package/dist/postRepository/api/index.d.ts.map +1 -1
- package/dist/postRepository/utils/payload.d.ts.map +1 -1
- package/dist/streamRepository/api/createStream.d.ts +1 -1
- package/dist/streamRepository/api/createStream.d.ts.map +1 -1
- package/dist/streamRepository/api/editStream.d.ts +18 -0
- package/dist/streamRepository/api/editStream.d.ts.map +1 -0
- package/dist/streamRepository/api/index.d.ts +1 -0
- package/dist/streamRepository/api/index.d.ts.map +1 -1
- package/dist/streamRepository/api/updateStream.d.ts +4 -1
- package/dist/streamRepository/api/updateStream.d.ts.map +1 -1
- package/dist/streamRepository/events/index.d.ts +2 -0
- package/dist/streamRepository/events/index.d.ts.map +1 -1
- package/dist/streamRepository/events/onStreamViewerBanned.d.ts +17 -0
- package/dist/streamRepository/events/onStreamViewerBanned.d.ts.map +1 -0
- package/dist/streamRepository/events/onStreamViewerUnbanned.d.ts +17 -0
- package/dist/streamRepository/events/onStreamViewerUnbanned.d.ts.map +1 -0
- package/dist/streamRepository/internalApi/getLiveChat.d.ts +16 -0
- package/dist/streamRepository/internalApi/getLiveChat.d.ts.map +1 -0
- package/dist/streamRepository/internalApi/getStream.d.ts +2 -2
- package/dist/streamRepository/internalApi/getStream.d.ts.map +1 -1
- package/dist/streamRepository/observers/getStreamById.d.ts.map +1 -1
- package/dist/streamRepository/observers/getStreams/GetStreamsLiveCollectionController.d.ts.map +1 -1
- package/dist/utils/linkedObject/channelLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/streamLinkedObject.d.ts.map +1 -1
- package/dist/utils/postTypePredicate.d.ts +5 -4
- package/dist/utils/postTypePredicate.d.ts.map +1 -1
- package/dist/utils/tests/dummy/comment.d.ts +1 -1
- package/package.json +1 -1
- package/src/@types/core/events.ts +10 -1
- package/src/@types/core/payload.ts +33 -1
- package/src/@types/domains/channel.ts +9 -0
- package/src/@types/domains/content.ts +0 -10
- package/src/@types/domains/feed.ts +1 -2
- package/src/@types/domains/file.ts +0 -5
- package/src/@types/domains/liveReaction.ts +25 -0
- package/src/@types/domains/post.ts +4 -4
- package/src/@types/domains/stream.ts +13 -1
- package/src/@types/index.ts +1 -0
- package/src/channelRepository/api/createChannel.ts +11 -8
- package/src/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.ts +2 -0
- package/src/channelRepository/events/index.ts +1 -1
- package/src/channelRepository/events/onChannelSetMuted.ts +48 -0
- package/src/channelRepository/events/onChannelSetUserMuted.ts +65 -0
- package/src/channelRepository/internalApi/getChannel.ts +0 -1
- package/src/channelRepository/internalApi/getMyMembership.ts +37 -0
- package/src/channelRepository/observers/getChannel.ts +2 -2
- package/src/channelRepository/observers/getChannels/ChannelLiveCollectionController.ts +2 -2
- package/src/channelRepository/observers/getMyMembership.ts +98 -0
- package/src/channelRepository/utils/constructChannelObject.ts +2 -2
- package/src/client/api/login.ts +2 -0
- package/src/communityRepository/api/getCommunity.ts +9 -0
- package/src/core/events.ts +4 -1
- package/src/core/subscription.ts +10 -6
- package/src/feedRepository/api/getCustomRankingGlobalFeed.ts +1 -1
- package/src/feedRepository/api/queryGlobalFeed.ts +1 -3
- package/src/fileRepository/api/index.ts +0 -1
- package/src/index.ts +2 -0
- package/src/liveReactionRepository/api/createReaction.ts +58 -0
- package/src/liveReactionRepository/api/index.ts +1 -0
- package/src/liveReactionRepository/events/index.ts +1 -0
- package/src/liveReactionRepository/events/onLiveReactionCreated.ts +37 -0
- package/src/liveReactionRepository/events/onLiveReactionCreatedLocal.ts +29 -0
- package/src/liveReactionRepository/index.ts +3 -0
- package/src/liveReactionRepository/internalApi/createLiveReaction.ts +42 -0
- package/src/liveReactionRepository/observers/getReactions.ts +59 -0
- package/src/liveReactionRepository/observers/index.ts +1 -0
- package/src/liveReactionRepository/service/ReactionSyncEngine.ts +138 -0
- package/src/liveReactionRepository/utils/ReactionSyncEngineOnLoginHandler.ts +19 -0
- package/src/liveStreamPlayer/api/getPlayer.ts +1 -1
- package/src/liveStreamPlayer/utils/eventRegister.ts +16 -1
- package/src/messageRepository/api/deleteMessage.ts +16 -0
- package/src/messageRepository/observers/getMessage.ts +2 -0
- package/src/messageRepository/observers/getMessages/MessageLiveCollectionController.ts +2 -0
- package/src/messageRepository/observers/getMessages/MessageQueryStreamController.ts +13 -0
- package/src/postRepository/api/createPost.ts +3 -2
- package/src/postRepository/api/index.ts +0 -2
- package/src/postRepository/api/queryPosts.ts +1 -1
- package/src/postRepository/observers/getPosts/PostPaginationController.ts +1 -1
- package/src/postRepository/utils/payload.ts +37 -1
- package/src/streamRepository/api/createStream.ts +4 -1
- package/src/streamRepository/api/editStream.ts +51 -0
- package/src/streamRepository/api/index.ts +1 -0
- package/src/streamRepository/api/updateStream.ts +8 -1
- package/src/streamRepository/events/index.ts +2 -0
- package/src/streamRepository/events/onStreamViewerBanned.ts +58 -0
- package/src/streamRepository/events/onStreamViewerUnbanned.ts +47 -0
- package/src/streamRepository/internalApi/getLiveChat.ts +59 -0
- package/src/streamRepository/internalApi/getStream.ts +3 -3
- package/src/streamRepository/observers/getStreamById.ts +2 -0
- package/src/streamRepository/observers/getStreams/GetStreamsLiveCollectionController.ts +5 -1
- package/src/utils/linkedObject/channelLinkedObject.ts +3 -0
- package/src/utils/linkedObject/postLinkedObject.ts +25 -6
- package/src/utils/linkedObject/streamLinkedObject.ts +4 -0
- package/src/utils/postTypePredicate.ts +20 -7
- package/dist/channelRepository/events/onChannelMuted.d.ts +0 -2
- package/dist/channelRepository/events/onChannelMuted.d.ts.map +0 -1
- package/dist/fileRepository/api/uploadClip.d.ts +0 -17
- package/dist/fileRepository/api/uploadClip.d.ts.map +0 -1
- package/dist/postRepository/api/createClipPost.d.ts +0 -32
- package/dist/postRepository/api/createClipPost.d.ts.map +0 -1
- package/src/channelRepository/events/onChannelMuted.ts +0 -39
- package/src/fileRepository/api/uploadClip.ts +0 -71
- package/src/postRepository/api/createClipPost.ts +0 -62
|
@@ -78,7 +78,7 @@ declare global {
|
|
|
78
78
|
metadata: Amity.MetadataFor<T>;
|
|
79
79
|
};
|
|
80
80
|
accessType: Amity.FileAccessType;
|
|
81
|
-
} & (T extends 'video'
|
|
81
|
+
} & (T extends 'video' ? Amity.VideoFileExtraPayload : unknown) &
|
|
82
82
|
Amity.Timestamps &
|
|
83
83
|
Amity.SoftDelete;
|
|
84
84
|
|
|
@@ -588,5 +588,37 @@ declare global {
|
|
|
588
588
|
type JoinRequestPayload = {
|
|
589
589
|
joinRequests: Amity.RawJoinRequest[];
|
|
590
590
|
};
|
|
591
|
+
|
|
592
|
+
type LiveReactionPayload = {
|
|
593
|
+
reactions: Amity.LiveReaction[];
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
type RawChannelSetMuted = {
|
|
597
|
+
channelId: string;
|
|
598
|
+
muteTimeout: Amity.timestamp;
|
|
599
|
+
actior: string;
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
type ChannelSetMutedPayload = RawChannelSetMuted[];
|
|
603
|
+
|
|
604
|
+
type RawChannelSetUserMuted = {
|
|
605
|
+
channelId: string;
|
|
606
|
+
userIds: string[];
|
|
607
|
+
muteTimeout: Amity.timestamp;
|
|
608
|
+
actor: string;
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
type RawStreamViewerBan = {
|
|
612
|
+
networkId: string;
|
|
613
|
+
streamId: string;
|
|
614
|
+
userId: string;
|
|
615
|
+
actor: string;
|
|
616
|
+
createdAt: Amity.timestamp;
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
type StreamViewerBanPayload = RawStreamViewerBan[];
|
|
620
|
+
type StreamViewerUnbanPayload = RawStreamViewerBan[];
|
|
621
|
+
|
|
622
|
+
type ChannelSetUserMutedPayload = RawChannelSetUserMuted;
|
|
591
623
|
}
|
|
592
624
|
}
|
|
@@ -25,6 +25,7 @@ declare global {
|
|
|
25
25
|
OnJoin = 'onJoin',
|
|
26
26
|
OnLeft = 'onLeft',
|
|
27
27
|
OnMute = 'onMute',
|
|
28
|
+
onUnmute = 'onUnmute',
|
|
28
29
|
OnMemberAdded = 'onMemberAdded',
|
|
29
30
|
OnMemberRemoved = 'onMemberRemoved',
|
|
30
31
|
OnUserMessageFeedMarkerFetch = 'onUserMessageFeedMarkerFetch',
|
|
@@ -61,6 +62,11 @@ declare global {
|
|
|
61
62
|
isPublic?: boolean;
|
|
62
63
|
|
|
63
64
|
lastActivity: Amity.timestamp;
|
|
65
|
+
|
|
66
|
+
attachedTo?: {
|
|
67
|
+
postId?: string;
|
|
68
|
+
videoStreamId?: string;
|
|
69
|
+
};
|
|
64
70
|
} & Amity.Metadata &
|
|
65
71
|
Amity.Taggable &
|
|
66
72
|
Amity.Timestamps &
|
|
@@ -94,6 +100,9 @@ declare global {
|
|
|
94
100
|
messagePreview?: Amity.MessagePreview | null;
|
|
95
101
|
markAsRead: () => Promise<boolean>;
|
|
96
102
|
previewMembers: Amity.Membership<'channel'>[];
|
|
103
|
+
myMembership: (
|
|
104
|
+
callback: Amity.LiveObjectCallback<Amity.Membership<'channel'> | undefined>,
|
|
105
|
+
) => Amity.Unsubscriber;
|
|
97
106
|
};
|
|
98
107
|
|
|
99
108
|
type QueryChannels = {
|
|
@@ -32,7 +32,6 @@ declare global {
|
|
|
32
32
|
| 'poll'
|
|
33
33
|
| 'json'
|
|
34
34
|
| 'liveStream'
|
|
35
|
-
| 'clip'
|
|
36
35
|
| string;
|
|
37
36
|
|
|
38
37
|
type ContentFeedType = ValueOf<typeof ContentFeedType>;
|
|
@@ -63,13 +62,6 @@ declare global {
|
|
|
63
62
|
};
|
|
64
63
|
};
|
|
65
64
|
|
|
66
|
-
type ContentDataClip = {
|
|
67
|
-
thumbnailFileId: Amity.File<'image'>['fileId'];
|
|
68
|
-
fileId: Amity.File<'clip'>['fileId'];
|
|
69
|
-
isMuted?: boolean;
|
|
70
|
-
displayMode?: Amity.ClipDisplayMode;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
65
|
type ContentDataPoll = {
|
|
74
66
|
pollId: Amity.Poll['pollId'];
|
|
75
67
|
};
|
|
@@ -90,8 +82,6 @@ declare global {
|
|
|
90
82
|
? ContentDataPoll
|
|
91
83
|
: T extends 'liveStream'
|
|
92
84
|
? ContentDataStream
|
|
93
|
-
: T extends 'clip'
|
|
94
|
-
? ContentDataClip
|
|
95
85
|
: T extends 'json'
|
|
96
86
|
? Record<string, unknown>
|
|
97
87
|
: T extends string
|
|
@@ -11,9 +11,8 @@ declare global {
|
|
|
11
11
|
} & Amity.Timestamps;
|
|
12
12
|
|
|
13
13
|
type QueryGlobalFeed = {
|
|
14
|
-
|
|
14
|
+
dataType?: 'video' | 'image' | 'file' | 'liveStream';
|
|
15
15
|
queryToken?: string;
|
|
16
|
-
resolveParent?: boolean;
|
|
17
16
|
};
|
|
18
17
|
}
|
|
19
18
|
}
|
|
@@ -2,7 +2,6 @@ export const FileType = Object.freeze({
|
|
|
2
2
|
FILE: 'file',
|
|
3
3
|
IMAGE: 'image',
|
|
4
4
|
VIDEO: 'video',
|
|
5
|
-
CLIP: 'clip',
|
|
6
5
|
});
|
|
7
6
|
|
|
8
7
|
export const VideoResolution = Object.freeze({
|
|
@@ -56,16 +55,12 @@ declare global {
|
|
|
56
55
|
|
|
57
56
|
type VideoMetadata = Record<string, never>;
|
|
58
57
|
|
|
59
|
-
type ClipMetadata = Record<string, never>;
|
|
60
|
-
|
|
61
58
|
type MetadataFor<T extends FileType> = T extends 'file'
|
|
62
59
|
? FileMetadata
|
|
63
60
|
: T extends 'image'
|
|
64
61
|
? ImageMetadata
|
|
65
62
|
: T extends 'video'
|
|
66
63
|
? VideoMetadata
|
|
67
|
-
: T extends 'clip'
|
|
68
|
-
? ClipMetadata
|
|
69
64
|
: never;
|
|
70
65
|
|
|
71
66
|
type File<T extends FileType = any> = Amity.FilePayload<T>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
namespace Amity {
|
|
5
|
+
type RawLiveReaction = {
|
|
6
|
+
userId: string; // user's public ID
|
|
7
|
+
referenceId: string; // post's internal ID
|
|
8
|
+
referencePublicId: string; // post's public ID
|
|
9
|
+
referenceType: string; // 'post'
|
|
10
|
+
reactionName: string; // 'love
|
|
11
|
+
// date string in ISO format
|
|
12
|
+
occurredAt: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type InternalLiveReaction = RawLiveReaction;
|
|
16
|
+
|
|
17
|
+
type LiveReaction = InternalLiveReaction;
|
|
18
|
+
|
|
19
|
+
type CreateLiveReactionRequest = Omit<RawLiveReaction, 'userId' | 'referenceId' | 'occurredAt'>;
|
|
20
|
+
|
|
21
|
+
type CreateLiveReactionResponse = {
|
|
22
|
+
addedIds: string[];
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -5,7 +5,6 @@ export const PostContentType = Object.freeze({
|
|
|
5
5
|
VIDEO: 'video',
|
|
6
6
|
LIVESTREAM: 'liveStream',
|
|
7
7
|
POLL: 'poll',
|
|
8
|
-
CLIP: 'clip',
|
|
9
8
|
});
|
|
10
9
|
|
|
11
10
|
declare global {
|
|
@@ -71,9 +70,11 @@ declare global {
|
|
|
71
70
|
|
|
72
71
|
type InternalPost<T extends PostContentType = any> = RawPost<T> & {
|
|
73
72
|
feedType?: 'reviewing' | 'published';
|
|
73
|
+
// childPosts?: Amity.RawPost[];
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
type PostLinkObject = {
|
|
77
|
+
childrenPosts: Amity.Post[];
|
|
77
78
|
latestComments: (Amity.Comment | null)[];
|
|
78
79
|
creator: Amity.User | undefined;
|
|
79
80
|
analytics: {
|
|
@@ -83,13 +84,12 @@ declare global {
|
|
|
83
84
|
getVideoInfo: () => Amity.File<'video'> | undefined;
|
|
84
85
|
getVideoThumbnailInfo: () => Amity.File<'image'> | undefined;
|
|
85
86
|
getFileInfo: () => Amity.File<'file'> | undefined;
|
|
86
|
-
|
|
87
|
+
getPollInfo: () => Amity.Poll | undefined;
|
|
88
|
+
getLivestreamInfo: () => Amity.Stream | undefined;
|
|
87
89
|
};
|
|
88
90
|
|
|
89
91
|
type Post<T extends PostContentType = any> = Amity.InternalPost<T> & Amity.PostLinkObject;
|
|
90
92
|
|
|
91
|
-
type ClipDisplayMode = 'fill' | 'fit';
|
|
92
|
-
|
|
93
93
|
type QueryPosts = {
|
|
94
94
|
targetId: string;
|
|
95
95
|
targetType: Amity.InternalPost['targetType'];
|
|
@@ -73,6 +73,13 @@ declare global {
|
|
|
73
73
|
*/
|
|
74
74
|
targetId?: string; // communityId, userId, etc..
|
|
75
75
|
targetType?: string; // 'community', 'user', etc..
|
|
76
|
+
|
|
77
|
+
/*
|
|
78
|
+
* when stream linked with a post and a live channel.
|
|
79
|
+
*/
|
|
80
|
+
postId?: string;
|
|
81
|
+
channelId?: string;
|
|
82
|
+
channelEnabled?: boolean;
|
|
76
83
|
} & Amity.Metadata &
|
|
77
84
|
Amity.Timestamps &
|
|
78
85
|
Amity.SoftDelete;
|
|
@@ -81,9 +88,14 @@ declare global {
|
|
|
81
88
|
|
|
82
89
|
type StreamLinkedObject = {
|
|
83
90
|
moderation?: Amity.StreamModeration;
|
|
91
|
+
post?: Amity.InternalPost;
|
|
92
|
+
getLiveChat: () => Promise<Amity.Channel<'live'> | undefined>;
|
|
84
93
|
};
|
|
85
94
|
|
|
86
|
-
type Stream = Amity.InternalStream & Amity.StreamLinkedObject
|
|
95
|
+
type Stream = Omit<Amity.InternalStream & Amity.StreamLinkedObject, 'watcherUrl'> & {
|
|
96
|
+
isBanned: boolean;
|
|
97
|
+
watcherUrl: null;
|
|
98
|
+
};
|
|
87
99
|
|
|
88
100
|
type QueryStreams = {
|
|
89
101
|
isLive?: boolean;
|
package/src/@types/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getActiveClient } from '~/client/api';
|
|
1
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
2
|
|
|
3
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
4
|
|
|
5
5
|
import { prepareChannelPayload } from '../utils';
|
|
6
|
-
import {
|
|
6
|
+
import { constructChannelObject } from '../utils/constructChannelObject';
|
|
7
7
|
|
|
8
8
|
/* begin_public_function
|
|
9
9
|
id: channel.create
|
|
@@ -23,11 +23,14 @@ import { constructChannelDynamicValue } from '../utils/constructChannelDynamicVa
|
|
|
23
23
|
* @async
|
|
24
24
|
*/
|
|
25
25
|
export const createChannel = async <T extends Amity.ChannelType>(
|
|
26
|
-
bundle: {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
bundle: {
|
|
27
|
+
type: T;
|
|
28
|
+
userIds?: Amity.InternalUser['userId'][];
|
|
29
|
+
// For live channel linked with a livestream post
|
|
30
|
+
videoStreamId?: string;
|
|
31
|
+
postId?: string;
|
|
32
|
+
} & Pick<Amity.Channel<T>, 'displayName' | 'avatarFileId' | 'tags' | 'metadata' | 'isPublic'>,
|
|
33
|
+
): Promise<Amity.Cached<Amity.Channel<T>>> => {
|
|
31
34
|
const client = getActiveClient();
|
|
32
35
|
client.log('user/createChannel', bundle);
|
|
33
36
|
|
|
@@ -53,7 +56,7 @@ export const createChannel = async <T extends Amity.ChannelType>(
|
|
|
53
56
|
|
|
54
57
|
const { channels } = data;
|
|
55
58
|
return {
|
|
56
|
-
data:
|
|
59
|
+
data: constructChannelObject(channels[0]),
|
|
57
60
|
cachedAt,
|
|
58
61
|
};
|
|
59
62
|
};
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
import { prepareChannelPayload } from '~/channelRepository/utils';
|
|
25
25
|
import { onUserDeleted } from '~/channelRepository/events/onUserDeleted';
|
|
26
26
|
import { LinkedObject } from '~/utils/linkedObject';
|
|
27
|
+
import { onChannelSetUserMuted } from '~/channelRepository/events/onChannelSetUserMuted';
|
|
27
28
|
|
|
28
29
|
export class ChannelMemberLiveCollectionController extends LiveCollectionController<
|
|
29
30
|
'channelUser',
|
|
@@ -89,6 +90,7 @@ export class ChannelMemberLiveCollectionController extends LiveCollectionControl
|
|
|
89
90
|
{ fn: onChannelMemberUnbanned, action: 'onChannelMemberUnbanned' },
|
|
90
91
|
{ fn: onChannelMemberRoleAdded, action: 'onChannelMemberRoleAdded' },
|
|
91
92
|
{ fn: onChannelMemberRoleRemoved, action: 'onChannelMemberRoleRemoved' },
|
|
93
|
+
{ fn: onChannelSetUserMuted, action: 'onChannelSetUserMuted' },
|
|
92
94
|
{ fn: onUserDeleted(this.query.channelId), action: 'onChannelMemberChanged' },
|
|
93
95
|
]);
|
|
94
96
|
}
|
|
@@ -4,7 +4,7 @@ export * from './onChannelDeleted';
|
|
|
4
4
|
|
|
5
5
|
export * from './onChannelJoined';
|
|
6
6
|
export * from './onChannelLeft';
|
|
7
|
-
export * from './
|
|
7
|
+
export * from './onChannelSetMuted';
|
|
8
8
|
|
|
9
9
|
export * from './onChannelMemberAdded';
|
|
10
10
|
export * from './onChannelMemberRemoved';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
+
import { createEventSubscriber } from '~/core/events';
|
|
3
|
+
import { pullFromCache, upsertInCache } from '~/cache/api';
|
|
4
|
+
|
|
5
|
+
type CallbackFn = Amity.Listener<Amity.StaticInternalChannel>;
|
|
6
|
+
const callbacks: CallbackFn[] = [];
|
|
7
|
+
let mainDisposer: (() => void) | null = null;
|
|
8
|
+
|
|
9
|
+
const dispose = (cb: CallbackFn) => {
|
|
10
|
+
const index = callbacks.indexOf(cb);
|
|
11
|
+
if (index > -1) {
|
|
12
|
+
callbacks.splice(index, 1);
|
|
13
|
+
}
|
|
14
|
+
if (callbacks.length === 0) {
|
|
15
|
+
mainDisposer?.();
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const onChannelSetMuted = (callback: Amity.Listener<Amity.StaticInternalChannel>) => {
|
|
20
|
+
if (callbacks.length === 0) {
|
|
21
|
+
const client = getActiveClient();
|
|
22
|
+
|
|
23
|
+
const filter = async (payloads: Amity.ChannelSetMutedPayload) => {
|
|
24
|
+
payloads.forEach(payload => {
|
|
25
|
+
upsertInCache(['channel', 'get', payload.channelId], {
|
|
26
|
+
// If muteTimeout > now => user is muted
|
|
27
|
+
// Otherwise => user is unmuted
|
|
28
|
+
isMuted: Date.parse(payload.muteTimeout) > Date.now(),
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const channel = pullFromCache<Amity.StaticInternalChannel>([
|
|
33
|
+
'channel',
|
|
34
|
+
'get',
|
|
35
|
+
payloads[0].channelId,
|
|
36
|
+
])?.data;
|
|
37
|
+
|
|
38
|
+
if (channel) {
|
|
39
|
+
callbacks.forEach(cb => cb(channel));
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
mainDisposer = createEventSubscriber(client, 'onChannelMute', 'channel.setMuted', filter);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
callbacks.push(callback);
|
|
47
|
+
return () => dispose(callback);
|
|
48
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
+
import { createEventSubscriber } from '~/core/events';
|
|
3
|
+
|
|
4
|
+
import { pullFromCache, upsertInCache } from '~/cache/api';
|
|
5
|
+
|
|
6
|
+
type CallbackFn = (
|
|
7
|
+
channel: Amity.StaticInternalChannel,
|
|
8
|
+
member: Amity.Membership<'channel'>,
|
|
9
|
+
) => void;
|
|
10
|
+
const callbacks: CallbackFn[] = [];
|
|
11
|
+
let mainDisposer: (() => void) | null = null;
|
|
12
|
+
|
|
13
|
+
const dispose = (cb: CallbackFn) => {
|
|
14
|
+
const index = callbacks.indexOf(cb);
|
|
15
|
+
if (index > -1) {
|
|
16
|
+
callbacks.splice(index, 1);
|
|
17
|
+
}
|
|
18
|
+
if (callbacks.length === 0) {
|
|
19
|
+
mainDisposer?.();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const onChannelSetUserMuted = (
|
|
24
|
+
callback: (channel: Amity.StaticInternalChannel, member: Amity.Membership<'channel'>) => void,
|
|
25
|
+
): Amity.Unsubscriber => {
|
|
26
|
+
if (callbacks.length === 0) {
|
|
27
|
+
const client = getActiveClient();
|
|
28
|
+
|
|
29
|
+
const filter = async (payload: Amity.ChannelSetUserMutedPayload) => {
|
|
30
|
+
payload.userIds.forEach(userId =>
|
|
31
|
+
// If muteTimeout > now => user is muted
|
|
32
|
+
// Otherwise => user is unmuted
|
|
33
|
+
upsertInCache(['channelUsers', 'get', `${payload.channelId}#${userId}`], {
|
|
34
|
+
isMuted: Date.parse(payload.muteTimeout) > Date.now(),
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const channel = pullFromCache<Amity.StaticInternalChannel>([
|
|
39
|
+
'channel',
|
|
40
|
+
'get',
|
|
41
|
+
payload.channelId,
|
|
42
|
+
])?.data;
|
|
43
|
+
|
|
44
|
+
const channelUser = pullFromCache<Amity.Membership<'channel'>>([
|
|
45
|
+
'channelUsers',
|
|
46
|
+
'get',
|
|
47
|
+
`${payload.channelId}#${payload.userIds[0]}`,
|
|
48
|
+
])?.data;
|
|
49
|
+
|
|
50
|
+
if (channel && channelUser) {
|
|
51
|
+
callbacks.forEach(cb => cb(channel, channelUser));
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
mainDisposer = createEventSubscriber(
|
|
56
|
+
client,
|
|
57
|
+
'onChannelUserMute',
|
|
58
|
+
'channel.setMutedUsers',
|
|
59
|
+
filter,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
callbacks.push(callback);
|
|
64
|
+
return () => dispose(callback);
|
|
65
|
+
};
|
|
@@ -9,7 +9,6 @@ import { pushToTombstone } from '~/cache/api/pushToTombstone';
|
|
|
9
9
|
|
|
10
10
|
import { prepareChannelPayload } from '../utils';
|
|
11
11
|
import { prepareUnreadCountInfo } from '../utils/prepareUnreadCountInfo';
|
|
12
|
-
import { constructChannelDynamicValue } from '../utils/constructChannelDynamicValue';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* ```js
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { pullFromCache } from '~/cache/api/pullFromCache';
|
|
2
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
3
|
+
import { ASCApiError } from '~/core/errors';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* get current user's membership data
|
|
8
|
+
*
|
|
9
|
+
* @returns the {@link Amity.Membership<'channel'>} objects
|
|
10
|
+
*
|
|
11
|
+
* @category Channel API
|
|
12
|
+
* @async
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const getMyMembership = (channelId: string): Amity.Cached<Amity.Membership<'channel'>> => {
|
|
16
|
+
const client = getActiveClient();
|
|
17
|
+
client.log('channel/getMyMembership.locally');
|
|
18
|
+
|
|
19
|
+
const cacheChannelUser = pullFromCache<Amity.Membership<'channel'>>([
|
|
20
|
+
'channelUsers',
|
|
21
|
+
'get',
|
|
22
|
+
`${channelId}#${client.userId}`,
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
if (!cacheChannelUser) {
|
|
26
|
+
throw new ASCApiError(
|
|
27
|
+
'Item not found!',
|
|
28
|
+
Amity.ServerError.ITEM_NOT_FOUND,
|
|
29
|
+
Amity.ErrorLevel.ERROR,
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
data: cacheChannelUser.data,
|
|
35
|
+
cachedAt: cacheChannelUser.cachedAt,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
onChannelMemberBanned,
|
|
11
11
|
onChannelMemberRemoved,
|
|
12
12
|
onChannelMemberUnbanned,
|
|
13
|
-
|
|
13
|
+
onChannelSetMuted,
|
|
14
14
|
onChannelUpdated,
|
|
15
15
|
} from '../events';
|
|
16
16
|
import { dropFromCache, pullFromCache } from '~/cache/api';
|
|
@@ -104,7 +104,7 @@ export const getChannel = (
|
|
|
104
104
|
onChannelMemberRemoved,
|
|
105
105
|
onChannelMemberBanned,
|
|
106
106
|
onChannelMemberUnbanned,
|
|
107
|
-
|
|
107
|
+
onChannelSetMuted,
|
|
108
108
|
convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel'),
|
|
109
109
|
convertEventPayload(onChannelMarkerUpdated, 'entityId', 'channel'),
|
|
110
110
|
convertEventPayload(
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
onChannelLeft,
|
|
12
12
|
onChannelMemberAdded,
|
|
13
13
|
onChannelMemberRemoved,
|
|
14
|
-
onChannelMuted,
|
|
15
14
|
onChannelUpdated,
|
|
16
15
|
} from '~/channelRepository/events';
|
|
17
16
|
import {
|
|
@@ -58,6 +57,7 @@ import { onUserMessageFeedMarkerResolved } from '~/marker/events/onUserMessageFe
|
|
|
58
57
|
import { onChannelUnreadInfoUpdatedLocal } from '~/marker/events/onChannelUnreadInfoUpdatedLocal';
|
|
59
58
|
import { constructChannelObject } from '~/channelRepository/utils/constructChannelObject';
|
|
60
59
|
import { onChannelUnreadUpdatedLocal } from '~/channelRepository/events/onChannelUnreadUpdatedLocal';
|
|
60
|
+
import { onChannelSetMuted } from '~/channelRepository/events/onChannelSetMuted';
|
|
61
61
|
|
|
62
62
|
export class ChannelLiveCollectionController extends LiveCollectionController<
|
|
63
63
|
'channel',
|
|
@@ -313,7 +313,7 @@ export class ChannelLiveCollectionController extends LiveCollectionController<
|
|
|
313
313
|
},
|
|
314
314
|
{ fn: onChannelDeleted, action: Amity.ChannelActionType.OnDelete },
|
|
315
315
|
{ fn: onChannelUpdated, action: Amity.ChannelActionType.OnUpdate },
|
|
316
|
-
{ fn:
|
|
316
|
+
{ fn: onChannelSetMuted, action: Amity.ChannelActionType.OnMute },
|
|
317
317
|
{
|
|
318
318
|
fn: (callback: Amity.Listener<Amity.StaticInternalChannel>) => {
|
|
319
319
|
return onChannelJoined(channel => {
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { getActiveUser } from '~/client/api/activeUser';
|
|
2
|
+
import { getMyMembership as _getMyMembership } from '../internalApi/getMyMembership';
|
|
3
|
+
import { ASCApiError, ASCError } from '~/core/errors';
|
|
4
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
5
|
+
import { isEqual } from '~/utils/isEqual';
|
|
6
|
+
import { createQuery, runQuery } from '~/core/query';
|
|
7
|
+
import {
|
|
8
|
+
UNSYNCED_OBJECT_CACHED_AT_MESSAGE,
|
|
9
|
+
UNSYNCED_OBJECT_CACHED_AT_VALUE,
|
|
10
|
+
} from '~/utils/constants';
|
|
11
|
+
import { channelMemberLinkedObject } from '~/utils/linkedObject/channelMemberLinkedObject';
|
|
12
|
+
import { onChannelMemberBanned, onChannelMemberUnbanned } from '../events';
|
|
13
|
+
import { onChannelSetUserMuted } from '../events/onChannelSetUserMuted';
|
|
14
|
+
|
|
15
|
+
export const getMyMembership = (
|
|
16
|
+
channelId: string,
|
|
17
|
+
callback: Amity.LiveObjectCallback<Amity.Membership<'channel'> | undefined>,
|
|
18
|
+
): Amity.Unsubscriber => {
|
|
19
|
+
const { _id: userId } = getActiveUser();
|
|
20
|
+
|
|
21
|
+
if (!userId)
|
|
22
|
+
throw new ASCError(
|
|
23
|
+
'The _id has not been defined in ActiveUser',
|
|
24
|
+
Amity.ClientError.UNKNOWN_ERROR,
|
|
25
|
+
Amity.ErrorLevel.ERROR,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const { log, cache } = getActiveClient();
|
|
29
|
+
|
|
30
|
+
if (!cache) {
|
|
31
|
+
console.log('This observable object need the cache data!');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const timestamp = Date.now();
|
|
35
|
+
log(`liveMymembership(tmpid: ${timestamp}) > listen`);
|
|
36
|
+
|
|
37
|
+
const disposers: Amity.Unsubscriber[] = [];
|
|
38
|
+
|
|
39
|
+
let isUnsyncedModel = false; // for messages
|
|
40
|
+
|
|
41
|
+
let model: Amity.Membership<'channel'> | undefined;
|
|
42
|
+
|
|
43
|
+
const dispatcher = (data: Amity.LiveObject<Amity.Membership<'channel'> | undefined>) => {
|
|
44
|
+
callback({
|
|
45
|
+
...data,
|
|
46
|
+
data: data.data ? channelMemberLinkedObject(data.data) : data.data,
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const realtimeRouter = (_: Amity.StaticInternalChannel, __: Amity.RawMembership<'channel'>) => {
|
|
51
|
+
const { data } = _getMyMembership(channelId);
|
|
52
|
+
|
|
53
|
+
if (isEqual(model, data)) return;
|
|
54
|
+
|
|
55
|
+
dispatcher({
|
|
56
|
+
loading: false,
|
|
57
|
+
data,
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const onFetch = () => {
|
|
62
|
+
const query = createQuery(async () => _getMyMembership(channelId));
|
|
63
|
+
|
|
64
|
+
runQuery(query, ({ error, data, loading, origin, cachedAt }) => {
|
|
65
|
+
if (cachedAt === UNSYNCED_OBJECT_CACHED_AT_VALUE) {
|
|
66
|
+
dispatcher({
|
|
67
|
+
data,
|
|
68
|
+
origin,
|
|
69
|
+
loading: false,
|
|
70
|
+
error: new ASCApiError(
|
|
71
|
+
UNSYNCED_OBJECT_CACHED_AT_MESSAGE,
|
|
72
|
+
Amity.ClientError.DISALOOW_UNSYNCED_OBJECT,
|
|
73
|
+
Amity.ErrorLevel.ERROR,
|
|
74
|
+
),
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
isUnsyncedModel = true;
|
|
78
|
+
disposers.forEach(fn => fn());
|
|
79
|
+
} else if (!isUnsyncedModel) {
|
|
80
|
+
dispatcher({ loading, data, origin, error });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (error) {
|
|
84
|
+
disposers.forEach(fn => fn());
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
disposers.push(onChannelMemberBanned(realtimeRouter));
|
|
90
|
+
disposers.push(onChannelMemberUnbanned(realtimeRouter));
|
|
91
|
+
disposers.push(onChannelSetUserMuted(realtimeRouter));
|
|
92
|
+
|
|
93
|
+
onFetch();
|
|
94
|
+
|
|
95
|
+
return () => {
|
|
96
|
+
disposers.forEach(fn => fn());
|
|
97
|
+
};
|
|
98
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getChannelMessagePreviewWithUser } from '~/messagePreview/utils';
|
|
2
2
|
import { constructChannelDynamicValue } from './constructChannelDynamicValue';
|
|
3
|
-
import {
|
|
3
|
+
import { channelLinkedObject } from '~/utils/linkedObject/channelLinkedObject';
|
|
4
4
|
|
|
5
5
|
export const constructChannelObject = (channel: Amity.StaticInternalChannel): Amity.Channel => {
|
|
6
6
|
/**
|
|
@@ -10,7 +10,7 @@ export const constructChannelObject = (channel: Amity.StaticInternalChannel): Am
|
|
|
10
10
|
* 3. [LinkedObject.channel] add markAsRead >> Amity.InternalChannel -> Amity.Channel
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
return
|
|
13
|
+
return channelLinkedObject(
|
|
14
14
|
constructChannelDynamicValue(getChannelMessagePreviewWithUser(channel)),
|
|
15
15
|
);
|
|
16
16
|
};
|
package/src/client/api/login.ts
CHANGED
|
@@ -13,6 +13,7 @@ import analyticsEngineOnLoginHandler from '~/analytic/utils/analyticsEngineOnLog
|
|
|
13
13
|
import readReceiptSyncEngineOnLoginHandler from '~/client/utils/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler';
|
|
14
14
|
import legacyReadReceiptSyncEngineOnLoginHandler from '~/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler';
|
|
15
15
|
import objectResolverEngineOnLoginHandler from '~/client/utils/ObjectResolver/objectResolverEngineOnLoginHandler';
|
|
16
|
+
import reactionSyncEngineOnLoginHandler from '~/liveReactionRepository/utils/ReactionSyncEngineOnLoginHandler';
|
|
16
17
|
import { logout } from './logout';
|
|
17
18
|
|
|
18
19
|
import { getActiveClient } from './activeClient';
|
|
@@ -201,6 +202,7 @@ export const login = async (
|
|
|
201
202
|
markReadEngineOnLoginHandler(),
|
|
202
203
|
analyticsEngineOnLoginHandler(),
|
|
203
204
|
objectResolverEngineOnLoginHandler(),
|
|
205
|
+
reactionSyncEngineOnLoginHandler(),
|
|
204
206
|
);
|
|
205
207
|
|
|
206
208
|
if (client.useLegacyUnreadCount) {
|