TP-45804 : Update get teams api to send team and pse oncall info (#253)
This commit is contained in:
6
service/response/bot_response.go
Normal file
6
service/response/bot_response.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package service
|
||||
|
||||
type BotResponse struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
@@ -16,6 +16,8 @@ type TeamResponse struct {
|
||||
WebhookSlackChannelName string `json:"webhookSlackChannelName"`
|
||||
WebhookSlackChannelId string `json:"webhookSlackChannelId"`
|
||||
ManagerId string `json:"managerId"`
|
||||
Oncall BotResponse `json:"oncall"`
|
||||
PseOncall BotResponse `json:"pse_oncall"`
|
||||
}
|
||||
|
||||
func ConvertToTeamResponse(teamEntity team.TeamEntity) TeamResponse {
|
||||
|
||||
@@ -208,6 +208,31 @@ func (t *TeamService) GetTeams(c *gin.Context) {
|
||||
} else {
|
||||
teamResponse.WebhookSlackChannelName = channel.Name
|
||||
}
|
||||
|
||||
oncallBots, err := t.client.GetUsersInfo(team.OncallHandle)
|
||||
|
||||
if err != nil || *oncallBots == nil || isUserInvalid(&(*oncallBots)[0], err) {
|
||||
t.logger.Error(fmt.Sprintf("error in GetUsersInfo for oncall bot of id: %v", team.OncallHandle))
|
||||
} else {
|
||||
oncallBotData := &(*oncallBots)[0]
|
||||
teamResponse.Oncall = service.BotResponse{
|
||||
Id: oncallBotData.ID,
|
||||
Name: oncallBotData.RealName,
|
||||
}
|
||||
}
|
||||
|
||||
pseOncallBots, err := t.client.GetUsersInfo(team.PseOncallHandle)
|
||||
|
||||
if err != nil || *pseOncallBots == nil || isUserInvalid(&(*pseOncallBots)[0], err) {
|
||||
t.logger.Error(fmt.Sprintf("error in GetUsersInfo for pse oncall bot of id: %v", team.PseOncallHandle))
|
||||
} else {
|
||||
pseOncallBotData := &(*pseOncallBots)[0]
|
||||
teamResponse.PseOncall = service.BotResponse{
|
||||
Id: pseOncallBotData.ID,
|
||||
Name: pseOncallBotData.RealName,
|
||||
}
|
||||
}
|
||||
|
||||
teamResponse.Participants = userResponses
|
||||
c.JSON(http.StatusOK, common.SuccessResponse(teamResponse, http.StatusOK))
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user