@@ -136,12 +136,15 @@ func (s *GroupService) CreateChannel(
136136 return nil , err
137137 }
138138 // check if ack is successful
139- if ack := response .GetAck (); ack != nil {
140- if ! ack .Success {
141- return nil , fmt .Errorf ("failed to create channel: %s" , ack .Messages )
142- }
143- logAckMessage (ctx , ack )
144- zlog .Debug ().Msgf ("Channel created successfully: %s" , channelName )
139+ ack := response .GetAck ()
140+ if ack == nil {
141+ zlog .Debug ().Msg ("failed to create channel: ack is nil" )
142+ return nil , fmt .Errorf ("failed to create channel" )
143+ }
144+ logAckMessage (ctx , ack )
145+ zlog .Debug ().Msgf ("Channel creation result for %s: success=%t" , channelName , ack .Success )
146+ if ! ack .Success {
147+ return nil , fmt .Errorf ("failed to create channel: %s" , ack .Messages )
145148 }
146149
147150 // Saving channel to DB
@@ -207,12 +210,15 @@ func (s *GroupService) DeleteChannel(
207210 return nil , err
208211 }
209212 // check if ack is successful
210- if ack := response .GetAck (); ack != nil {
211- if ! ack .Success {
212- return nil , fmt .Errorf ("failed to delete participant: %s" , ack .Messages )
213- }
214- logAckMessage (ctx , ack )
215- zlog .Debug ().Msg ("Ack message received, channel deleted successfully." )
213+ ack := response .GetAck ()
214+ if ack == nil {
215+ zlog .Debug ().Msg ("failed to delete channel: ack is nil" )
216+ return nil , fmt .Errorf ("failed to delete channel" )
217+ }
218+ logAckMessage (ctx , ack )
219+ zlog .Debug ().Msgf ("Channel deletion result for %s: success=%t" , deleteChannelRequest .ChannelName , ack .Success )
220+ if ! ack .Success {
221+ return ack , nil
216222 }
217223
218224 err = s .dbService .DeleteChannel (deleteChannelRequest .ChannelName )
@@ -221,9 +227,7 @@ func (s *GroupService) DeleteChannel(
221227 }
222228 zlog .Debug ().Msg ("Channel deleted successfully." )
223229
224- return & controllerapi.Ack {
225- Success : true ,
226- }, nil
230+ return ack , nil
227231}
228232
229233func (s * GroupService ) AddParticipant (
@@ -282,12 +286,15 @@ func (s *GroupService) AddParticipant(
282286 return nil , err
283287 }
284288 // check if ack is successful
285- if ack := response .GetAck (); ack != nil {
286- if ! ack .Success {
287- return nil , fmt .Errorf ("failed to add participant: %s" , ack .Messages )
288- }
289- logAckMessage (ctx , ack )
290- zlog .Debug ().Msg ("Ack message received, participant added successfully." )
289+ ack := response .GetAck ()
290+ if ack == nil {
291+ zlog .Debug ().Msg ("failed to add participant: ack is nil" )
292+ return nil , fmt .Errorf ("failed to add participant" )
293+ }
294+ logAckMessage (ctx , ack )
295+ zlog .Debug ().Msgf ("AddParticipant result success=%t" , ack .Success )
296+ if ! ack .Success {
297+ return ack , nil
291298 }
292299
293300 if slices .Contains (channel .Participants , addParticipantRequest .ParticipantName ) {
@@ -302,9 +309,7 @@ func (s *GroupService) AddParticipant(
302309 }
303310 zlog .Debug ().Msg ("Channel updated, participant added successfully." )
304311
305- return & controllerapi.Ack {
306- Success : true ,
307- }, nil
312+ return ack , nil
308313}
309314
310315func (s * GroupService ) DeleteParticipant (
@@ -369,14 +374,16 @@ func (s *GroupService) DeleteParticipant(
369374 return nil , err
370375 }
371376 // check if ack is successful
372- if ack := response .GetAck (); ack != nil {
373- if ! ack .Success {
374- return nil , fmt .Errorf ("failed to delete participant: %s" , ack .Messages )
375- }
376- logAckMessage (ctx , ack )
377- zlog .Debug ().Msg ("Ack message received, participant deleted successfully." )
377+ ack := response .GetAck ()
378+ if ack == nil {
379+ zlog .Debug ().Msg ("failed to delete participant: ack is nil" )
380+ return nil , fmt .Errorf ("failed to delete participant" )
381+ }
382+ logAckMessage (ctx , ack )
383+ zlog .Debug ().Msgf ("DeleteParticipant result success=%t" , ack .Success )
384+ if ! ack .Success {
385+ return ack , nil
378386 }
379-
380387 // Control plane side DB operations
381388 channel .Participants = append (channel .Participants [:foundIdx ], channel .Participants [foundIdx + 1 :]... )
382389
@@ -386,9 +393,7 @@ func (s *GroupService) DeleteParticipant(
386393 }
387394 zlog .Debug ().Msg ("Channel updated, participant deleted successfully." )
388395
389- return & controllerapi.Ack {
390- Success : true ,
391- }, nil
396+ return ack , nil
392397}
393398
394399func (s * GroupService ) ListChannels (
0 commit comments