Skip to content

Commit

Permalink
Merge pull request #24 from free5gc/fix/identityData
Browse files Browse the repository at this point in the history
Feature: support GetIdentityDataProcedure()
  • Loading branch information
ianchen0119 authored Dec 28, 2023
2 parents 1fc7dc8 + 5cbb316 commit 492aeae
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions internal/sbi/producer/data_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -2540,9 +2540,17 @@ func HandleGetIdentityData(request *httpwrapper.Request) *httpwrapper.Response {
collName := "subscriptionData.identityData"

response, problemDetails := GetIdentityDataProcedure(collName, ueId)

if response != nil {
return httpwrapper.NewResponse(http.StatusOK, nil, response)
res := models.IdentityData{}
gpsi, ok := (*response)["gpsi"]
if ok {
res.GpsiList = append(res.GpsiList, gpsi.(string))
}
ueId, ok := (*response)["ueId"]
if ok {
res.SupiList = append(res.SupiList, ueId.(string))
}
return httpwrapper.NewResponse(http.StatusOK, nil, res)
} else if problemDetails != nil {
return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails)
}
Expand All @@ -2552,10 +2560,16 @@ func HandleGetIdentityData(request *httpwrapper.Request) *httpwrapper.Response {
}

func GetIdentityDataProcedure(collName string, ueId string) (*map[string]interface{}, *models.ProblemDetails) {
filter := bson.M{"ueId": ueId}
logger.DataRepoLog.Debugf("Handle GetIdentityDataProcedure: %+v", ueId)
filter := bson.M{
"$or": []bson.M{
{"gpsi": ueId},
{"ueId": ueId},
},
}
data, pd := getDataFromDB(collName, filter)
if pd != nil {
logger.DataRepoLog.Errorf("GetIdentityDataProcedure err: %s", pd.Detail)
logger.DataRepoLog.Errorf("GetIdentityDataProcedure err: %+v", pd)
return nil, pd
}
return &data, nil
Expand Down

0 comments on commit 492aeae

Please sign in to comment.