Skip to content

Commit

Permalink
add proof field
Browse files Browse the repository at this point in the history
  • Loading branch information
freigeistig committed Jan 29, 2024
1 parent ccb1e24 commit ff83437
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 12 deletions.
5 changes: 5 additions & 0 deletions docs/spec/components/schemas/Proof.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ allOf:
- org_id
- schema_url
- operator
- field
properties:
creator:
type: string
Expand All @@ -40,3 +41,7 @@ allOf:
type: string
description: The operator that will be used to check the proof
example: "$eq"
field:
type: string
description: The field that will be checked
example: "groupID"
5 changes: 5 additions & 0 deletions docs/spec/components/schemas/ProofCreate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ required:
- user_did
- schema_url
- operator
- field
properties:
user_did:
type: string
Expand All @@ -26,3 +27,7 @@ properties:
operator:
type: string
description: The operator that will be used to check the proof
field:
type: string
description: The field that will be checked
example: "groupID"
5 changes: 5 additions & 0 deletions internal/assets/migrations/003_proof_field.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- +migrate Up
alter table proofs add column field text not null;

-- +migrate Down
alter table proofs drop column field;
24 changes: 12 additions & 12 deletions internal/data/pg/schema.xo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/data/schema.xo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions internal/services/api/handlers/create_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func CreateProof(w http.ResponseWriter, r *http.Request) {
OrgID: orgID,
SchemaURL: req.Data.SchemaUrl,
Operator: data.MustProofOperatorFromString(req.Data.Operator),
Field: req.Data.Field,
}

err = Storage(r).ProofQ().Insert(&proof)
Expand All @@ -97,6 +98,7 @@ func CreateProof(w http.ResponseWriter, r *http.Request) {
OrgId: proof.OrgID.String(),
SchemaUrl: req.Data.SchemaUrl,
Operator: proof.Operator.String(),
Field: req.Data.Field,
},
},
Included: resources.Included{},
Expand Down
1 change: 1 addition & 0 deletions internal/services/api/handlers/get_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func ProofByID(w http.ResponseWriter, r *http.Request) {
OrgId: proof.OrgID.String(),
SchemaUrl: proof.SchemaURL,
Operator: proof.Operator.String(),
Field: proof.Field,
},
},
Included: resources.Included{},
Expand Down
1 change: 1 addition & 0 deletions internal/services/api/handlers/get_proofs_by_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func GetLinkByID(w http.ResponseWriter, r *http.Request) {
OrgId: proof.OrgID.String(),
SchemaUrl: proof.SchemaURL,
Operator: proof.Operator.String(),
Field: proof.Field,
},
})
}
Expand Down
2 changes: 2 additions & 0 deletions internal/services/api/handlers/get_proofs_by_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ func GetProofs(w http.ResponseWriter, r *http.Request) {
ProofType: proof.Type,
OrgId: proof.OrgID.String(),
SchemaUrl: proof.SchemaURL,
Operator: proof.Operator.String(),
Field: proof.Field,
},
},
}
Expand Down
2 changes: 2 additions & 0 deletions resources/model_proof_attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ type ProofAttributes struct {
CreatedAt time.Time `json:"created_at"`
// The ID of the user who created the proof
Creator string `json:"creator"`
// The field that will be checked
Field string `json:"field"`
// The operator that will be used to check the proof
Operator string `json:"operator"`
// The ID of the organization that issued the proof's claim
Expand Down
2 changes: 2 additions & 0 deletions resources/model_proof_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
package resources

type ProofCreate struct {
// The field that will be checked
Field string `json:"field"`
// The operator that will be used to check the proof
Operator string `json:"operator"`
// The ID of the organization that issued the proof's claim
Expand Down

0 comments on commit ff83437

Please sign in to comment.