Skip to content

Commit

Permalink
remove teams on op-owner-leave
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudkucooland committed Apr 25, 2023
1 parent 9f2814d commit 28266cb
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion model/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,28 @@ func (teamID TeamID) RemoveAgent(in AgentID) error {
messaging.AgentDeleteOperation(messaging.GoogleID(gid), messaging.OperationID(opID))
}

// log.Debugw("removing agent from team", "GID", gid, "resource", teamID, "message", "removing agent from team")
// remove this team from ops the agent owns
oprows, err := db.Query("SELECT ID FROM operation WHERE gid = ?", gid)
if err != nil && err != sql.ErrNoRows {
log.Error(err)
return err
}
defer oprows.Close()

for oprows.Next() {
var ID OperationID
err = rows.Scan(&ID)

This comment has been minimized.

Copy link
@le-jeu

le-jeu Apr 25, 2023

Member

should it be oprows ?

This comment has been minimized.

Copy link
@cloudkucooland

cloudkucooland Apr 25, 2023

Author Member

yes, yes it should.

if err != nil {
log.Error(err)
return err
}

if _, err := db.Exec("DELETE FROM permissions WHERE teamID = ? AND opID = ?", teamID, ID); err != nil {
log.Error(err)
return err
}
}

return nil
}

Expand Down

0 comments on commit 28266cb

Please sign in to comment.