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