aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2021-04-04 15:49:16 +0200
committerGitHub <noreply@github.com>2021-04-04 15:49:16 +0200
commitfc04af34f5d6dff930003cc1f27ead972d424324 (patch)
tree8b9750d46182fff88d72fcc891e89d5a79ed83b0 /api
parent2055bd5d0afb534cc98cd11bd9802d66acbb0c8f (diff)
parentcb9b06551ddc1fae33046733f79ede20f8d09f9a (diff)
downloadgit-bug-fc04af34f5d6dff930003cc1f27ead972d424324.tar.gz
Merge pull request #532 from MichaelMure/dag-entity
Work towards a reusable entity datastructure + commit signature
Diffstat (limited to 'api')
-rw-r--r--api/graphql/models/lazy_identity.go49
-rw-r--r--api/graphql/resolvers/operations.go12
-rw-r--r--api/graphql/resolvers/query.go13
3 files changed, 10 insertions, 64 deletions
diff --git a/api/graphql/models/lazy_identity.go b/api/graphql/models/lazy_identity.go
index 344bb5f0..002c38e4 100644
--- a/api/graphql/models/lazy_identity.go
+++ b/api/graphql/models/lazy_identity.go
@@ -7,8 +7,6 @@ import (
"github.com/MichaelMure/git-bug/cache"
"github.com/MichaelMure/git-bug/entity"
"github.com/MichaelMure/git-bug/identity"
- "github.com/MichaelMure/git-bug/util/lamport"
- "github.com/MichaelMure/git-bug/util/timestamp"
)
// IdentityWrapper is an interface used by the GraphQL resolvers to handle an identity.
@@ -21,11 +19,8 @@ type IdentityWrapper interface {
Login() (string, error)
AvatarUrl() (string, error)
Keys() ([]*identity.Key, error)
- ValidKeysAtTime(time lamport.Time) ([]*identity.Key, error)
DisplayName() string
IsProtected() (bool, error)
- LastModificationLamport() (lamport.Time, error)
- LastModification() (timestamp.Timestamp, error)
}
var _ IdentityWrapper = &lazyIdentity{}
@@ -69,6 +64,10 @@ func (li *lazyIdentity) Name() string {
return li.excerpt.Name
}
+func (li *lazyIdentity) DisplayName() string {
+ return li.excerpt.DisplayName()
+}
+
func (li *lazyIdentity) Email() (string, error) {
id, err := li.load()
if err != nil {
@@ -101,18 +100,6 @@ func (li *lazyIdentity) Keys() ([]*identity.Key, error) {
return id.Keys(), nil
}
-func (li *lazyIdentity) ValidKeysAtTime(time lamport.Time) ([]*identity.Key, error) {
- id, err := li.load()
- if err != nil {
- return nil, err
- }
- return id.ValidKeysAtTime(time), nil
-}
-
-func (li *lazyIdentity) DisplayName() string {
- return li.excerpt.DisplayName()
-}
-
func (li *lazyIdentity) IsProtected() (bool, error) {
id, err := li.load()
if err != nil {
@@ -121,22 +108,6 @@ func (li *lazyIdentity) IsProtected() (bool, error) {
return id.IsProtected(), nil
}
-func (li *lazyIdentity) LastModificationLamport() (lamport.Time, error) {
- id, err := li.load()
- if err != nil {
- return 0, err
- }
- return id.LastModificationLamport(), nil
-}
-
-func (li *lazyIdentity) LastModification() (timestamp.Timestamp, error) {
- id, err := li.load()
- if err != nil {
- return 0, err
- }
- return id.LastModification(), nil
-}
-
var _ IdentityWrapper = &loadedIdentity{}
type loadedIdentity struct {
@@ -163,18 +134,6 @@ func (l loadedIdentity) Keys() ([]*identity.Key, error) {
return l.Interface.Keys(), nil
}
-func (l loadedIdentity) ValidKeysAtTime(time lamport.Time) ([]*identity.Key, error) {
- return l.Interface.ValidKeysAtTime(time), nil
-}
-
func (l loadedIdentity) IsProtected() (bool, error) {
return l.Interface.IsProtected(), nil
}
-
-func (l loadedIdentity) LastModificationLamport() (lamport.Time, error) {
- return l.Interface.LastModificationLamport(), nil
-}
-
-func (l loadedIdentity) LastModification() (timestamp.Timestamp, error) {
- return l.Interface.LastModification(), nil
-}
diff --git a/api/graphql/resolvers/operations.go b/api/graphql/resolvers/operations.go
index 8d3e5bba..0ede9f13 100644
--- a/api/graphql/resolvers/operations.go
+++ b/api/graphql/resolvers/operations.go
@@ -19,7 +19,7 @@ func (createOperationResolver) ID(_ context.Context, obj *bug.CreateOperation) (
}
func (createOperationResolver) Author(_ context.Context, obj *bug.CreateOperation) (models.IdentityWrapper, error) {
- return models.NewLoadedIdentity(obj.Author), nil
+ return models.NewLoadedIdentity(obj.Author()), nil
}
func (createOperationResolver) Date(_ context.Context, obj *bug.CreateOperation) (*time.Time, error) {
@@ -36,7 +36,7 @@ func (addCommentOperationResolver) ID(_ context.Context, obj *bug.AddCommentOper
}
func (addCommentOperationResolver) Author(_ context.Context, obj *bug.AddCommentOperation) (models.IdentityWrapper, error) {
- return models.NewLoadedIdentity(obj.Author), nil
+ return models.NewLoadedIdentity(obj.Author()), nil
}
func (addCommentOperationResolver) Date(_ context.Context, obj *bug.AddCommentOperation) (*time.Time, error) {
@@ -57,7 +57,7 @@ func (editCommentOperationResolver) Target(_ context.Context, obj *bug.EditComme
}
func (editCommentOperationResolver) Author(_ context.Context, obj *bug.EditCommentOperation) (models.IdentityWrapper, error) {
- return models.NewLoadedIdentity(obj.Author), nil
+ return models.NewLoadedIdentity(obj.Author()), nil
}
func (editCommentOperationResolver) Date(_ context.Context, obj *bug.EditCommentOperation) (*time.Time, error) {
@@ -74,7 +74,7 @@ func (labelChangeOperationResolver) ID(_ context.Context, obj *bug.LabelChangeOp
}
func (labelChangeOperationResolver) Author(_ context.Context, obj *bug.LabelChangeOperation) (models.IdentityWrapper, error) {
- return models.NewLoadedIdentity(obj.Author), nil
+ return models.NewLoadedIdentity(obj.Author()), nil
}
func (labelChangeOperationResolver) Date(_ context.Context, obj *bug.LabelChangeOperation) (*time.Time, error) {
@@ -91,7 +91,7 @@ func (setStatusOperationResolver) ID(_ context.Context, obj *bug.SetStatusOperat
}
func (setStatusOperationResolver) Author(_ context.Context, obj *bug.SetStatusOperation) (models.IdentityWrapper, error) {
- return models.NewLoadedIdentity(obj.Author), nil
+ return models.NewLoadedIdentity(obj.Author()), nil
}
func (setStatusOperationResolver) Date(_ context.Context, obj *bug.SetStatusOperation) (*time.Time, error) {
@@ -112,7 +112,7 @@ func (setTitleOperationResolver) ID(_ context.Context, obj *bug.SetTitleOperatio
}
func (setTitleOperationResolver) Author(_ context.Context, obj *bug.SetTitleOperation) (models.IdentityWrapper, error) {
- return models.NewLoadedIdentity(obj.Author), nil
+ return models.NewLoadedIdentity(obj.Author()), nil
}
func (setTitleOperationResolver) Date(_ context.Context, obj *bug.SetTitleOperation) (*time.Time, error) {
diff --git a/api/graphql/resolvers/query.go b/api/graphql/resolvers/query.go
index 4ad7ae0c..b2003555 100644
--- a/api/graphql/resolvers/query.go
+++ b/api/graphql/resolvers/query.go
@@ -14,19 +14,6 @@ type rootQueryResolver struct {
cache *cache.MultiRepoCache
}
-func (r rootQueryResolver) DefaultRepository(_ context.Context) (*models.Repository, error) {
- repo, err := r.cache.DefaultRepo()
-
- if err != nil {
- return nil, err
- }
-
- return &models.Repository{
- Cache: r.cache,
- Repo: repo,
- }, nil
-}
-
func (r rootQueryResolver) Repository(_ context.Context, ref *string) (*models.Repository, error) {
var repo *cache.RepoCache
var err error