Merge pull request 'feat: added sources to AnthroveUserRelationship' (#1) from more-querys into main
Reviewed-on: #1
This commit is contained in:
commit
175fb4daab
@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"git.dragse.it/anthrove/otter-space-sdk/internal/utils"
|
||||
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@ -96,7 +95,7 @@ func GetUserSourceLink(ctx context.Context, driver neo4j.DriverWithContext, anth
|
||||
|
||||
query := `
|
||||
MATCH (user:User{user_id: $anthrove_user_id})-[r:HAS_ACCOUNT_AT]->(s:Source)
|
||||
RETURN toString(r.user_id) AS sourceUserID, toString(r.username) AS sourceUsername, s.display_name as sourceDisplayName;
|
||||
RETURN toString(r.user_id) AS sourceUserID, toString(r.username) AS sourceUsername, s as source;
|
||||
`
|
||||
params := map[string]any{
|
||||
"anthrove_user_id": anthroveUserID,
|
||||
@ -113,7 +112,7 @@ func GetUserSourceLink(ctx context.Context, driver neo4j.DriverWithContext, anth
|
||||
|
||||
for i := range result.Records {
|
||||
record := result.Records[i]
|
||||
sourceName, _, err := neo4j.GetRecordValue[string](record, "sourceDisplayName")
|
||||
source, _, err := neo4j.GetRecordValue[neo4j.Node](record, "source")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -126,11 +125,20 @@ func GetUserSourceLink(ctx context.Context, driver neo4j.DriverWithContext, anth
|
||||
return nil, err
|
||||
}
|
||||
|
||||
displayName := source.Props["display_name"].(string)
|
||||
domain := source.Props["domain"].(string)
|
||||
icon := source.Props["icon"].(string)
|
||||
|
||||
anthroveSourceUser := models.AnthroveUserRelationship{
|
||||
UserID: sourceUserID,
|
||||
Username: sourceUsername,
|
||||
Source: models.AnthroveSource{
|
||||
DisplayName: displayName,
|
||||
Domain: domain,
|
||||
Icon: icon,
|
||||
},
|
||||
}
|
||||
userSource[sourceName] = anthroveSourceUser
|
||||
userSource[displayName] = anthroveSourceUser
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
|
Reference in New Issue
Block a user