|
1 | 1 | package callback |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "context" |
5 | 4 | "strconv" |
6 | 5 |
|
7 | 6 | "github.com/sirupsen/logrus" |
@@ -35,8 +34,15 @@ func SendN1N2TransferFailureNotification(ue *amf_context.AmfUe, cause models.N1N |
35 | 34 | }, |
36 | 35 | } |
37 | 36 |
|
38 | | - _, err := client.N1N2MessageCollectionCollectionApi. |
39 | | - N1N2TransferFailureNotification(context.Background(), uri, &n1N2MsgTxfrFailureNotificationReq) |
| 37 | + ctx, pd, err := amf_context.GetSelf().GetTokenCtx( |
| 38 | + models.ServiceName("namf-callback"), models.NrfNfManagementNfType_SMF) |
| 39 | + if err != nil { |
| 40 | + HttpLog.Warnf("SendN1N2TransferFailureNotification get token failed: %+v", pd) |
| 41 | + return |
| 42 | + } |
| 43 | + |
| 44 | + _, err = client.N1N2MessageCollectionCollectionApi. |
| 45 | + N1N2TransferFailureNotification(ctx, uri, &n1N2MsgTxfrFailureNotificationReq) |
40 | 46 |
|
41 | 47 | if err != nil { |
42 | 48 | HttpLog.Errorln(err.Error()) |
@@ -73,8 +79,16 @@ func SendN1MessageNotify(ue *amf_context.AmfUe, n1class models.N1MessageClass, n |
73 | 79 | n1MessageNotifyReq := Namf_Communication.N1MessageNotifyRequest{ |
74 | 80 | N1MessageNotifyRequest: &n1MessageNotify, |
75 | 81 | } |
76 | | - _, err := client.N1N2SubscriptionsCollectionForIndividualUEContextsCollectionApi. |
77 | | - N1MessageNotify(context.Background(), subscription.N1NotifyCallbackUri, &n1MessageNotifyReq) |
| 82 | + |
| 83 | + ctx, pd, err := amf_context.GetSelf().GetTokenCtx( |
| 84 | + models.ServiceName("namf-callback"), models.NrfNfManagementNfType_SMF) |
| 85 | + if err != nil { |
| 86 | + HttpLog.Warnf("SendN1MessageNotify get token failed: %+v", pd) |
| 87 | + return false |
| 88 | + } |
| 89 | + |
| 90 | + _, err = client.N1N2SubscriptionsCollectionForIndividualUEContextsCollectionApi. |
| 91 | + N1MessageNotify(ctx, subscription.N1NotifyCallbackUri, &n1MessageNotifyReq) |
78 | 92 | if err != nil { |
79 | 93 | HttpLog.Errorln(err.Error()) |
80 | 94 | } |
@@ -117,8 +131,15 @@ func SendN1MessageNotifyAtAMFReAllocation( |
117 | 131 | } |
118 | 132 | } |
119 | 133 |
|
120 | | - _, err := client.N1N2SubscriptionsCollectionForIndividualUEContextsCollectionApi. |
121 | | - N1MessageNotify(context.Background(), callbackUri, &n1MessageNotifyReq) |
| 134 | + ctx, pd, err := amf_context.GetSelf().GetTokenCtx( |
| 135 | + models.ServiceName("namf-callback"), models.NrfNfManagementNfType_AMF) |
| 136 | + if err != nil { |
| 137 | + HttpLog.Warnf("SendN1MessageNotifyAtAMFReAllocation get token failed: %+v", pd) |
| 138 | + return err |
| 139 | + } |
| 140 | + |
| 141 | + _, err = client.N1N2SubscriptionsCollectionForIndividualUEContextsCollectionApi. |
| 142 | + N1MessageNotify(ctx, callbackUri, &n1MessageNotifyReq) |
122 | 143 | if err != nil { |
123 | 144 | HttpLog.Errorln(err.Error()) |
124 | 145 | return err |
@@ -187,8 +208,15 @@ func SendN2InfoNotify(ue *amf_context.AmfUe, n2class models.N2InformationClass, |
187 | 208 | N2InfoNotifyRequest: &n2InformationNotify, |
188 | 209 | } |
189 | 210 |
|
190 | | - _, err := client.N1N2SubscriptionsCollectionForIndividualUEContextsCollectionApi. |
191 | | - N2InfoNotify(context.Background(), subscription.N2NotifyCallbackUri, &n2InformationNotifyReq) |
| 211 | + ctx, pd, err := amf_context.GetSelf().GetTokenCtx( |
| 212 | + models.ServiceName("namf-callback"), models.NrfNfManagementNfType_SMF) |
| 213 | + if err != nil { |
| 214 | + HttpLog.Warnf("SendN2InfoNotify get token failed: %+v", pd) |
| 215 | + return false |
| 216 | + } |
| 217 | + |
| 218 | + _, err = client.N1N2SubscriptionsCollectionForIndividualUEContextsCollectionApi. |
| 219 | + N2InfoNotify(ctx, subscription.N2NotifyCallbackUri, &n2InformationNotifyReq) |
192 | 220 | if err != nil { |
193 | 221 | HttpLog.Errorln(err.Error()) |
194 | 222 | } |
|
0 commit comments