-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathChannelBatchUpdater.java
More file actions
231 lines (216 loc) · 8.43 KB
/
ChannelBatchUpdater.java
File metadata and controls
231 lines (216 loc) · 8.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
package io.getstream.chat.java.models;
import io.getstream.chat.java.models.Channel.*;
import java.util.ArrayList;
import java.util.List;
import org.jetbrains.annotations.NotNull;
/** Provides convenience methods for batch channel operations. */
public class ChannelBatchUpdater {
/**
* Adds members to channels matching the filter.
*
* @param filter the filter to match channels
* @param members list of members to add
* @return the batch update request
*/
@NotNull
public ChannelsBatchUpdateRequest addMembers(
@NotNull ChannelsBatchFilters filter, @NotNull List<ChannelBatchMemberRequest> members) {
ChannelsBatchOptions options = new ChannelsBatchOptions();
options.setOperation(ChannelBatchOperation.ADD_MEMBERS);
options.setFilter(filter);
options.setMembers(members != null ? new ArrayList<>(members) : null);
return Channel.updateBatch(options);
}
/**
* Removes members from channels matching the filter.
*
* @param filter the filter to match channels
* @param members list of members to remove
* @return the batch update request
*/
@NotNull
public ChannelsBatchUpdateRequest removeMembers(
@NotNull ChannelsBatchFilters filter, @NotNull List<ChannelBatchMemberRequest> members) {
ChannelsBatchOptions options = new ChannelsBatchOptions();
options.setOperation(ChannelBatchOperation.REMOVE_MEMBERS);
options.setFilter(filter);
options.setMembers(members != null ? new ArrayList<>(members) : null);
return Channel.updateBatch(options);
}
/**
* Invites members to channels matching the filter.
*
* @param filter the filter to match channels
* @param members list of members to invite
* @return the batch update request
*/
@NotNull
public ChannelsBatchUpdateRequest inviteMembers(
@NotNull ChannelsBatchFilters filter, @NotNull List<ChannelBatchMemberRequest> members) {
ChannelsBatchOptions options = new ChannelsBatchOptions();
options.setOperation(ChannelBatchOperation.INVITE_MEMBERS);
options.setFilter(filter);
options.setMembers(members != null ? new ArrayList<>(members) : null);
return Channel.updateBatch(options);
}
/**
* Adds moderators to channels matching the filter.
*
* @param filter the filter to match channels
* @param members list of members to add as moderators
* @return the batch update request
*/
@NotNull
public ChannelsBatchUpdateRequest addModerators(
@NotNull ChannelsBatchFilters filter, @NotNull List<ChannelBatchMemberRequest> members) {
ChannelsBatchOptions options = new ChannelsBatchOptions();
options.setOperation(ChannelBatchOperation.ADD_MODERATORS);
options.setFilter(filter);
options.setMembers(members != null ? new ArrayList<>(members) : null);
return Channel.updateBatch(options);
}
/**
* Removes moderator role from members in channels matching the filter.
*
* @param filter the filter to match channels
* @param members list of members to demote from moderators
* @return the batch update request
*/
@NotNull
public ChannelsBatchUpdateRequest demoteModerators(
@NotNull ChannelsBatchFilters filter, @NotNull List<ChannelBatchMemberRequest> members) {
ChannelsBatchOptions options = new ChannelsBatchOptions();
options.setOperation(ChannelBatchOperation.DEMOTE_MODERATORS);
options.setFilter(filter);
options.setMembers(members != null ? new ArrayList<>(members) : null);
return Channel.updateBatch(options);
}
/**
* Assigns roles to members in channels matching the filter.
*
* @param filter the filter to match channels
* @param members list of members with roles to assign
* @return the batch update request
*/
@NotNull
public ChannelsBatchUpdateRequest assignRoles(
@NotNull ChannelsBatchFilters filter, @NotNull List<ChannelBatchMemberRequest> members) {
ChannelsBatchOptions options = new ChannelsBatchOptions();
options.setOperation(ChannelBatchOperation.ASSIGN_ROLES);
options.setFilter(filter);
options.setMembers(members != null ? new ArrayList<>(members) : null);
return Channel.updateBatch(options);
}
/**
* Hides channels matching the filter for the specified members.
*
* @param filter the filter to match channels
* @param members list of members for whom to hide channels
* @return the batch update request
*/
@NotNull
public ChannelsBatchUpdateRequest hide(
@NotNull ChannelsBatchFilters filter, @NotNull List<ChannelBatchMemberRequest> members) {
ChannelsBatchOptions options = new ChannelsBatchOptions();
options.setOperation(ChannelBatchOperation.HIDE);
options.setFilter(filter);
options.setMembers(members != null ? new ArrayList<>(members) : null);
return Channel.updateBatch(options);
}
/**
* Shows channels matching the filter for the specified members.
*
* @param filter the filter to match channels
* @param members list of members for whom to show channels
* @return the batch update request
*/
@NotNull
public ChannelsBatchUpdateRequest show(
@NotNull ChannelsBatchFilters filter, @NotNull List<ChannelBatchMemberRequest> members) {
ChannelsBatchOptions options = new ChannelsBatchOptions();
options.setOperation(ChannelBatchOperation.SHOW);
options.setFilter(filter);
options.setMembers(members != null ? new ArrayList<>(members) : null);
return Channel.updateBatch(options);
}
/**
* Archives channels matching the filter for the specified members.
*
* @param filter the filter to match channels
* @param members list of members for whom to archive channels
* @return the batch update request
*/
@NotNull
public ChannelsBatchUpdateRequest archive(
@NotNull ChannelsBatchFilters filter, @NotNull List<ChannelBatchMemberRequest> members) {
ChannelsBatchOptions options = new ChannelsBatchOptions();
options.setOperation(ChannelBatchOperation.ARCHIVE);
options.setFilter(filter);
options.setMembers(members != null ? new ArrayList<>(members) : null);
return Channel.updateBatch(options);
}
/**
* Unarchives channels matching the filter for the specified members.
*
* @param filter the filter to match channels
* @param members list of members for whom to unarchive channels
* @return the batch update request
*/
@NotNull
public ChannelsBatchUpdateRequest unarchive(
@NotNull ChannelsBatchFilters filter, @NotNull List<ChannelBatchMemberRequest> members) {
ChannelsBatchOptions options = new ChannelsBatchOptions();
options.setOperation(ChannelBatchOperation.UNARCHIVE);
options.setFilter(filter);
options.setMembers(members != null ? new ArrayList<>(members) : null);
return Channel.updateBatch(options);
}
/**
* Updates data on channels matching the filter.
*
* @param filter the filter to match channels
* @param data channel data to update
* @return the batch update request
*/
@NotNull
public ChannelsBatchUpdateRequest updateData(
@NotNull ChannelsBatchFilters filter, @NotNull ChannelDataUpdate data) {
ChannelsBatchOptions options = new ChannelsBatchOptions();
options.setOperation(ChannelBatchOperation.UPDATE_DATA);
options.setFilter(filter);
options.setData(data);
return Channel.updateBatch(options);
}
/**
* Adds filter tags to channels matching the filter.
*
* @param filter the filter to match channels
* @param tags list of filter tags to add
* @return the batch update request
*/
@NotNull
public ChannelsBatchUpdateRequest addFilterTags(
@NotNull ChannelsBatchFilters filter, @NotNull List<String> tags) {
ChannelsBatchOptions options = new ChannelsBatchOptions();
options.setOperation(ChannelBatchOperation.ADD_FILTER_TAGS);
options.setFilter(filter);
options.setFilterTagsUpdate(tags != null ? new ArrayList<>(tags) : null);
return Channel.updateBatch(options);
}
/**
* Removes filter tags from channels matching the filter.
*
* @param filter the filter to match channels
* @param tags list of filter tags to remove
* @return the batch update request
*/
@NotNull
public ChannelsBatchUpdateRequest removeFilterTags(
@NotNull ChannelsBatchFilters filter, @NotNull List<String> tags) {
ChannelsBatchOptions options = new ChannelsBatchOptions();
options.setOperation(ChannelBatchOperation.REMOVE_FILTER_TAGS);
options.setFilter(filter);
options.setFilterTagsUpdate(tags != null ? new ArrayList<>(tags) : null);
return Channel.updateBatch(options);
}
}