mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-02-11 23:30:16 +00:00
use accountDomain
This commit is contained in:
parent
8ffb1a8845
commit
124ff8ca0b
|
@ -30,7 +30,7 @@
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *converter) ASRepresentationToAccount(ctx context.Context, accountable ap.Accountable, update bool) (*gtsmodel.Account, error) {
|
func (c *converter) ASRepresentationToAccount(ctx context.Context, accountable ap.Accountable, accountDomain string, update bool) (*gtsmodel.Account, error) {
|
||||||
// first check if we actually already know this account
|
// first check if we actually already know this account
|
||||||
uriProp := accountable.GetJSONLDId()
|
uriProp := accountable.GetJSONLDId()
|
||||||
if uriProp == nil || !uriProp.IsIRI() {
|
if uriProp == nil || !uriProp.IsIRI() {
|
||||||
|
@ -63,7 +63,11 @@ func (c *converter) ASRepresentationToAccount(ctx context.Context, accountable a
|
||||||
acct.Username = username
|
acct.Username = username
|
||||||
|
|
||||||
// Domain
|
// Domain
|
||||||
acct.Domain = uri.Host
|
if accountDomain != "" {
|
||||||
|
acct.Domain = accountDomain
|
||||||
|
} else {
|
||||||
|
acct.Domain = uri.Host
|
||||||
|
}
|
||||||
|
|
||||||
// avatar aka icon
|
// avatar aka icon
|
||||||
// if this one isn't extractable in a format we recognise we'll just skip it
|
// if this one isn't extractable in a format we recognise we'll just skip it
|
||||||
|
|
|
@ -38,7 +38,7 @@ type ASToInternalTestSuite struct {
|
||||||
func (suite *ASToInternalTestSuite) TestParsePerson() {
|
func (suite *ASToInternalTestSuite) TestParsePerson() {
|
||||||
testPerson := suite.testPeople["https://unknown-instance.com/users/brand_new_person"]
|
testPerson := suite.testPeople["https://unknown-instance.com/users/brand_new_person"]
|
||||||
|
|
||||||
acct, err := suite.typeconverter.ASRepresentationToAccount(context.Background(), testPerson, false)
|
acct, err := suite.typeconverter.ASRepresentationToAccount(context.Background(), testPerson, "", false)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
suite.Equal("https://unknown-instance.com/users/brand_new_person", acct.URI)
|
suite.Equal("https://unknown-instance.com/users/brand_new_person", acct.URI)
|
||||||
|
@ -106,7 +106,7 @@ func (suite *ASToInternalTestSuite) TestParseGargron() {
|
||||||
rep, ok := t.(ap.Accountable)
|
rep, ok := t.(ap.Accountable)
|
||||||
suite.True(ok)
|
suite.True(ok)
|
||||||
|
|
||||||
acct, err := suite.typeconverter.ASRepresentationToAccount(context.Background(), rep, false)
|
acct, err := suite.typeconverter.ASRepresentationToAccount(context.Background(), rep, "", false)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
fmt.Printf("%+v", acct)
|
fmt.Printf("%+v", acct)
|
||||||
|
@ -168,7 +168,7 @@ func (suite *ASToInternalTestSuite) TestParseOwncastService() {
|
||||||
rep, ok := t.(ap.Accountable)
|
rep, ok := t.(ap.Accountable)
|
||||||
suite.True(ok)
|
suite.True(ok)
|
||||||
|
|
||||||
acct, err := suite.typeconverter.ASRepresentationToAccount(context.Background(), rep, false)
|
acct, err := suite.typeconverter.ASRepresentationToAccount(context.Background(), rep, "", false)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
suite.Equal("rgh", acct.Username)
|
suite.Equal("rgh", acct.Username)
|
||||||
|
|
|
@ -99,7 +99,10 @@ type TypeConverter interface {
|
||||||
// If update is false, and the account is already known in the database, then the existing account entry will be returned.
|
// If update is false, and the account is already known in the database, then the existing account entry will be returned.
|
||||||
// If update is true, then even if the account is already known, all fields in the accountable will be parsed and a new *gtsmodel.Account
|
// If update is true, then even if the account is already known, all fields in the accountable will be parsed and a new *gtsmodel.Account
|
||||||
// will be generated. This is useful when one needs to force refresh of an account, eg., during an Update of a Profile.
|
// will be generated. This is useful when one needs to force refresh of an account, eg., during an Update of a Profile.
|
||||||
ASRepresentationToAccount(ctx context.Context, accountable ap.Accountable, update bool) (*gtsmodel.Account, error)
|
//
|
||||||
|
// If accountDomain is set (not an empty string) then this value will be used as the account's Domain. If not set,
|
||||||
|
// then the Host of the accountable's AP ID will be used instead.
|
||||||
|
ASRepresentationToAccount(ctx context.Context, accountable ap.Accountable, accountDomain string, update bool) (*gtsmodel.Account, error)
|
||||||
// ASStatus converts a remote activitystreams 'status' representation into a gts model status.
|
// ASStatus converts a remote activitystreams 'status' representation into a gts model status.
|
||||||
ASStatusToStatus(ctx context.Context, statusable ap.Statusable) (*gtsmodel.Status, error)
|
ASStatusToStatus(ctx context.Context, statusable ap.Statusable) (*gtsmodel.Status, error)
|
||||||
// ASFollowToFollowRequest converts a remote activitystreams `follow` representation into gts model follow request.
|
// ASFollowToFollowRequest converts a remote activitystreams `follow` representation into gts model follow request.
|
||||||
|
|
Loading…
Reference in a new issue