GatewayRights returns the rights the caller has on the given gateway. The query for the gateway only considers the Gateway ID and not the EUI (if provided).
(ctx context.Context, gtwIDs *ttnpb.GatewayIdentifiers)
| 143 | // GatewayRights returns the rights the caller has on the given gateway. |
| 144 | // The query for the gateway only considers the Gateway ID and not the EUI (if provided). |
| 145 | func (is *IdentityServer) GatewayRights(ctx context.Context, gtwIDs *ttnpb.GatewayIdentifiers) (*ttnpb.Rights, error) { |
| 146 | ids := &ttnpb.GatewayIdentifiers{ |
| 147 | GatewayId: gtwIDs.GatewayId, |
| 148 | } |
| 149 | entity, universal, err := is.getRights(ctx, ids.GetEntityIdentifiers()) |
| 150 | if err != nil { |
| 151 | return nil, err |
| 152 | } |
| 153 | err = is.store.Transact(ctx, func(ctx context.Context, st store.Store) (err error) { |
| 154 | gtw, err := st.GetGateway(ctx, ids, []string{"ids", "status_public", "location_public"}) |
| 155 | if err != nil { |
| 156 | return err |
| 157 | } |
| 158 | if gtw.StatusPublic { |
| 159 | entity = entity.Union(ttnpb.RightsFrom(ttnpb.Right_RIGHT_GATEWAY_STATUS_READ)) |
| 160 | } |
| 161 | if gtw.LocationPublic { |
| 162 | entity = entity.Union(ttnpb.RightsFrom(ttnpb.Right_RIGHT_GATEWAY_LOCATION_READ)) |
| 163 | } |
| 164 | return nil |
| 165 | }) |
| 166 | if errors.IsNotFound(err) { |
| 167 | if is.IsAdmin(ctx) { |
| 168 | return nil, err |
| 169 | } |
| 170 | return &ttnpb.Rights{}, nil |
| 171 | } else if err != nil { |
| 172 | return nil, err |
| 173 | } |
| 174 | return entity.Union(universal), nil |
| 175 | } |
| 176 | |
| 177 | // OrganizationRights returns the rights the caller has on the given organization. |
| 178 | func (is *IdentityServer) OrganizationRights(ctx context.Context, orgIDs *ttnpb.OrganizationIdentifiers) (*ttnpb.Rights, error) { |
nothing calls this directly
no test coverage detected