@@ -99,7 +99,10 @@ type userItem struct {
9999 UpdatedAt time.Time `json:"updated_at"`
100100 DeletedAt * time.Time `json:"deleted_at"`
101101 DeactivatedAt * time.Time `json:"deactivated_at"`
102+ Language string `json:"language"`
102103 Teams []string `json:"teams"`
104+ ChannelMutes []string `json:"channel_mutes"`
105+ UserMutes []string `json:"user_mutes"`
103106 PushNotifications pushNotification `json:"push_notifications"`
104107 Custom extraFields
105108}
@@ -138,9 +141,37 @@ func (u *userItem) validateReferences(idx *index) error {
138141 if ! idx .roleExist (u .Role ) {
139142 return fmt .Errorf ("user.role %q doesn't exist (user %q)" , u .Role , u .ID )
140143 }
144+
145+ if len (u .ChannelMutes ) > 0 {
146+ for _ , ch := range u .ChannelMutes {
147+ typ , id , err := splitChannelCID (ch )
148+ if err != nil {
149+ return err
150+ }
151+ if ! idx .channelExist (typ , id ) {
152+ return fmt .Errorf ("muted channel %q by user %q doesn't exist" , ch , u .ID )
153+ }
154+ }
155+ }
156+ if len (u .UserMutes ) > 0 {
157+ for _ , mutedUserID := range u .UserMutes {
158+ if ! idx .userExist (mutedUserID ) {
159+ return fmt .Errorf ("muted user %q by user %q doesn't exist" , mutedUserID , u .ID )
160+ }
161+ }
162+ }
141163 return nil
142164}
143165
166+ // splitChannelCID returns channel type and channel ID from channel CID
167+ func splitChannelCID (cid string ) (string , string , error ) {
168+ s := strings .Split (cid , ":" )
169+ if len (s ) != 2 {
170+ return "" , "" , fmt .Errorf (`channel %q should have the following format "type:id"` , cid )
171+ }
172+ return s [0 ], s [1 ], nil
173+ }
174+
144175type deviceItem struct {
145176 ID string `json:"id"`
146177 UserID string `json:"user_id"`
0 commit comments