Skip to content

Commit

Permalink
Rebase with MG-2304
Browse files Browse the repository at this point in the history
Signed-off-by: nyagamunene <[email protected]>
  • Loading branch information
nyagamunene committed Aug 26, 2024
1 parent a0d4d91 commit 3ff6161
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions bootstrap/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ import (

"github.com/absmach/magistrala"
"github.com/absmach/magistrala/auth"
"github.com/absmach/magistrala/pkg/clients"
"github.com/absmach/magistrala/pkg/errors"
repoerr "github.com/absmach/magistrala/pkg/errors/repository"
svcerr "github.com/absmach/magistrala/pkg/errors/service"
mgsdk "github.com/absmach/magistrala/pkg/sdk/go"
)

const (
allConn = "all_connected"
)

var (
// ErrThings indicates failure to communicate with Magistrala Things service.
// It can be due to networking error or invalid/unauthenticated request.
Expand Down Expand Up @@ -476,14 +473,14 @@ func (bs bootstrapService) ConnectThingHandler(ctx context.Context, channelID, t
}
ch := bs.toIDList(channels)
resp, err := bs.tauth.VerifyConnections(ctx, &magistrala.VerifyConnectionsReq{
ThingsId: []string{thingID},
GroupsId: ch,
ThingIds: []string{thingID},
GroupIds: ch,
})
if err != nil {
return err
}

if resp.Status == allConn {
if resp.Status == clients.AllConnectedState.String() {
if err := bs.configs.ConnectThing(ctx, channelID, thingID); err != nil {
return errors.Wrap(errConnectThing, err)
}
Expand All @@ -499,13 +496,13 @@ func (bs bootstrapService) DisconnectThingHandler(ctx context.Context, channelID
}
ch := bs.toIDList(channels)
resp, err := bs.tauth.VerifyConnections(ctx, &magistrala.VerifyConnectionsReq{
ThingsId: []string{thingID},
GroupsId: ch,
ThingIds: []string{thingID},
GroupIds: ch,
})
if err != nil {
return err
}
if resp.Status != allConn {
if resp.Status != clients.AllConnectedState.String() {
if err := bs.configs.DisconnectThing(ctx, channelID, thingID); err != nil {
return errors.Wrap(errDisconnectThing, err)
}
Expand Down

0 comments on commit 3ff6161

Please sign in to comment.