This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
otter-space-sdk/pkg/graph/source_impl.go
SoXX 76f3c8d97e refactor(model): changed types of model
Signed-off-by: SoXX <soxx@fenpa.ws>
2024-05-31 16:03:35 +02:00

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)
}