|
| 1 | +package stream_chat |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | +) |
| 6 | + |
| 7 | +// ChannelBatchUpdater provides convenience methods for batch channel operations. |
| 8 | +type ChannelBatchUpdater struct { |
| 9 | + client *Client |
| 10 | +} |
| 11 | + |
| 12 | +// AddMembers adds members to channels matching the filter. |
| 13 | +func (u *ChannelBatchUpdater) AddMembers(ctx context.Context, filter UpdateChannelsBatchFilters, members interface{}) (*UpdateChannelsBatchResponse, error) { |
| 14 | + options := &UpdateChannelsBatchOptions{ |
| 15 | + Operation: BatchUpdateOperationAddMembers, |
| 16 | + Filter: filter, |
| 17 | + Members: members, |
| 18 | + } |
| 19 | + return u.client.UpdateChannelsBatch(ctx, options) |
| 20 | +} |
| 21 | + |
| 22 | +// RemoveMembers removes members from channels matching the filter. |
| 23 | +func (u *ChannelBatchUpdater) RemoveMembers(ctx context.Context, filter UpdateChannelsBatchFilters, members []string) (*UpdateChannelsBatchResponse, error) { |
| 24 | + options := &UpdateChannelsBatchOptions{ |
| 25 | + Operation: BatchUpdateOperationRemoveMembers, |
| 26 | + Filter: filter, |
| 27 | + Members: members, |
| 28 | + } |
| 29 | + return u.client.UpdateChannelsBatch(ctx, options) |
| 30 | +} |
| 31 | + |
| 32 | +// InviteMembers invites members to channels matching the filter. |
| 33 | +func (u *ChannelBatchUpdater) InviteMembers(ctx context.Context, filter UpdateChannelsBatchFilters, members interface{}) (*UpdateChannelsBatchResponse, error) { |
| 34 | + options := &UpdateChannelsBatchOptions{ |
| 35 | + Operation: BatchUpdateOperationInvites, |
| 36 | + Filter: filter, |
| 37 | + Members: members, |
| 38 | + } |
| 39 | + return u.client.UpdateChannelsBatch(ctx, options) |
| 40 | +} |
| 41 | + |
| 42 | +// AddModerators adds moderators to channels matching the filter. |
| 43 | +func (u *ChannelBatchUpdater) AddModerators(ctx context.Context, filter UpdateChannelsBatchFilters, members []string) (*UpdateChannelsBatchResponse, error) { |
| 44 | + options := &UpdateChannelsBatchOptions{ |
| 45 | + Operation: BatchUpdateOperationAddModerators, |
| 46 | + Filter: filter, |
| 47 | + Members: members, |
| 48 | + } |
| 49 | + return u.client.UpdateChannelsBatch(ctx, options) |
| 50 | +} |
| 51 | + |
| 52 | +// DemoteModerators removes moderator role from members in channels matching the filter. |
| 53 | +func (u *ChannelBatchUpdater) DemoteModerators(ctx context.Context, filter UpdateChannelsBatchFilters, members []string) (*UpdateChannelsBatchResponse, error) { |
| 54 | + options := &UpdateChannelsBatchOptions{ |
| 55 | + Operation: BatchUpdateOperationDemoteModerators, |
| 56 | + Filter: filter, |
| 57 | + Members: members, |
| 58 | + } |
| 59 | + return u.client.UpdateChannelsBatch(ctx, options) |
| 60 | +} |
| 61 | + |
| 62 | +// AssignRoles assigns roles to members in channels matching the filter. |
| 63 | +func (u *ChannelBatchUpdater) AssignRoles(ctx context.Context, filter UpdateChannelsBatchFilters, members []*ChannelMember) (*UpdateChannelsBatchResponse, error) { |
| 64 | + options := &UpdateChannelsBatchOptions{ |
| 65 | + Operation: BatchUpdateOperationAssignRoles, |
| 66 | + Filter: filter, |
| 67 | + Members: members, |
| 68 | + } |
| 69 | + return u.client.UpdateChannelsBatch(ctx, options) |
| 70 | +} |
| 71 | + |
| 72 | +// Hide hides channels matching the filter. |
| 73 | +func (u *ChannelBatchUpdater) Hide(ctx context.Context, filter UpdateChannelsBatchFilters) (*UpdateChannelsBatchResponse, error) { |
| 74 | + options := &UpdateChannelsBatchOptions{ |
| 75 | + Operation: BatchUpdateOperationHide, |
| 76 | + Filter: filter, |
| 77 | + } |
| 78 | + return u.client.UpdateChannelsBatch(ctx, options) |
| 79 | +} |
| 80 | + |
| 81 | +// Show shows channels matching the filter. |
| 82 | +func (u *ChannelBatchUpdater) Show(ctx context.Context, filter UpdateChannelsBatchFilters) (*UpdateChannelsBatchResponse, error) { |
| 83 | + options := &UpdateChannelsBatchOptions{ |
| 84 | + Operation: BatchUpdateOperationShow, |
| 85 | + Filter: filter, |
| 86 | + } |
| 87 | + return u.client.UpdateChannelsBatch(ctx, options) |
| 88 | +} |
| 89 | + |
| 90 | +// Archive archives channels matching the filter. |
| 91 | +func (u *ChannelBatchUpdater) Archive(ctx context.Context, filter UpdateChannelsBatchFilters) (*UpdateChannelsBatchResponse, error) { |
| 92 | + options := &UpdateChannelsBatchOptions{ |
| 93 | + Operation: BatchUpdateOperationArchive, |
| 94 | + Filter: filter, |
| 95 | + } |
| 96 | + return u.client.UpdateChannelsBatch(ctx, options) |
| 97 | +} |
| 98 | + |
| 99 | +// Unarchive unarchives channels matching the filter. |
| 100 | +func (u *ChannelBatchUpdater) Unarchive(ctx context.Context, filter UpdateChannelsBatchFilters) (*UpdateChannelsBatchResponse, error) { |
| 101 | + options := &UpdateChannelsBatchOptions{ |
| 102 | + Operation: BatchUpdateOperationUnarchive, |
| 103 | + Filter: filter, |
| 104 | + } |
| 105 | + return u.client.UpdateChannelsBatch(ctx, options) |
| 106 | +} |
| 107 | + |
| 108 | +// UpdateData updates data on channels matching the filter. |
| 109 | +func (u *ChannelBatchUpdater) UpdateData(ctx context.Context, filter UpdateChannelsBatchFilters, data *BatchChannelDataUpdate) (*UpdateChannelsBatchResponse, error) { |
| 110 | + options := &UpdateChannelsBatchOptions{ |
| 111 | + Operation: BatchUpdateOperationUpdateData, |
| 112 | + Filter: filter, |
| 113 | + Data: data, |
| 114 | + } |
| 115 | + return u.client.UpdateChannelsBatch(ctx, options) |
| 116 | +} |
| 117 | + |
| 118 | +// AddFilterTags adds filter tags to channels matching the filter. |
| 119 | +func (u *ChannelBatchUpdater) AddFilterTags(ctx context.Context, filter UpdateChannelsBatchFilters, tags []string) (*UpdateChannelsBatchResponse, error) { |
| 120 | + options := &UpdateChannelsBatchOptions{ |
| 121 | + Operation: BatchUpdateOperationAddFilterTags, |
| 122 | + Filter: filter, |
| 123 | + FilterTagsUpdate: tags, |
| 124 | + } |
| 125 | + return u.client.UpdateChannelsBatch(ctx, options) |
| 126 | +} |
| 127 | + |
| 128 | +// RemoveFilterTags removes filter tags from channels matching the filter. |
| 129 | +func (u *ChannelBatchUpdater) RemoveFilterTags(ctx context.Context, filter UpdateChannelsBatchFilters, tags []string) (*UpdateChannelsBatchResponse, error) { |
| 130 | + options := &UpdateChannelsBatchOptions{ |
| 131 | + Operation: BatchUpdateOperationRemoveFilterTags, |
| 132 | + Filter: filter, |
| 133 | + FilterTagsUpdate: tags, |
| 134 | + } |
| 135 | + return u.client.UpdateChannelsBatch(ctx, options) |
| 136 | +} |
| 137 | + |
0 commit comments