40 lines
2.0 KiB
Go
40 lines
2.0 KiB
Go
package graph
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.dragse.it/anthrove/otter-space-sdk/internal/post"
|
|
"git.dragse.it/anthrove/otter-space-sdk/internal/relation"
|
|
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
|
)
|
|
|
|
// CreatePost will always create a new node, it does not check if the node with the corresponding post_id and rating exists.
|
|
func (g *graphConnection) CreatePost(ctx context.Context, anthrovePost *models.AnthrovePost) error {
|
|
return post.CreateAnthrovePostNode(ctx, g.driver, anthrovePost)
|
|
}
|
|
|
|
// DeletePost will always delete a node, it only needs the anthrovePost.PostID filled out.
|
|
func (g *graphConnection) DeletePost(ctx context.Context, anthrovePost *models.AnthrovePost) error {
|
|
return post.DeleteAnthrovePostNode(ctx, g.driver, anthrovePost)
|
|
|
|
}
|
|
|
|
// CheckPostNodeExistsBySourceID checks if a models.AnthrovePost exists by its sourcePostID.
|
|
func (g *graphConnection) CheckPostNodeExistsBySourceID(ctx context.Context, sourcePostID string) (*models.AnthrovePost, bool, error) {
|
|
return post.AnthroveNodeExistsBySourceID(ctx, g.driver, sourcePostID)
|
|
}
|
|
|
|
// CheckPostNodeExistsByAnthroveID checks if a models.AnthrovePost exists by its models.AnthrovePostID.
|
|
func (g *graphConnection) CheckPostNodeExistsByAnthroveID(ctx context.Context, anthrovePost *models.AnthrovePost) (*models.AnthrovePost, bool, error) {
|
|
return post.AnthroveNodeExistsByAnthroveID(ctx, g.driver, anthrovePost)
|
|
}
|
|
|
|
// CheckPostNodeExistsBySourceURL checks if a models.AnthrovePost exists by its sourceUrl.
|
|
func (g *graphConnection) CheckPostNodeExistsBySourceURL(ctx context.Context, sourceUrl string) (*models.AnthrovePost, bool, error) {
|
|
return post.AnthroveNodeExistsBySourceURL(ctx, g.driver, sourceUrl)
|
|
}
|
|
|
|
func (g *graphConnection) LinkPostWithSource(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveSourceDomain string, anthrovePostRelationship *models.AnthrovePostRelationship) error {
|
|
return relation.EstablishAnthrovePostToSourceLink(ctx, g.driver, anthrovePostID, anthroveSourceDomain, anthrovePostRelationship)
|
|
}
|