37 lines
1.6 KiB
Go
37 lines
1.6 KiB
Go
package graph
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.dragse.it/anthrove/otter-space-sdk/internal/source"
|
|
"git.dragse.it/anthrove/otter-space-sdk/internal/user"
|
|
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
|
)
|
|
|
|
// CreateSource will always create a new node, it checks if a node with the same url exits and merges it.
|
|
func (g *graphConnection) CreateSource(ctx context.Context, anthroveSource *models.AnthroveSource) error {
|
|
return source.CreateSourceNode(ctx, g.driver, anthroveSource)
|
|
}
|
|
|
|
// DeleteSource will delete a node with a given Domain
|
|
func (g *graphConnection) DeleteSource(ctx context.Context, anthroveSource *models.AnthroveSource) error {
|
|
return source.DeleteSourceNode(ctx, g.driver, anthroveSource)
|
|
}
|
|
|
|
// GetSourceByURL returns the first models.AnthroveSource provided by the database
|
|
func (g *graphConnection) GetSourceByURL(ctx context.Context, sourceUrl models.AnthroveSourceDomain) (*models.AnthroveSource, error) {
|
|
return source.GetSourceNodesByURL(ctx, g.driver, sourceUrl)
|
|
}
|
|
|
|
func (g *graphConnection) GetAllSources(ctx context.Context) ([]models.AnthroveSource, error) {
|
|
return source.GetAllSourceNodes(ctx, g.driver)
|
|
}
|
|
|
|
func (g *graphConnection) GetSourceLinkForSpecifiedUser(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceDisplayName models.AnthroveSourceDisplayName) (map[string]models.AnthroveUserRelationship, error) {
|
|
return user.GetSpecifiedUserSourceLink(ctx, g.driver, anthroveUserID, sourceDisplayName)
|
|
}
|
|
|
|
func (g *graphConnection) GetSourceLinkForUser(ctx context.Context, anthroveUserID models.AnthroveUserID) (map[string]models.AnthroveUserRelationship, error) {
|
|
return user.GetUserSourceLink(ctx, g.driver, anthroveUserID)
|
|
}
|