TP-45804 : Update get teams api to send team and pse oncall info (#253)

This commit is contained in:
Vijay Joshi
2023-10-20 13:03:09 +05:30
committed by GitHub
parent 5d17830187
commit 07ad271c3c
3 changed files with 33 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
package service
type BotResponse struct {
Id string `json:"id"`
Name string `json:"name"`
}

View File

@@ -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 {

View File

@@ -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