feat(postgres): added LinkUserWithPost
This commit is contained in:
parent
8d655e991f
commit
a430c3b582
@ -37,3 +37,22 @@ func EstablishAnthrovePostToSourceLink(ctx context.Context, db *gorm.DB, anthrov
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func EstablishUserToPostLink(ctx context.Context, db *gorm.DB, anthroveUserID models.AnthroveUserID, anthrovePostID models.AnthrovePostID) error {
|
||||
userFavorite := pgModels.UserFavorite{
|
||||
UserID: string(anthroveUserID),
|
||||
PostID: string(anthrovePostID),
|
||||
}
|
||||
|
||||
err := db.WithContext(ctx).Create(&userFavorite).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"anthrove_user_id": anthroveUserID,
|
||||
"anthrove_post_id": anthrovePostID,
|
||||
}).Trace("database: created user to post link")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -77,8 +77,7 @@ func (p *postgresqlConnection) LinkPostWithSource(ctx context.Context, anthroveP
|
||||
}
|
||||
|
||||
func (p *postgresqlConnection) LinkUserWithPost(ctx context.Context, anthroveUser *graphModels.AnthroveUser, anthrovePost *graphModels.AnthrovePost) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
return postgres.EstablishUserToPostLink(ctx, p.db, anthroveUser.UserID, anthrovePost.PostID)
|
||||
}
|
||||
|
||||
func (p *postgresqlConnection) CheckUserPostLink(ctx context.Context, anthroveUserID models.AnthroveUserID, sourcePostID string, sourceUrl string) (bool, error) {
|
||||
|
Reference in New Issue
Block a user