ListOrganization lists the rights for the given organization ID in the context.
(ctx context.Context, id *ttnpb.OrganizationIdentifiers)
| 117 | |
| 118 | // ListOrganization lists the rights for the given organization ID in the context. |
| 119 | func ListOrganization(ctx context.Context, id *ttnpb.OrganizationIdentifiers) (rights *ttnpb.Rights, err error) { |
| 120 | uid := unique.ID(ctx, id) |
| 121 | if inCtx, ok := fromContext(ctx); ok { |
| 122 | r, _ := inCtx.OrganizationRights.GetRights(uid) |
| 123 | return r, nil |
| 124 | } |
| 125 | if inCtx, ok := cacheFromContext(ctx); ok { |
| 126 | if r, ok := inCtx.OrganizationRights.GetRights(uid); ok { |
| 127 | return r, nil |
| 128 | } |
| 129 | } |
| 130 | defer func() { |
| 131 | if err == nil { |
| 132 | cacheInContext(ctx, func(r *Rights) { r.setOrganizationRights(uid, rights) }) |
| 133 | } |
| 134 | }() |
| 135 | fetcher, ok := fetcherFromContext(ctx) |
| 136 | if !ok { |
| 137 | panic(errNoFetcher) |
| 138 | } |
| 139 | rights, err = fetcher.OrganizationRights(ctx, id) |
| 140 | if err != nil { |
| 141 | if errors.IsPermissionDenied(err) { |
| 142 | return &ttnpb.Rights{}, nil |
| 143 | } |
| 144 | return nil, err |
| 145 | } |
| 146 | return rights, nil |
| 147 | } |
| 148 | |
| 149 | // ListUser lists the rights for the given user ID in the context. |
| 150 | func ListUser(ctx context.Context, id *ttnpb.UserIdentifiers) (rights *ttnpb.Rights, err error) { |
no test coverage detected