feat: implemented user to post relationship creation
This commit is contained in:
parent
924416dd06
commit
1919cf5c76
@ -36,3 +36,29 @@ func EstablishAnthrovePostToSourceLink(ctx context.Context, driver neo4j.DriverW
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func EstablishUserToPostLink(ctx context.Context, driver neo4j.DriverWithContext, anthroveUser *models.AnthroveUser, anthrovePost *models.AnthrovePost) error {
|
||||||
|
|
||||||
|
query := `
|
||||||
|
MATCH (user:User {user_id: $anthrove_user_id})
|
||||||
|
MATCH (anthrovePost:AnthrovePost {post_id: $anthrove_post_id})
|
||||||
|
MERGE (user)-[:FAV]->(anthrovePost)
|
||||||
|
`
|
||||||
|
|
||||||
|
params := map[string]any{
|
||||||
|
"anthrove_post_id": anthrovePost.PostID,
|
||||||
|
"anthrove_user_id": anthroveUser.UserID,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := neo4j.ExecuteQuery(ctx, driver, query, params, neo4j.EagerResultTransformer)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"anthrove_post_id": anthrovePost.PostID,
|
||||||
|
"anthrove_user_id": anthroveUser.UserID,
|
||||||
|
}).Trace("graph: created user to post link")
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -57,8 +57,7 @@ func (g *graphConnection) LinkPostWithSource(ctx context.Context, anthrovePostID
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *graphConnection) LinkUserWithPost(ctx context.Context, anthroveUser *models.AnthroveUser, anthrovePost *models.AnthrovePost) error {
|
func (g *graphConnection) LinkUserWithPost(ctx context.Context, anthroveUser *models.AnthroveUser, anthrovePost *models.AnthrovePost) error {
|
||||||
//TODO implement me
|
return internal.EstablishUserToPostLink(ctx, g.driver, anthroveUser, anthrovePost)
|
||||||
panic("implement me")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *graphConnection) VerifyUserPostLink(ctx context.Context, anthrovePost *models.AnthrovePost, anthroveUser *models.AnthroveUser) (bool, error) {
|
func (g *graphConnection) VerifyUserPostLink(ctx context.Context, anthrovePost *models.AnthrovePost, anthroveUser *models.AnthroveUser) (bool, error) {
|
||||||
|
Reference in New Issue
Block a user