diff --git a/pkg/apis/compute/nat.go b/pkg/apis/compute/nat.go index 0406606e0f..e7cf73ec3c 100644 --- a/pkg/apis/compute/nat.go +++ b/pkg/apis/compute/nat.go @@ -52,14 +52,19 @@ type NatSEntryDetails struct { apis.StandaloneResourceDetails // SNatSEntry - Natgateway string `json:"natgateway"` - RealName string `json:"real_name"` - Network SimpleNetwork `json:"network"` + Natgateway string `json:"natgateway"` + // RealName identifies the local name of SNAT record + RealName string `json:"real_name"` + Network SimpleNetwork `json:"network"` } type SimpleNetwork struct { - Id string `json:"id"` - Name string `json:"name"` + Id string `json:"id"` + Name string `json:"name"` + GuestIpStart string `json:"guest_ip_start"` + GuestIpEnd string `json:"guest_ip_end"` + GuestIp6Start string `json:"guest_ip6_start"` + GuestIp6End string `json:"guest_ip6_end"` } type NatgatewayDetails struct { diff --git a/pkg/apis/notify/notification.go b/pkg/apis/notify/notification.go index 2400807f08..47b62073c0 100644 --- a/pkg/apis/notify/notification.go +++ b/pkg/apis/notify/notification.go @@ -23,6 +23,7 @@ import ( type NotificationDetails struct { apis.ModelBaseDetails + Id string `json:"id"` Name string `json:"name"` UserList jsonutils.JSONObject `json:"user_list"` diff --git a/pkg/compute/models/natstable.go b/pkg/compute/models/natstable.go index ce7a0165c1..c7ba0c49ef 100644 --- a/pkg/compute/models/natstable.go +++ b/pkg/compute/models/natstable.go @@ -323,8 +323,12 @@ func (self *SNatSEntry) getMoreDetails(ctx context.Context, userCred mcclient.To return out } out.Network = api.SimpleNetwork{ - Id: network.Id, - Name: network.Name, + Id: network.Id, + Name: network.Name, + GuestIpStart: network.GuestIpStart, + GuestIpEnd: network.GuestIpEnd, + GuestIp6Start: network.GuestIp6Start, + GuestIp6End: network.GuestIp6End, } natgateway, err := self.GetNatgateway() if err != nil { diff --git a/pkg/notify/models/mod_contact.go b/pkg/notify/models/mod_contact.go index 10dbbdefa1..9fbab37a8f 100644 --- a/pkg/notify/models/mod_contact.go +++ b/pkg/notify/models/mod_contact.go @@ -209,7 +209,7 @@ func (self *SContact) getMoreDetail(ctx context.Context, userCred mcclient.Token return out, nil } -func (self *SContact) GetExtraDetail(ctx context.Context, userCred mcclient.TokenCredential, +func (self *SContact) GetExtraDetails(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, isList bool) (api.ContactDetails, error) { var err error out := api.ContactDetails{} diff --git a/pkg/notify/models/mod_notification.go b/pkg/notify/models/mod_notification.go index 2b7d54a157..6e49c363a4 100644 --- a/pkg/notify/models/mod_notification.go +++ b/pkg/notify/models/mod_notification.go @@ -111,16 +111,35 @@ func (self *SNotification) GetExtraDetails(ctx context.Context, userCred mcclien if err != nil { return out, err } - userDetail := UserDetail{ - Status: self.Status, - Name: self.UID, - ReceivedAt: self.ReceivedAt, + + var scopeStr string + scopeStr, err = query.GetString("scope") + if err != nil { + scopeStr = "system" } - name, err := utils.GetUsernameByID(ctx, self.UID) - if err == nil && len(name) != 0 { - out.Name = name + scope := rbacutils.TRbacScope(scopeStr) + + var userDetails []UserDetail + if scope.HigherEqual(rbacutils.ScopeSystem) { + userDetails, err = NotificationManager.fetchUserDetailByClusterID(ctx, self.ClusterID) + if err != nil { + return out, errors.Wrap(err, "NotificationManager.fetchUserDetailByClusterID") + } + } else { + userDetail := UserDetail{ + Status: self.Status, + Name: self.UID, + ReceivedAt: self.ReceivedAt, + } + name, err := utils.GetUsernameByID(ctx, self.UID) + if err == nil && len(name) != 0 { + userDetail.Name = name + } + userDetails = []UserDetail{userDetail} } - out.UserList = jsonutils.Marshal([]UserDetail{userDetail}) + + out.Id = self.ClusterID + out.UserList = jsonutils.Marshal(userDetails) return out, nil }