@@ -171,7 +171,9 @@ func (m *Mattermost) FetchGroupsAndSyncables(ctx context.Context) ([]Group, erro
171171 Name : ch .Name ,
172172 MembershipUnmanaged : false ,
173173 }
174- m .GroupStore .SaveChannel (ctx , chInfo )
174+ if err := m .GroupStore .SaveChannel (ctx , chInfo ); err != nil {
175+ l .WithError (err ).WithField ("channelInfo" , chInfo ).Error ("failed to save additional channel info" )
176+ }
175177 }
176178 channelInfo [ch .Id ] = chInfo
177179 knownChannels .Add (ch .Name )
@@ -206,18 +208,19 @@ func (m *Mattermost) FetchGroupsAndSyncables(ctx context.Context) ([]Group, erro
206208 })
207209 if appErr != nil {
208210 return nil , fmt .Errorf ("creating default public channel for team %v: %w" , t .Name , appErr )
209- } else {
210- allChannels = append (allChannels , ch )
211211 }
212- m .GroupStore .SaveChannel (ctx , & datastore.ChannelInfo {
212+ allChannels = append (allChannels , ch )
213+ if err := m .GroupStore .SaveChannel (ctx , & datastore.ChannelInfo {
213214 ID : ch .Id ,
214215 Name : t .Name ,
215216 MembershipUnmanaged : false ,
216- })
217+ }); err != nil {
218+ l .WithError (err ).WithField ("channel_id" , ch .Id ).WithField ("channel_name" , t .Name ).Error ("Failed to create default public channel metadata" )
219+ }
217220 }
218221 privName := t .Name + "-private"
219222 if ! knownChannels .Contains (privName ) {
220- // Create the default public channel for this team.
223+ // Create the default private channel for this team.
221224 ch , appErr := m .API .CreateChannel (& model.Channel {
222225 TeamId : theTeam .Id ,
223226 Type : model .ChannelTypePrivate ,
@@ -226,14 +229,15 @@ func (m *Mattermost) FetchGroupsAndSyncables(ctx context.Context) ([]Group, erro
226229 })
227230 if appErr != nil {
228231 return nil , fmt .Errorf ("creating default private channel %v for team %v: %w" , privName , t .Name , appErr )
229- } else {
230- allChannels = append (allChannels , ch )
231232 }
232- m .GroupStore .SaveChannel (ctx , & datastore.ChannelInfo {
233+ allChannels = append (allChannels , ch )
234+ if err := m .GroupStore .SaveChannel (ctx , & datastore.ChannelInfo {
233235 ID : ch .Id ,
234236 Name : privName ,
235237 MembershipUnmanaged : false ,
236- })
238+ }); err != nil {
239+ l .WithError (err ).WithField ("channel_id" , ch .Id ).WithField ("channel_name" , t .Name ).Error ("Failed to create default private channel metadata" )
240+ }
237241 }
238242 }
239243
@@ -361,7 +365,7 @@ func (m *Mattermost) ensureCredentials(ctx context.Context) error {
361365
362366 roles := u .GetRawRoles ()
363367 if ! u .IsInRole ("system_admin" ) {
364- roles = roles + " system_admin"
368+ roles += " system_admin"
365369 }
366370 sess := & model.Session {
367371 UserId : u .Id ,
0 commit comments