Skip to content

Commit

Permalink
pba: Prioritize gateway's contact fields in update operations
Browse files Browse the repository at this point in the history
Change the priority of which contact is used when sending update
notifications, instead of using the contacts present within the
ContactInfo list both AdministrativeContact and TechnicalContact have
the priority.
  • Loading branch information
nicholaspcr committed Aug 2, 2023
1 parent 07b7e7d commit d25b7e2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/packetbrokeragent/grpc_gspba.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,19 @@ func (s *gsPbaServer) UpdateGateway(ctx context.Context, req *ttnpb.UpdatePacket
}

if ttnpb.HasAnyField(req.FieldMask.GetPaths(), "contact_info") {
reqAdminContact := &packetbroker.ContactInfo{Email: req.Gateway.GetAdministrativeContact().GetUserIds().Email}
reqTechContact := &packetbroker.ContactInfo{Email: req.Gateway.GetTechnicalContact().GetUserIds().Email}
adminContact, techContact := toPBContactInfo(req.Gateway.GetContactInfo())

// Prioritize administrative and technical contacts attached to the gateway instead of the ones present in
// ContactInfo slice.
if req.Gateway.AdministrativeContact != nil {
adminContact = reqAdminContact
}
if req.Gateway.TechnicalContact != nil {
adminContact = reqTechContact
}

updateReq.AdministrativeContact = &packetbroker.ContactInfoValue{
Value: adminContact,
}
Expand Down

0 comments on commit d25b7e2

Please sign in to comment.