@amityco/ts-sdk 7.6.1-a0961ea.0 → 7.6.1-b8014723.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 +5 -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/observers/getChannels/ChannelLiveCollectionController.d.ts.map +1 -1
- 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 +6341 -5860
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +6182 -5703
- 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/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/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/postLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/streamLinkedObject.d.ts.map +1 -1
- package/dist/utils/postTypePredicate.d.ts +2 -1
- 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 +9 -1
- package/src/@types/core/payload.ts +33 -1
- package/src/@types/domains/channel.ts +6 -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 +3 -4
- package/src/@types/domains/stream.ts +12 -1
- package/src/@types/index.ts +1 -0
- package/src/channelRepository/api/createChannel.ts +12 -9
- 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 +67 -0
- package/src/channelRepository/internalApi/getChannel.ts +0 -1
- package/src/channelRepository/observers/getChannel.ts +2 -2
- package/src/channelRepository/observers/getChannels/ChannelLiveCollectionController.ts +2 -2
- 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 +1 -0
- 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/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/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/postLinkedObject.ts +25 -6
- package/src/utils/linkedObject/streamLinkedObject.ts +4 -0
- package/src/utils/postTypePredicate.ts +12 -3
- 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
|
@@ -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 {
|
|
@@ -74,6 +73,7 @@ declare global {
|
|
|
74
73
|
};
|
|
75
74
|
|
|
76
75
|
type PostLinkObject = {
|
|
76
|
+
childrenPosts: Amity.Post[];
|
|
77
77
|
latestComments: (Amity.Comment | null)[];
|
|
78
78
|
creator: Amity.User | undefined;
|
|
79
79
|
analytics: {
|
|
@@ -83,13 +83,12 @@ declare global {
|
|
|
83
83
|
getVideoInfo: () => Amity.File<'video'> | undefined;
|
|
84
84
|
getVideoThumbnailInfo: () => Amity.File<'image'> | undefined;
|
|
85
85
|
getFileInfo: () => Amity.File<'file'> | undefined;
|
|
86
|
-
|
|
86
|
+
getPollInfo: () => Amity.Poll | undefined;
|
|
87
|
+
getLivestreamInfo: () => Amity.Stream | undefined;
|
|
87
88
|
};
|
|
88
89
|
|
|
89
90
|
type Post<T extends PostContentType = any> = Amity.InternalPost<T> & Amity.PostLinkObject;
|
|
90
91
|
|
|
91
|
-
type ClipDisplayMode = 'fill' | 'fit';
|
|
92
|
-
|
|
93
92
|
type QueryPosts = {
|
|
94
93
|
targetId: string;
|
|
95
94
|
targetType: Amity.InternalPost['targetType'];
|
|
@@ -73,6 +73,12 @@ declare global {
|
|
|
73
73
|
*/
|
|
74
74
|
targetId?: string; // communityId, userId, etc..
|
|
75
75
|
targetType?: string; // 'community', 'user', etc..
|
|
76
|
+
/*
|
|
77
|
+
* when stream linked with a post and a live channel.
|
|
78
|
+
*/
|
|
79
|
+
postId?: string;
|
|
80
|
+
channelId?: string;
|
|
81
|
+
channelEnabled?: boolean;
|
|
76
82
|
} & Amity.Metadata &
|
|
77
83
|
Amity.Timestamps &
|
|
78
84
|
Amity.SoftDelete;
|
|
@@ -81,9 +87,14 @@ declare global {
|
|
|
81
87
|
|
|
82
88
|
type StreamLinkedObject = {
|
|
83
89
|
moderation?: Amity.StreamModeration;
|
|
90
|
+
post?: Amity.InternalPost;
|
|
91
|
+
getLiveChat: () => Promise<Amity.Channel<'live'> | undefined>;
|
|
84
92
|
};
|
|
85
93
|
|
|
86
|
-
type Stream = Amity.InternalStream & Amity.StreamLinkedObject
|
|
94
|
+
type Stream = Omit<Amity.InternalStream & Amity.StreamLinkedObject, 'watcherUrl'> & {
|
|
95
|
+
isBanned: boolean;
|
|
96
|
+
watcherUrl: null;
|
|
97
|
+
};
|
|
87
98
|
|
|
88
99
|
type QueryStreams = {
|
|
89
100
|
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
|
-
import { prepareChannelPayload } from '../utils';
|
|
6
|
-
import {
|
|
5
|
+
import { prepareChannelPayload } from '../utils/prepareChannelPayload';
|
|
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,67 @@
|
|
|
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 (payloads: Amity.ChannelSetUserMutedPayload) => {
|
|
30
|
+
payloads.forEach(payload => {
|
|
31
|
+
payload.userIds.forEach(userId =>
|
|
32
|
+
// If muteTimeout > now => user is muted
|
|
33
|
+
// Otherwise => user is unmuted
|
|
34
|
+
upsertInCache(['channelUsers', 'get', `${payload.channelId}#${userId}`], {
|
|
35
|
+
isMuted: Date.parse(payload.muteTimeout) > Date.now(),
|
|
36
|
+
}),
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const channel = pullFromCache<Amity.StaticInternalChannel>([
|
|
41
|
+
'channel',
|
|
42
|
+
'get',
|
|
43
|
+
payloads[0].channelId,
|
|
44
|
+
])?.data;
|
|
45
|
+
|
|
46
|
+
const channelUser = pullFromCache<Amity.Membership<'channel'>>([
|
|
47
|
+
'channelUsers',
|
|
48
|
+
'get',
|
|
49
|
+
`${payloads[0].channelId}#${payloads[0].userIds[0]}`,
|
|
50
|
+
])?.data;
|
|
51
|
+
|
|
52
|
+
if (channel && channelUser) {
|
|
53
|
+
callbacks.forEach(cb => cb(channel, channelUser));
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
mainDisposer = createEventSubscriber(
|
|
58
|
+
client,
|
|
59
|
+
'onChannelUserMute',
|
|
60
|
+
'channel.setUserMuted',
|
|
61
|
+
filter,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
callbacks.push(callback);
|
|
66
|
+
return () => dispose(callback);
|
|
67
|
+
};
|
|
@@ -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
|
|
@@ -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 => {
|
|
@@ -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) {
|
|
@@ -5,6 +5,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
5
5
|
|
|
6
6
|
import { saveCommunityUsers } from '~/communityRepository/utils/saveCommunityUsers';
|
|
7
7
|
import { prepareCommunityPayload } from '../utils';
|
|
8
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* ```js
|
|
@@ -22,6 +23,8 @@ import { prepareCommunityPayload } from '../utils';
|
|
|
22
23
|
*/
|
|
23
24
|
export const getCommunity = async (
|
|
24
25
|
communityId: Amity.Community['communityId'],
|
|
26
|
+
type?: Amity.JoinRequestType,
|
|
27
|
+
includeDiscoverablePrivateCommunity?: boolean,
|
|
25
28
|
): Promise<Amity.Cached<Amity.InternalCommunity>> => {
|
|
26
29
|
const client = getActiveClient();
|
|
27
30
|
client.log('community/getCommunity', communityId);
|
|
@@ -29,6 +32,12 @@ export const getCommunity = async (
|
|
|
29
32
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
30
33
|
const { data: payload } = await client.http.get<Amity.CommunityPayload>(
|
|
31
34
|
`/api/v3/communities/${communityId}`,
|
|
35
|
+
{
|
|
36
|
+
params: {
|
|
37
|
+
type: 'communityJoinRequest',
|
|
38
|
+
includeDiscoverablePrivateCommunity: includeDiscoverablePrivateCommunity ?? true,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
32
41
|
);
|
|
33
42
|
|
|
34
43
|
const data = prepareCommunityPayload(payload);
|
package/src/core/events.ts
CHANGED
package/src/core/subscription.ts
CHANGED
|
@@ -154,6 +154,16 @@ export const getSmartFeedMessageTopic = (): string => {
|
|
|
154
154
|
return `${getNetworkId(user)}/smartfeed/${user._id}/messages`;
|
|
155
155
|
};
|
|
156
156
|
|
|
157
|
+
export const getLiveStreamTopic = (): string => {
|
|
158
|
+
const user = getActiveUser();
|
|
159
|
+
|
|
160
|
+
return `${getNetworkId(user)}/videostreaming`;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export const getLiveReactionTopic = (post: Amity.Post) => {
|
|
164
|
+
return `${post.path}/liveReaction`;
|
|
165
|
+
};
|
|
166
|
+
|
|
157
167
|
let mqttAccessToken: string;
|
|
158
168
|
let mqttUserId: string;
|
|
159
169
|
|
|
@@ -168,9 +178,3 @@ export function subscribeTopic(
|
|
|
168
178
|
|
|
169
179
|
return mqtt.subscribe(topic, callback);
|
|
170
180
|
}
|
|
171
|
-
|
|
172
|
-
export const getLiveStreamTopic = (): string => {
|
|
173
|
-
const user = getActiveUser();
|
|
174
|
-
|
|
175
|
-
return `${getNetworkId(user)}/videostreaming`;
|
|
176
|
-
};
|
|
@@ -23,7 +23,7 @@ import { LinkedObject } from '~/utils/linkedObject';
|
|
|
23
23
|
* @async
|
|
24
24
|
* */
|
|
25
25
|
export const getCustomRankingGlobalFeed = async (query?: {
|
|
26
|
-
dataTypes?: ('video' | 'image' | 'file' | 'liveStream'
|
|
26
|
+
dataTypes?: ('video' | 'image' | 'file' | 'liveStream')[];
|
|
27
27
|
limit?: number;
|
|
28
28
|
queryToken?: string;
|
|
29
29
|
}): Promise<
|
|
@@ -32,7 +32,7 @@ export const queryGlobalFeed = async (
|
|
|
32
32
|
const client = getActiveClient();
|
|
33
33
|
client.log('feed/queryGlobalFeed', query);
|
|
34
34
|
|
|
35
|
-
const { queryToken,
|
|
35
|
+
const { queryToken, ...params } = query ?? {};
|
|
36
36
|
|
|
37
37
|
const options = (() => {
|
|
38
38
|
if (queryToken) return { token: queryToken };
|
|
@@ -44,8 +44,6 @@ export const queryGlobalFeed = async (
|
|
|
44
44
|
{
|
|
45
45
|
params: {
|
|
46
46
|
...params,
|
|
47
|
-
dataTypes,
|
|
48
|
-
resolveParent: resolveParent ?? true,
|
|
49
47
|
options,
|
|
50
48
|
},
|
|
51
49
|
},
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { fireEvent } from '~/core/events';
|
|
2
|
+
import ReactionSyncEngine from '../service/ReactionSyncEngine';
|
|
3
|
+
|
|
4
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
5
|
+
// TODO: confirm id
|
|
6
|
+
/* begin_public_function
|
|
7
|
+
id: live_reaction.create
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* ```js
|
|
11
|
+
* import { acceptInvitation } from '@amityco/ts-sdk'
|
|
12
|
+
* const isAccepted = await acceptInvitation(invitationId)
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
*
|
|
16
|
+
* @param referenceId that is target post's ID linked with a livestream
|
|
17
|
+
* @param reactionName that is the reaction name
|
|
18
|
+
* @param streamId stream id
|
|
19
|
+
* @returns a success boolean if the reaction was added
|
|
20
|
+
*
|
|
21
|
+
* @category Live Reaction API
|
|
22
|
+
* @async
|
|
23
|
+
*/
|
|
24
|
+
export const createReaction = async ({
|
|
25
|
+
referenceId,
|
|
26
|
+
referenceType,
|
|
27
|
+
reactionName,
|
|
28
|
+
streamId,
|
|
29
|
+
}: Pick<Amity.CreateLiveReactionRequest, 'referenceType' | 'reactionName'> & {
|
|
30
|
+
referenceId: string;
|
|
31
|
+
streamId: string;
|
|
32
|
+
}): Promise<boolean> => {
|
|
33
|
+
const client = getActiveClient();
|
|
34
|
+
|
|
35
|
+
client.log('live_reaction/createReaction', {
|
|
36
|
+
referenceId,
|
|
37
|
+
referenceType,
|
|
38
|
+
reactionName,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const reactionSynceEngine = ReactionSyncEngine.getInstance();
|
|
42
|
+
|
|
43
|
+
const reaction = {
|
|
44
|
+
reactionName,
|
|
45
|
+
referencePublicId: referenceId,
|
|
46
|
+
referenceType,
|
|
47
|
+
streamId,
|
|
48
|
+
occurredAt: new Date().toISOString(),
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
reactionSynceEngine.createLiveReaction(reaction);
|
|
53
|
+
|
|
54
|
+
fireEvent('local.liveReaction.created', [{ ...reaction, userId: client.userId!, referenceId }]);
|
|
55
|
+
|
|
56
|
+
return true;
|
|
57
|
+
};
|
|
58
|
+
/* end_public_function */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './createReaction';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './onLiveReactionCreated';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api';
|
|
2
|
+
import { createEventSubscriber } from '~/core/events';
|
|
3
|
+
/**
|
|
4
|
+
* ```js
|
|
5
|
+
* import { onLiveReactionCreated } from '@amityco/ts-sdk'
|
|
6
|
+
* const dispose = onLiveReactionCreated(reactions => {
|
|
7
|
+
* // ...
|
|
8
|
+
* })
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Fired when a batch of {@link Amity.LiveReaction} has been created
|
|
12
|
+
*
|
|
13
|
+
* @param callback The function to call when the event was fired
|
|
14
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
15
|
+
*
|
|
16
|
+
* @category Live Reaction Events
|
|
17
|
+
*/
|
|
18
|
+
export const onLiveReactionCreated = (
|
|
19
|
+
callback: Amity.Listener<Amity.LiveReaction[]>,
|
|
20
|
+
): Amity.Unsubscriber => {
|
|
21
|
+
const client = getActiveClient();
|
|
22
|
+
|
|
23
|
+
const filter = (rawPayload: Amity.LiveReactionPayload) => {
|
|
24
|
+
if (rawPayload.reactions.length > 0) {
|
|
25
|
+
// TODO: check with BE if user id is internal or pulbic id
|
|
26
|
+
const filteredPayload = rawPayload.reactions.filter(({ userId }) => userId !== client.userId);
|
|
27
|
+
callback(filteredPayload);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return createEventSubscriber(
|
|
32
|
+
client,
|
|
33
|
+
'live_reaction/onLiveReactionCreated',
|
|
34
|
+
'liveReaction.created',
|
|
35
|
+
filter,
|
|
36
|
+
);
|
|
37
|
+
};
|