stream-chat 4.27.0__py3-none-any.whl → 4.29.0__py3-none-any.whl
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.
- stream_chat/__pkg__.py +1 -1
- stream_chat/async_chat/channel_batch_updater.py +242 -0
- stream_chat/async_chat/client.py +31 -1
- stream_chat/base/channel.py +2 -2
- stream_chat/base/client.py +21 -0
- stream_chat/channel_batch_updater.py +242 -0
- stream_chat/client.py +38 -2
- stream_chat/types/channel_batch.py +93 -0
- {stream_chat-4.27.0.dist-info → stream_chat-4.29.0.dist-info}/METADATA +2 -2
- {stream_chat-4.27.0.dist-info → stream_chat-4.29.0.dist-info}/RECORD +13 -10
- {stream_chat-4.27.0.dist-info → stream_chat-4.29.0.dist-info}/WHEEL +0 -0
- {stream_chat-4.27.0.dist-info → stream_chat-4.29.0.dist-info}/licenses/LICENSE +0 -0
- {stream_chat-4.27.0.dist-info → stream_chat-4.29.0.dist-info}/top_level.txt +0 -0
stream_chat/__pkg__.py
CHANGED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
from typing import TYPE_CHECKING, List
|
|
2
|
+
|
|
3
|
+
from stream_chat.types.channel_batch import (
|
|
4
|
+
ChannelBatchMemberRequest,
|
|
5
|
+
ChannelDataUpdate,
|
|
6
|
+
ChannelsBatchFilters,
|
|
7
|
+
ChannelsBatchOptions,
|
|
8
|
+
)
|
|
9
|
+
from stream_chat.types.stream_response import StreamResponse
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from stream_chat.async_chat.client import StreamChatAsync
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ChannelBatchUpdater:
|
|
16
|
+
"""
|
|
17
|
+
Provides convenience methods for batch channel operations (async).
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
def __init__(self, client: "StreamChatAsync") -> None:
|
|
21
|
+
self.client = client
|
|
22
|
+
|
|
23
|
+
async def add_members(
|
|
24
|
+
self, filter: ChannelsBatchFilters, members: List[ChannelBatchMemberRequest]
|
|
25
|
+
) -> StreamResponse:
|
|
26
|
+
"""
|
|
27
|
+
Adds members to channels matching the filter.
|
|
28
|
+
|
|
29
|
+
:param filter: The filter to match channels.
|
|
30
|
+
:param members: List of members to add.
|
|
31
|
+
:return: StreamResponse containing task_id.
|
|
32
|
+
"""
|
|
33
|
+
options: ChannelsBatchOptions = {
|
|
34
|
+
"operation": "addMembers",
|
|
35
|
+
"filter": filter,
|
|
36
|
+
"members": members,
|
|
37
|
+
}
|
|
38
|
+
return await self.client.update_channels_batch(options)
|
|
39
|
+
|
|
40
|
+
async def remove_members(
|
|
41
|
+
self, filter: ChannelsBatchFilters, members: List[ChannelBatchMemberRequest]
|
|
42
|
+
) -> StreamResponse:
|
|
43
|
+
"""
|
|
44
|
+
Removes members from channels matching the filter.
|
|
45
|
+
|
|
46
|
+
:param filter: The filter to match channels.
|
|
47
|
+
:param members: List of members to remove.
|
|
48
|
+
:return: StreamResponse containing task_id.
|
|
49
|
+
"""
|
|
50
|
+
options: ChannelsBatchOptions = {
|
|
51
|
+
"operation": "removeMembers",
|
|
52
|
+
"filter": filter,
|
|
53
|
+
"members": members,
|
|
54
|
+
}
|
|
55
|
+
return await self.client.update_channels_batch(options)
|
|
56
|
+
|
|
57
|
+
async def invite_members(
|
|
58
|
+
self, filter: ChannelsBatchFilters, members: List[ChannelBatchMemberRequest]
|
|
59
|
+
) -> StreamResponse:
|
|
60
|
+
"""
|
|
61
|
+
Invites members to channels matching the filter.
|
|
62
|
+
|
|
63
|
+
:param filter: The filter to match channels.
|
|
64
|
+
:param members: List of members to invite.
|
|
65
|
+
:return: StreamResponse containing task_id.
|
|
66
|
+
"""
|
|
67
|
+
options: ChannelsBatchOptions = {
|
|
68
|
+
"operation": "inviteMembers",
|
|
69
|
+
"filter": filter,
|
|
70
|
+
"members": members,
|
|
71
|
+
}
|
|
72
|
+
return await self.client.update_channels_batch(options)
|
|
73
|
+
|
|
74
|
+
async def add_moderators(
|
|
75
|
+
self, filter: ChannelsBatchFilters, members: List[ChannelBatchMemberRequest]
|
|
76
|
+
) -> StreamResponse:
|
|
77
|
+
"""
|
|
78
|
+
Adds moderators to channels matching the filter.
|
|
79
|
+
|
|
80
|
+
:param filter: The filter to match channels.
|
|
81
|
+
:param members: List of members to add as moderators.
|
|
82
|
+
:return: StreamResponse containing task_id.
|
|
83
|
+
"""
|
|
84
|
+
options: ChannelsBatchOptions = {
|
|
85
|
+
"operation": "addModerators",
|
|
86
|
+
"filter": filter,
|
|
87
|
+
"members": members,
|
|
88
|
+
}
|
|
89
|
+
return await self.client.update_channels_batch(options)
|
|
90
|
+
|
|
91
|
+
async def demote_moderators(
|
|
92
|
+
self, filter: ChannelsBatchFilters, members: List[ChannelBatchMemberRequest]
|
|
93
|
+
) -> StreamResponse:
|
|
94
|
+
"""
|
|
95
|
+
Removes moderator role from members in channels matching the filter.
|
|
96
|
+
|
|
97
|
+
:param filter: The filter to match channels.
|
|
98
|
+
:param members: List of members to demote from moderators.
|
|
99
|
+
:return: StreamResponse containing task_id.
|
|
100
|
+
"""
|
|
101
|
+
options: ChannelsBatchOptions = {
|
|
102
|
+
"operation": "demoteModerators",
|
|
103
|
+
"filter": filter,
|
|
104
|
+
"members": members,
|
|
105
|
+
}
|
|
106
|
+
return await self.client.update_channels_batch(options)
|
|
107
|
+
|
|
108
|
+
async def assign_roles(
|
|
109
|
+
self, filter: ChannelsBatchFilters, members: List[ChannelBatchMemberRequest]
|
|
110
|
+
) -> StreamResponse:
|
|
111
|
+
"""
|
|
112
|
+
Assigns roles to members in channels matching the filter.
|
|
113
|
+
|
|
114
|
+
:param filter: The filter to match channels.
|
|
115
|
+
:param members: List of members with roles to assign.
|
|
116
|
+
:return: StreamResponse containing task_id.
|
|
117
|
+
"""
|
|
118
|
+
options: ChannelsBatchOptions = {
|
|
119
|
+
"operation": "assignRoles",
|
|
120
|
+
"filter": filter,
|
|
121
|
+
"members": members,
|
|
122
|
+
}
|
|
123
|
+
return await self.client.update_channels_batch(options)
|
|
124
|
+
|
|
125
|
+
async def hide(
|
|
126
|
+
self, filter: ChannelsBatchFilters, members: List[ChannelBatchMemberRequest]
|
|
127
|
+
) -> StreamResponse:
|
|
128
|
+
"""
|
|
129
|
+
Hides channels matching the filter for the specified members.
|
|
130
|
+
|
|
131
|
+
:param filter: The filter to match channels.
|
|
132
|
+
:param members: List of members for whom to hide channels.
|
|
133
|
+
:return: StreamResponse containing task_id.
|
|
134
|
+
"""
|
|
135
|
+
options: ChannelsBatchOptions = {
|
|
136
|
+
"operation": "hide",
|
|
137
|
+
"filter": filter,
|
|
138
|
+
"members": members,
|
|
139
|
+
}
|
|
140
|
+
return await self.client.update_channels_batch(options)
|
|
141
|
+
|
|
142
|
+
async def show(
|
|
143
|
+
self, filter: ChannelsBatchFilters, members: List[ChannelBatchMemberRequest]
|
|
144
|
+
) -> StreamResponse:
|
|
145
|
+
"""
|
|
146
|
+
Shows channels matching the filter for the specified members.
|
|
147
|
+
|
|
148
|
+
:param filter: The filter to match channels.
|
|
149
|
+
:param members: List of members for whom to show channels.
|
|
150
|
+
:return: StreamResponse containing task_id.
|
|
151
|
+
"""
|
|
152
|
+
options: ChannelsBatchOptions = {
|
|
153
|
+
"operation": "show",
|
|
154
|
+
"filter": filter,
|
|
155
|
+
"members": members,
|
|
156
|
+
}
|
|
157
|
+
return await self.client.update_channels_batch(options)
|
|
158
|
+
|
|
159
|
+
async def archive(
|
|
160
|
+
self, filter: ChannelsBatchFilters, members: List[ChannelBatchMemberRequest]
|
|
161
|
+
) -> StreamResponse:
|
|
162
|
+
"""
|
|
163
|
+
Archives channels matching the filter for the specified members.
|
|
164
|
+
|
|
165
|
+
:param filter: The filter to match channels.
|
|
166
|
+
:param members: List of members for whom to archive channels.
|
|
167
|
+
:return: StreamResponse containing task_id.
|
|
168
|
+
"""
|
|
169
|
+
options: ChannelsBatchOptions = {
|
|
170
|
+
"operation": "archive",
|
|
171
|
+
"filter": filter,
|
|
172
|
+
"members": members,
|
|
173
|
+
}
|
|
174
|
+
return await self.client.update_channels_batch(options)
|
|
175
|
+
|
|
176
|
+
async def unarchive(
|
|
177
|
+
self, filter: ChannelsBatchFilters, members: List[ChannelBatchMemberRequest]
|
|
178
|
+
) -> StreamResponse:
|
|
179
|
+
"""
|
|
180
|
+
Unarchives channels matching the filter for the specified members.
|
|
181
|
+
|
|
182
|
+
:param filter: The filter to match channels.
|
|
183
|
+
:param members: List of members for whom to unarchive channels.
|
|
184
|
+
:return: StreamResponse containing task_id.
|
|
185
|
+
"""
|
|
186
|
+
options: ChannelsBatchOptions = {
|
|
187
|
+
"operation": "unarchive",
|
|
188
|
+
"filter": filter,
|
|
189
|
+
"members": members,
|
|
190
|
+
}
|
|
191
|
+
return await self.client.update_channels_batch(options)
|
|
192
|
+
|
|
193
|
+
async def update_data(
|
|
194
|
+
self, filter: ChannelsBatchFilters, data: ChannelDataUpdate
|
|
195
|
+
) -> StreamResponse:
|
|
196
|
+
"""
|
|
197
|
+
Updates data on channels matching the filter.
|
|
198
|
+
|
|
199
|
+
:param filter: The filter to match channels.
|
|
200
|
+
:param data: Channel data to update.
|
|
201
|
+
:return: StreamResponse containing task_id.
|
|
202
|
+
"""
|
|
203
|
+
options: ChannelsBatchOptions = {
|
|
204
|
+
"operation": "updateData",
|
|
205
|
+
"filter": filter,
|
|
206
|
+
"data": data,
|
|
207
|
+
}
|
|
208
|
+
return await self.client.update_channels_batch(options)
|
|
209
|
+
|
|
210
|
+
async def add_filter_tags(
|
|
211
|
+
self, filter: ChannelsBatchFilters, tags: List[str]
|
|
212
|
+
) -> StreamResponse:
|
|
213
|
+
"""
|
|
214
|
+
Adds filter tags to channels matching the filter.
|
|
215
|
+
|
|
216
|
+
:param filter: The filter to match channels.
|
|
217
|
+
:param tags: List of filter tags to add.
|
|
218
|
+
:return: StreamResponse containing task_id.
|
|
219
|
+
"""
|
|
220
|
+
options: ChannelsBatchOptions = {
|
|
221
|
+
"operation": "addFilterTags",
|
|
222
|
+
"filter": filter,
|
|
223
|
+
"filter_tags_update": tags,
|
|
224
|
+
}
|
|
225
|
+
return await self.client.update_channels_batch(options)
|
|
226
|
+
|
|
227
|
+
async def remove_filter_tags(
|
|
228
|
+
self, filter: ChannelsBatchFilters, tags: List[str]
|
|
229
|
+
) -> StreamResponse:
|
|
230
|
+
"""
|
|
231
|
+
Removes filter tags from channels matching the filter.
|
|
232
|
+
|
|
233
|
+
:param filter: The filter to match channels.
|
|
234
|
+
:param tags: List of filter tags to remove.
|
|
235
|
+
:return: StreamResponse containing task_id.
|
|
236
|
+
"""
|
|
237
|
+
options: ChannelsBatchOptions = {
|
|
238
|
+
"operation": "removeFilterTags",
|
|
239
|
+
"filter": filter,
|
|
240
|
+
"filter_tags_update": tags,
|
|
241
|
+
}
|
|
242
|
+
return await self.client.update_channels_batch(options)
|
stream_chat/async_chat/client.py
CHANGED
|
@@ -4,6 +4,7 @@ import sys
|
|
|
4
4
|
import warnings
|
|
5
5
|
from types import TracebackType
|
|
6
6
|
from typing import (
|
|
7
|
+
TYPE_CHECKING,
|
|
7
8
|
Any,
|
|
8
9
|
AsyncContextManager,
|
|
9
10
|
Callable,
|
|
@@ -15,12 +16,17 @@ from typing import (
|
|
|
15
16
|
Union,
|
|
16
17
|
cast,
|
|
17
18
|
)
|
|
19
|
+
|
|
20
|
+
if TYPE_CHECKING:
|
|
21
|
+
from stream_chat.async_chat.channel_batch_updater import ChannelBatchUpdater
|
|
22
|
+
|
|
18
23
|
from urllib.parse import urlparse
|
|
19
24
|
|
|
20
25
|
from stream_chat.async_chat.campaign import Campaign
|
|
21
26
|
from stream_chat.async_chat.segment import Segment
|
|
22
27
|
from stream_chat.types.base import SortParam
|
|
23
28
|
from stream_chat.types.campaign import CampaignData, QueryCampaignsOptions
|
|
29
|
+
from stream_chat.types.channel_batch import ChannelsBatchOptions
|
|
24
30
|
from stream_chat.types.draft import QueryDraftsFilter, QueryDraftsOptions
|
|
25
31
|
from stream_chat.types.segment import (
|
|
26
32
|
QuerySegmentsOptions,
|
|
@@ -965,7 +971,7 @@ class StreamChatAsync(StreamChatInterface, AsyncContextManager):
|
|
|
965
971
|
:return: API response with reminders
|
|
966
972
|
"""
|
|
967
973
|
params = options.copy()
|
|
968
|
-
params["
|
|
974
|
+
params["filter"] = filter_conditions or {}
|
|
969
975
|
params["sort"] = sort or [{"field": "remind_at", "direction": 1}]
|
|
970
976
|
params["user_id"] = user_id
|
|
971
977
|
return await self.post("reminders/query", data=params)
|
|
@@ -1028,6 +1034,30 @@ class StreamChatAsync(StreamChatInterface, AsyncContextManager):
|
|
|
1028
1034
|
|
|
1029
1035
|
return await self.mark_delivered(data)
|
|
1030
1036
|
|
|
1037
|
+
async def update_channels_batch(
|
|
1038
|
+
self, options: ChannelsBatchOptions
|
|
1039
|
+
) -> StreamResponse:
|
|
1040
|
+
"""
|
|
1041
|
+
Updates channels in batch based on the provided options.
|
|
1042
|
+
|
|
1043
|
+
:param options: ChannelsBatchOptions containing operation, filter, and operation-specific data.
|
|
1044
|
+
:return: StreamResponse containing task_id.
|
|
1045
|
+
"""
|
|
1046
|
+
if options is None:
|
|
1047
|
+
raise ValueError("options must not be None")
|
|
1048
|
+
|
|
1049
|
+
return await self.put("channels/batch", data=options)
|
|
1050
|
+
|
|
1051
|
+
def channel_batch_updater(self) -> "ChannelBatchUpdater":
|
|
1052
|
+
"""
|
|
1053
|
+
Returns a ChannelBatchUpdater instance for batch channel operations.
|
|
1054
|
+
|
|
1055
|
+
:return: ChannelBatchUpdater instance.
|
|
1056
|
+
"""
|
|
1057
|
+
from stream_chat.async_chat.channel_batch_updater import ChannelBatchUpdater
|
|
1058
|
+
|
|
1059
|
+
return ChannelBatchUpdater(self)
|
|
1060
|
+
|
|
1031
1061
|
async def close(self) -> None:
|
|
1032
1062
|
await self.session.close()
|
|
1033
1063
|
|
stream_chat/base/channel.py
CHANGED
|
@@ -284,11 +284,11 @@ class ChannelInterface(abc.ABC):
|
|
|
284
284
|
self, user_id: str, **data: Any
|
|
285
285
|
) -> Union[StreamResponse, Awaitable[StreamResponse]]:
|
|
286
286
|
"""
|
|
287
|
-
Marks channel as unread from a specific message or
|
|
287
|
+
Marks channel as unread from a specific message, thread, or timestamp, if thread_id is provided in data
|
|
288
288
|
a thread will be searched, otherwise a message.
|
|
289
289
|
|
|
290
290
|
:param user_id: the user ID for the event
|
|
291
|
-
:param data: additional data, ie {"message_id": last_message_id}
|
|
291
|
+
:param data: additional data, ie {"message_id": last_message_id}, {"thread_id": thread_id}, or {"message_timestamp": timestamp}
|
|
292
292
|
:return: The server response
|
|
293
293
|
"""
|
|
294
294
|
pass
|
stream_chat/base/client.py
CHANGED
|
@@ -1302,6 +1302,27 @@ class StreamChatInterface(abc.ABC):
|
|
|
1302
1302
|
"""
|
|
1303
1303
|
pass
|
|
1304
1304
|
|
|
1305
|
+
@abc.abstractmethod
|
|
1306
|
+
def update_channels_batch(
|
|
1307
|
+
self, options: Any
|
|
1308
|
+
) -> Union[StreamResponse, Awaitable[StreamResponse]]:
|
|
1309
|
+
"""
|
|
1310
|
+
Updates channels in batch based on the provided options.
|
|
1311
|
+
|
|
1312
|
+
:param options: ChannelsBatchOptions containing operation, filter, and operation-specific data.
|
|
1313
|
+
:return: StreamResponse containing task_id.
|
|
1314
|
+
"""
|
|
1315
|
+
pass
|
|
1316
|
+
|
|
1317
|
+
@abc.abstractmethod
|
|
1318
|
+
def channel_batch_updater(self) -> Any:
|
|
1319
|
+
"""
|
|
1320
|
+
Returns a ChannelBatchUpdater instance for batch channel operations.
|
|
1321
|
+
|
|
1322
|
+
:return: ChannelBatchUpdater instance.
|
|
1323
|
+
"""
|
|
1324
|
+
pass
|
|
1325
|
+
|
|
1305
1326
|
@abc.abstractmethod
|
|
1306
1327
|
def send_user_custom_event(
|
|
1307
1328
|
self, user_id: str, event: Dict
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
from typing import TYPE_CHECKING, List
|
|
2
|
+
|
|
3
|
+
from stream_chat.types.channel_batch import (
|
|
4
|
+
ChannelBatchMemberRequest,
|
|
5
|
+
ChannelDataUpdate,
|
|
6
|
+
ChannelsBatchFilters,
|
|
7
|
+
ChannelsBatchOptions,
|
|
8
|
+
)
|
|
9
|
+
from stream_chat.types.stream_response import StreamResponse
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from stream_chat.client import StreamChat
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ChannelBatchUpdater:
|
|
16
|
+
"""
|
|
17
|
+
Provides convenience methods for batch channel operations.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
def __init__(self, client: "StreamChat") -> None:
|
|
21
|
+
self.client = client
|
|
22
|
+
|
|
23
|
+
def add_members(
|
|
24
|
+
self, filter: ChannelsBatchFilters, members: List[ChannelBatchMemberRequest]
|
|
25
|
+
) -> StreamResponse:
|
|
26
|
+
"""
|
|
27
|
+
Adds members to channels matching the filter.
|
|
28
|
+
|
|
29
|
+
:param filter: The filter to match channels.
|
|
30
|
+
:param members: List of members to add.
|
|
31
|
+
:return: StreamResponse containing task_id.
|
|
32
|
+
"""
|
|
33
|
+
options: ChannelsBatchOptions = {
|
|
34
|
+
"operation": "addMembers",
|
|
35
|
+
"filter": filter,
|
|
36
|
+
"members": members,
|
|
37
|
+
}
|
|
38
|
+
return self.client.update_channels_batch(options)
|
|
39
|
+
|
|
40
|
+
def remove_members(
|
|
41
|
+
self, filter: ChannelsBatchFilters, members: List[ChannelBatchMemberRequest]
|
|
42
|
+
) -> StreamResponse:
|
|
43
|
+
"""
|
|
44
|
+
Removes members from channels matching the filter.
|
|
45
|
+
|
|
46
|
+
:param filter: The filter to match channels.
|
|
47
|
+
:param members: List of members to remove.
|
|
48
|
+
:return: StreamResponse containing task_id.
|
|
49
|
+
"""
|
|
50
|
+
options: ChannelsBatchOptions = {
|
|
51
|
+
"operation": "removeMembers",
|
|
52
|
+
"filter": filter,
|
|
53
|
+
"members": members,
|
|
54
|
+
}
|
|
55
|
+
return self.client.update_channels_batch(options)
|
|
56
|
+
|
|
57
|
+
def invite_members(
|
|
58
|
+
self, filter: ChannelsBatchFilters, members: List[ChannelBatchMemberRequest]
|
|
59
|
+
) -> StreamResponse:
|
|
60
|
+
"""
|
|
61
|
+
Invites members to channels matching the filter.
|
|
62
|
+
|
|
63
|
+
:param filter: The filter to match channels.
|
|
64
|
+
:param members: List of members to invite.
|
|
65
|
+
:return: StreamResponse containing task_id.
|
|
66
|
+
"""
|
|
67
|
+
options: ChannelsBatchOptions = {
|
|
68
|
+
"operation": "inviteMembers",
|
|
69
|
+
"filter": filter,
|
|
70
|
+
"members": members,
|
|
71
|
+
}
|
|
72
|
+
return self.client.update_channels_batch(options)
|
|
73
|
+
|
|
74
|
+
def add_moderators(
|
|
75
|
+
self, filter: ChannelsBatchFilters, members: List[ChannelBatchMemberRequest]
|
|
76
|
+
) -> StreamResponse:
|
|
77
|
+
"""
|
|
78
|
+
Adds moderators to channels matching the filter.
|
|
79
|
+
|
|
80
|
+
:param filter: The filter to match channels.
|
|
81
|
+
:param members: List of members to add as moderators.
|
|
82
|
+
:return: StreamResponse containing task_id.
|
|
83
|
+
"""
|
|
84
|
+
options: ChannelsBatchOptions = {
|
|
85
|
+
"operation": "addModerators",
|
|
86
|
+
"filter": filter,
|
|
87
|
+
"members": members,
|
|
88
|
+
}
|
|
89
|
+
return self.client.update_channels_batch(options)
|
|
90
|
+
|
|
91
|
+
def demote_moderators(
|
|
92
|
+
self, filter: ChannelsBatchFilters, members: List[ChannelBatchMemberRequest]
|
|
93
|
+
) -> StreamResponse:
|
|
94
|
+
"""
|
|
95
|
+
Removes moderator role from members in channels matching the filter.
|
|
96
|
+
|
|
97
|
+
:param filter: The filter to match channels.
|
|
98
|
+
:param members: List of members to demote from moderators.
|
|
99
|
+
:return: StreamResponse containing task_id.
|
|
100
|
+
"""
|
|
101
|
+
options: ChannelsBatchOptions = {
|
|
102
|
+
"operation": "demoteModerators",
|
|
103
|
+
"filter": filter,
|
|
104
|
+
"members": members,
|
|
105
|
+
}
|
|
106
|
+
return self.client.update_channels_batch(options)
|
|
107
|
+
|
|
108
|
+
def assign_roles(
|
|
109
|
+
self, filter: ChannelsBatchFilters, members: List[ChannelBatchMemberRequest]
|
|
110
|
+
) -> StreamResponse:
|
|
111
|
+
"""
|
|
112
|
+
Assigns roles to members in channels matching the filter.
|
|
113
|
+
|
|
114
|
+
:param filter: The filter to match channels.
|
|
115
|
+
:param members: List of members with roles to assign.
|
|
116
|
+
:return: StreamResponse containing task_id.
|
|
117
|
+
"""
|
|
118
|
+
options: ChannelsBatchOptions = {
|
|
119
|
+
"operation": "assignRoles",
|
|
120
|
+
"filter": filter,
|
|
121
|
+
"members": members,
|
|
122
|
+
}
|
|
123
|
+
return self.client.update_channels_batch(options)
|
|
124
|
+
|
|
125
|
+
def hide(
|
|
126
|
+
self, filter: ChannelsBatchFilters, members: List[ChannelBatchMemberRequest]
|
|
127
|
+
) -> StreamResponse:
|
|
128
|
+
"""
|
|
129
|
+
Hides channels matching the filter for the specified members.
|
|
130
|
+
|
|
131
|
+
:param filter: The filter to match channels.
|
|
132
|
+
:param members: List of members for whom to hide channels.
|
|
133
|
+
:return: StreamResponse containing task_id.
|
|
134
|
+
"""
|
|
135
|
+
options: ChannelsBatchOptions = {
|
|
136
|
+
"operation": "hide",
|
|
137
|
+
"filter": filter,
|
|
138
|
+
"members": members,
|
|
139
|
+
}
|
|
140
|
+
return self.client.update_channels_batch(options)
|
|
141
|
+
|
|
142
|
+
def show(
|
|
143
|
+
self, filter: ChannelsBatchFilters, members: List[ChannelBatchMemberRequest]
|
|
144
|
+
) -> StreamResponse:
|
|
145
|
+
"""
|
|
146
|
+
Shows channels matching the filter for the specified members.
|
|
147
|
+
|
|
148
|
+
:param filter: The filter to match channels.
|
|
149
|
+
:param members: List of members for whom to show channels.
|
|
150
|
+
:return: StreamResponse containing task_id.
|
|
151
|
+
"""
|
|
152
|
+
options: ChannelsBatchOptions = {
|
|
153
|
+
"operation": "show",
|
|
154
|
+
"filter": filter,
|
|
155
|
+
"members": members,
|
|
156
|
+
}
|
|
157
|
+
return self.client.update_channels_batch(options)
|
|
158
|
+
|
|
159
|
+
def archive(
|
|
160
|
+
self, filter: ChannelsBatchFilters, members: List[ChannelBatchMemberRequest]
|
|
161
|
+
) -> StreamResponse:
|
|
162
|
+
"""
|
|
163
|
+
Archives channels matching the filter for the specified members.
|
|
164
|
+
|
|
165
|
+
:param filter: The filter to match channels.
|
|
166
|
+
:param members: List of members for whom to archive channels.
|
|
167
|
+
:return: StreamResponse containing task_id.
|
|
168
|
+
"""
|
|
169
|
+
options: ChannelsBatchOptions = {
|
|
170
|
+
"operation": "archive",
|
|
171
|
+
"filter": filter,
|
|
172
|
+
"members": members,
|
|
173
|
+
}
|
|
174
|
+
return self.client.update_channels_batch(options)
|
|
175
|
+
|
|
176
|
+
def unarchive(
|
|
177
|
+
self, filter: ChannelsBatchFilters, members: List[ChannelBatchMemberRequest]
|
|
178
|
+
) -> StreamResponse:
|
|
179
|
+
"""
|
|
180
|
+
Unarchives channels matching the filter for the specified members.
|
|
181
|
+
|
|
182
|
+
:param filter: The filter to match channels.
|
|
183
|
+
:param members: List of members for whom to unarchive channels.
|
|
184
|
+
:return: StreamResponse containing task_id.
|
|
185
|
+
"""
|
|
186
|
+
options: ChannelsBatchOptions = {
|
|
187
|
+
"operation": "unarchive",
|
|
188
|
+
"filter": filter,
|
|
189
|
+
"members": members,
|
|
190
|
+
}
|
|
191
|
+
return self.client.update_channels_batch(options)
|
|
192
|
+
|
|
193
|
+
def update_data(
|
|
194
|
+
self, filter: ChannelsBatchFilters, data: ChannelDataUpdate
|
|
195
|
+
) -> StreamResponse:
|
|
196
|
+
"""
|
|
197
|
+
Updates data on channels matching the filter.
|
|
198
|
+
|
|
199
|
+
:param filter: The filter to match channels.
|
|
200
|
+
:param data: Channel data to update.
|
|
201
|
+
:return: StreamResponse containing task_id.
|
|
202
|
+
"""
|
|
203
|
+
options: ChannelsBatchOptions = {
|
|
204
|
+
"operation": "updateData",
|
|
205
|
+
"filter": filter,
|
|
206
|
+
"data": data,
|
|
207
|
+
}
|
|
208
|
+
return self.client.update_channels_batch(options)
|
|
209
|
+
|
|
210
|
+
def add_filter_tags(
|
|
211
|
+
self, filter: ChannelsBatchFilters, tags: List[str]
|
|
212
|
+
) -> StreamResponse:
|
|
213
|
+
"""
|
|
214
|
+
Adds filter tags to channels matching the filter.
|
|
215
|
+
|
|
216
|
+
:param filter: The filter to match channels.
|
|
217
|
+
:param tags: List of filter tags to add.
|
|
218
|
+
:return: StreamResponse containing task_id.
|
|
219
|
+
"""
|
|
220
|
+
options: ChannelsBatchOptions = {
|
|
221
|
+
"operation": "addFilterTags",
|
|
222
|
+
"filter": filter,
|
|
223
|
+
"filter_tags_update": tags,
|
|
224
|
+
}
|
|
225
|
+
return self.client.update_channels_batch(options)
|
|
226
|
+
|
|
227
|
+
def remove_filter_tags(
|
|
228
|
+
self, filter: ChannelsBatchFilters, tags: List[str]
|
|
229
|
+
) -> StreamResponse:
|
|
230
|
+
"""
|
|
231
|
+
Removes filter tags from channels matching the filter.
|
|
232
|
+
|
|
233
|
+
:param filter: The filter to match channels.
|
|
234
|
+
:param tags: List of filter tags to remove.
|
|
235
|
+
:return: StreamResponse containing task_id.
|
|
236
|
+
"""
|
|
237
|
+
options: ChannelsBatchOptions = {
|
|
238
|
+
"operation": "removeFilterTags",
|
|
239
|
+
"filter": filter,
|
|
240
|
+
"filter_tags_update": tags,
|
|
241
|
+
}
|
|
242
|
+
return self.client.update_channels_batch(options)
|
stream_chat/client.py
CHANGED
|
@@ -2,14 +2,28 @@ import datetime
|
|
|
2
2
|
import json
|
|
3
3
|
import sys
|
|
4
4
|
import warnings
|
|
5
|
-
from typing import
|
|
5
|
+
from typing import (
|
|
6
|
+
TYPE_CHECKING,
|
|
7
|
+
Any,
|
|
8
|
+
Callable,
|
|
9
|
+
Dict,
|
|
10
|
+
Iterable,
|
|
11
|
+
List,
|
|
12
|
+
Optional,
|
|
13
|
+
Union,
|
|
14
|
+
cast,
|
|
15
|
+
)
|
|
6
16
|
from urllib.parse import urlparse
|
|
7
17
|
from urllib.request import Request, urlopen
|
|
8
18
|
|
|
19
|
+
if TYPE_CHECKING:
|
|
20
|
+
from stream_chat.channel_batch_updater import ChannelBatchUpdater
|
|
21
|
+
|
|
9
22
|
from stream_chat.campaign import Campaign
|
|
10
23
|
from stream_chat.segment import Segment
|
|
11
24
|
from stream_chat.types.base import SortParam
|
|
12
25
|
from stream_chat.types.campaign import CampaignData, QueryCampaignsOptions
|
|
26
|
+
from stream_chat.types.channel_batch import ChannelsBatchOptions
|
|
13
27
|
from stream_chat.types.draft import QueryDraftsFilter, QueryDraftsOptions
|
|
14
28
|
from stream_chat.types.segment import (
|
|
15
29
|
QuerySegmentsOptions,
|
|
@@ -919,7 +933,7 @@ class StreamChat(StreamChatInterface):
|
|
|
919
933
|
:return: API response with reminders
|
|
920
934
|
"""
|
|
921
935
|
params = options.copy()
|
|
922
|
-
params["
|
|
936
|
+
params["filter"] = filter_conditions or {}
|
|
923
937
|
params["sort"] = sort or [{"field": "remind_at", "direction": 1}]
|
|
924
938
|
params["user_id"] = user_id
|
|
925
939
|
return self.post("reminders/query", data=params)
|
|
@@ -985,3 +999,25 @@ class StreamChat(StreamChatInterface):
|
|
|
985
999
|
"user_id": user_id,
|
|
986
1000
|
}
|
|
987
1001
|
return self.mark_delivered(data=data)
|
|
1002
|
+
|
|
1003
|
+
def update_channels_batch(self, options: ChannelsBatchOptions) -> StreamResponse:
|
|
1004
|
+
"""
|
|
1005
|
+
Updates channels in batch based on the provided options.
|
|
1006
|
+
|
|
1007
|
+
:param options: ChannelsBatchOptions containing operation, filter, and operation-specific data.
|
|
1008
|
+
:return: StreamResponse containing task_id.
|
|
1009
|
+
"""
|
|
1010
|
+
if options is None:
|
|
1011
|
+
raise ValueError("options must not be None")
|
|
1012
|
+
|
|
1013
|
+
return self.put("channels/batch", data=options)
|
|
1014
|
+
|
|
1015
|
+
def channel_batch_updater(self) -> "ChannelBatchUpdater":
|
|
1016
|
+
"""
|
|
1017
|
+
Returns a ChannelBatchUpdater instance for batch channel operations.
|
|
1018
|
+
|
|
1019
|
+
:return: ChannelBatchUpdater instance.
|
|
1020
|
+
"""
|
|
1021
|
+
from stream_chat.channel_batch_updater import ChannelBatchUpdater
|
|
1022
|
+
|
|
1023
|
+
return ChannelBatchUpdater(self)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from typing import Any, Dict, List, Optional
|
|
3
|
+
|
|
4
|
+
if sys.version_info >= (3, 8):
|
|
5
|
+
from typing import Literal, TypedDict
|
|
6
|
+
else:
|
|
7
|
+
from typing_extensions import Literal, TypedDict
|
|
8
|
+
|
|
9
|
+
ChannelBatchOperation = Literal[
|
|
10
|
+
"addMembers",
|
|
11
|
+
"removeMembers",
|
|
12
|
+
"inviteMembers",
|
|
13
|
+
"assignRoles",
|
|
14
|
+
"addModerators",
|
|
15
|
+
"demoteModerators",
|
|
16
|
+
"hide",
|
|
17
|
+
"show",
|
|
18
|
+
"archive",
|
|
19
|
+
"unarchive",
|
|
20
|
+
"updateData",
|
|
21
|
+
"addFilterTags",
|
|
22
|
+
"removeFilterTags",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class ChannelBatchMemberRequest(TypedDict, total=False):
|
|
27
|
+
"""
|
|
28
|
+
Represents a member in batch operations.
|
|
29
|
+
|
|
30
|
+
Parameters:
|
|
31
|
+
user_id: The ID of the user.
|
|
32
|
+
channel_role: The role of the user in the channel (optional).
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
user_id: str
|
|
36
|
+
channel_role: Optional[str]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class ChannelDataUpdate(TypedDict, total=False):
|
|
40
|
+
"""
|
|
41
|
+
Represents data that can be updated on channels in batch.
|
|
42
|
+
|
|
43
|
+
Parameters:
|
|
44
|
+
frozen: Whether the channel is frozen.
|
|
45
|
+
disabled: Whether the channel is disabled.
|
|
46
|
+
custom: Custom data for the channel.
|
|
47
|
+
team: The team ID for the channel.
|
|
48
|
+
config_overrides: Configuration overrides for the channel.
|
|
49
|
+
auto_translation_enabled: Whether auto-translation is enabled.
|
|
50
|
+
auto_translation_language: The language for auto-translation.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
frozen: Optional[bool]
|
|
54
|
+
disabled: Optional[bool]
|
|
55
|
+
custom: Optional[Dict[str, Any]]
|
|
56
|
+
team: Optional[str]
|
|
57
|
+
config_overrides: Optional[Dict[str, Any]]
|
|
58
|
+
auto_translation_enabled: Optional[bool]
|
|
59
|
+
auto_translation_language: Optional[str]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class ChannelsBatchFilters(TypedDict, total=False):
|
|
63
|
+
"""
|
|
64
|
+
Represents filters for batch channel updates.
|
|
65
|
+
|
|
66
|
+
Parameters:
|
|
67
|
+
cids: Filter by channel CIDs (can be a dict with operators like $in).
|
|
68
|
+
types: Filter by channel types (can be a dict with operators like $in).
|
|
69
|
+
filter_tags: Filter by filter tags (can be a dict with operators like $in).
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
cids: Optional[Any]
|
|
73
|
+
types: Optional[Any]
|
|
74
|
+
filter_tags: Optional[Any]
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class ChannelsBatchOptions(TypedDict, total=False):
|
|
78
|
+
"""
|
|
79
|
+
Represents options for batch channel updates.
|
|
80
|
+
|
|
81
|
+
Parameters:
|
|
82
|
+
operation: The batch operation to perform (required).
|
|
83
|
+
filter: The filter to match channels (required).
|
|
84
|
+
members: List of members for member-related operations (optional).
|
|
85
|
+
data: Channel data updates for updateData operation (optional).
|
|
86
|
+
filter_tags_update: List of filter tags for filter tag operations (optional).
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
operation: ChannelBatchOperation
|
|
90
|
+
filter: ChannelsBatchFilters
|
|
91
|
+
members: Optional[List[ChannelBatchMemberRequest]]
|
|
92
|
+
data: Optional[ChannelDataUpdate]
|
|
93
|
+
filter_tags_update: Optional[List[str]]
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: stream-chat
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.29.0
|
|
4
4
|
Summary: Client for Stream Chat.
|
|
5
5
|
Home-page: https://github.com/GetStream/stream-chat-python
|
|
6
6
|
Author: Tommaso Barbugli
|
|
7
7
|
Author-email: support@getstream.io
|
|
8
8
|
Project-URL: Bug Tracker, https://github.com/GetStream/stream-chat-python/issues
|
|
9
9
|
Project-URL: Documentation, https://getstream.io/activity-feeds/docs/python/?language=python
|
|
10
|
-
Project-URL: Release Notes, https://github.com/GetStream/stream-chat-python/releases/tag/v4.
|
|
10
|
+
Project-URL: Release Notes, https://github.com/GetStream/stream-chat-python/releases/tag/v4.29.0
|
|
11
11
|
Classifier: Intended Audience :: Developers
|
|
12
12
|
Classifier: Intended Audience :: System Administrators
|
|
13
13
|
Classifier: Operating System :: OS Independent
|
|
@@ -1,34 +1,37 @@
|
|
|
1
1
|
stream_chat/__init__.py,sha256=xYQuC8xcPLJxJnFWzaNaO-sVUc7IJZYe13OIPRaDBEA,116
|
|
2
|
-
stream_chat/__pkg__.py,sha256=
|
|
2
|
+
stream_chat/__pkg__.py,sha256=8cnvJc4Zln03zsTmgM1cga5doADhiHe3q7MxtOkTlSg,206
|
|
3
3
|
stream_chat/campaign.py,sha256=Z7bBo2rGMs02JkA1k9_206J0spcSLecjdhQuRnrc2Eo,2156
|
|
4
4
|
stream_chat/channel.py,sha256=40q61hI0A0iy_Q2Xdv6D94oSG47Bu1PYaBXMRX2k03g,11059
|
|
5
|
-
stream_chat/
|
|
5
|
+
stream_chat/channel_batch_updater.py,sha256=QkO7MlIsD0q0krox_zKqKrqNNsB0wiSRKiwIXALdyd0,8216
|
|
6
|
+
stream_chat/client.py,sha256=-IZduXIKFarCHsyGK_Cw888Sd9uiQNasYLC25rFoqTM,38294
|
|
6
7
|
stream_chat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
8
|
stream_chat/query_threads.py,sha256=zz0w7DnTq0FR8OAvNkPH7Q1CSYaWOtoP_NAa8JgsKtE,542
|
|
8
9
|
stream_chat/segment.py,sha256=MD1de83rVsaqxcyPy8wTXDudFjxz5Mvr70z4pTkW3P0,2691
|
|
9
10
|
stream_chat/async_chat/__init__.py,sha256=V6x7yDCdXbP3vMuSan6Xm7RE_njZUvflImqOxfKRt4Y,67
|
|
10
11
|
stream_chat/async_chat/campaign.py,sha256=Bc3iHZigxserUycZK4wDuXU0wXVH2G6fIDiYNVYPkeE,1885
|
|
11
12
|
stream_chat/async_chat/channel.py,sha256=20dj1jQVm6dU_VUDpFJ1rUqxZVJtLhQeFxjJvcFm56s,11525
|
|
12
|
-
stream_chat/async_chat/
|
|
13
|
+
stream_chat/async_chat/channel_batch_updater.py,sha256=UiPHN8j49tn15RnjxqUBW6p6Ee3enMmvbNZn3gNWEBY,8401
|
|
14
|
+
stream_chat/async_chat/client.py,sha256=uWck1sxCgp_KmWCgQ05Kn0MmrFvOAJBrQkxkac98Gqo,40451
|
|
13
15
|
stream_chat/async_chat/segment.py,sha256=G_YEwW2SXIE7huTW3Zu_rim2XkYcuFNYekLZZGDjFkA,2777
|
|
14
16
|
stream_chat/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
17
|
stream_chat/base/campaign.py,sha256=dAVkTYyirEpgyOPn8JyDebNMKeJu02vTuqgmPvdQoWU,1449
|
|
16
|
-
stream_chat/base/channel.py,sha256=
|
|
17
|
-
stream_chat/base/client.py,sha256=
|
|
18
|
+
stream_chat/base/channel.py,sha256=zaVhpVHXW-e3GHCqOtQO8x2yHqqAQ6MKP-AZXarQOUc,17805
|
|
19
|
+
stream_chat/base/client.py,sha256=YPqpNlaPYr-QifVPImUh4ZFGtUoEpV8AV3N8bi6P_Ew,49023
|
|
18
20
|
stream_chat/base/exceptions.py,sha256=eh1qW5d6zjUrlgsHNEBebAr0jVH2UupZ06w8sp2cseI,819
|
|
19
21
|
stream_chat/base/query_threads.py,sha256=LfC09Atsw6cwL98MJjL-cGzQU4V1r7CRbRLitgBV-x8,934
|
|
20
22
|
stream_chat/base/segment.py,sha256=X82DX8Y-cERJ1OvF2tz9iIM4CBNW6tx8HGaTEXBva9I,2364
|
|
21
23
|
stream_chat/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
24
|
stream_chat/types/base.py,sha256=JKlOxQVPvMClTo0ev63Ya-K-dX-98j95qSE-KKzziEE,858
|
|
23
25
|
stream_chat/types/campaign.py,sha256=3Hsgf3SGKA5jh-szQkGLJlmIuswKVTFQBW7vxpJVu-g,2795
|
|
26
|
+
stream_chat/types/channel_batch.py,sha256=KskaIJCwQMXjanJaFOA3q5ipAgQjhw_RiNpyTmv6k_E,2714
|
|
24
27
|
stream_chat/types/delivery_receipts.py,sha256=ir1EYIvRCKo2pw5nMPJ_JNJck1c_9xRXOANEW_803gk,1607
|
|
25
28
|
stream_chat/types/draft.py,sha256=EJP1JkCtDFnz-DTC8p7WFWXfTazA8x5XKE7ghag7gJM,288
|
|
26
29
|
stream_chat/types/rate_limit.py,sha256=v3Z4Ur0yoEdFLiHa1CNABEej2nxPlHQ6Bpy2XxW-TYQ,165
|
|
27
30
|
stream_chat/types/segment.py,sha256=KzOi5N-VzLfj0m4zeZ9U_29ey9dxDtewtcNv9g4Aums,1273
|
|
28
31
|
stream_chat/types/shared_locations.py,sha256=2rO4e0G1RX9DXGHcg3HJt5gp33G-LRKox62hfc0skGA,200
|
|
29
32
|
stream_chat/types/stream_response.py,sha256=jWKPrOU7u6dZ2SyOK53uQCXTstrL1HshO9fA7R6Bt_A,2391
|
|
30
|
-
stream_chat-4.
|
|
31
|
-
stream_chat-4.
|
|
32
|
-
stream_chat-4.
|
|
33
|
-
stream_chat-4.
|
|
34
|
-
stream_chat-4.
|
|
33
|
+
stream_chat-4.29.0.dist-info/licenses/LICENSE,sha256=H66SBDuPWSRHzKPEdyjAk3C0THQRcGPfqqve4naQuu0,14424
|
|
34
|
+
stream_chat-4.29.0.dist-info/METADATA,sha256=r3T-WT0XDCPg5M_ZHhUrTskgTmLJiWlGgn7c3YveWmU,7638
|
|
35
|
+
stream_chat-4.29.0.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
|
|
36
|
+
stream_chat-4.29.0.dist-info/top_level.txt,sha256=26uTfg4bWcEaFrVKlzGGgfONH1p5DDe21G07EKfYSvo,12
|
|
37
|
+
stream_chat-4.29.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|