BREAKING CHANGE: V2 of thr SDK #12

Merged
fenpaws merged 124 commits from develop/postgresql into main 2024-07-01 20:46:28 +00:00
2 changed files with 43 additions and 2 deletions
Showing only changes of commit bbd08b9a2f - Show all commits

View File

@ -118,3 +118,45 @@ func GetUserSourceLink(ctx context.Context, db *gorm.DB, anthroveUserID models.A
return userSourceMap, nil return userSourceMap, nil
} }
func GetSpecifiedUserSourceLink(ctx context.Context, db *gorm.DB, anthroveUserID models.AnthroveUserID, sourceDisplayName string) (map[string]graphModels.AnthroveUserRelationship, error) {
var userSources []pgModels.UserSource
userSourceMap := make(map[string]graphModels.AnthroveUserRelationship)
err := db.WithContext(ctx).Model(&pgModels.UserSource{}).Joins("Source").Where("user_id = ? AND display_name = ?", string(anthroveUserID), sourceDisplayName).Find(&userSources).Error
if err != nil {
log.WithFields(log.Fields{
"anthrove_user_id": anthroveUserID,
"source_display_name": sourceDisplayName,
}).Error("database: failed to get specified user source link")
return nil, err
}
for _, userSource := range userSources {
var source pgModels.Source
err = db.WithContext(ctx).Model(&pgModels.Source{}).Where("id = ?", userSource.SourceID).First(&source).Error
if err != nil {
log.WithFields(log.Fields{
"source_id": userSource.SourceID,
}).Error("database: failed to get source")
return nil, err
}
userSourceMap[source.DisplayName] = graphModels.AnthroveUserRelationship{
UserID: userSource.AccountID,
Username: userSource.AccountUsername,
Source: graphModels.AnthroveSource{
DisplayName: source.DisplayName,
Domain: source.Domain,
Icon: source.Icon,
},
}
}
log.WithFields(log.Fields{
"anthrove_user_id": anthroveUserID,
"source_display_name": sourceDisplayName,
}).Trace("database: got specified user source link")
return userSourceMap, nil
}

View File

@ -110,8 +110,7 @@ func (p *postgresqlConnection) GetUserSourceLinks(ctx context.Context, anthroveU
} }
func (p *postgresqlConnection) GetSpecifiedUserSourceLink(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceDisplayName string) (map[string]graphModels.AnthroveUserRelationship, error) { func (p *postgresqlConnection) GetSpecifiedUserSourceLink(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceDisplayName string) (map[string]graphModels.AnthroveUserRelationship, error) {
//TODO implement me return postgres.GetSpecifiedUserSourceLink(ctx, p.db, anthroveUserID, sourceDisplayName)
panic("implement me")
} }
func (p *postgresqlConnection) GetAnthroveUser(ctx context.Context, anthroveUserID models.AnthroveUserID) (*graphModels.AnthroveUser, error) { func (p *postgresqlConnection) GetAnthroveUser(ctx context.Context, anthroveUserID models.AnthroveUserID) (*graphModels.AnthroveUser, error) {