mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-01 05:02:24 -05:00
[feature] Support incoming avatar/header descriptions (#4275)
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl> # Description Follow-up to #4270 Closes https://codeberg.org/superseriousbusiness/gotosocial/issues/3450 ## Checklist - [x] I/we have read the [GoToSocial contribution guidelines](https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/CONTRIBUTING.md). - [ ] I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat. - [x] I/we have not leveraged AI to create the proposed changes. - [x] I/we have performed a self-review of added code. - [x] I/we have written code that is legible and maintainable by others. - [x] I/we have commented the added code, particularly in hard-to-understand areas. - [ ] I/we have made any necessary changes to documentation. - [x] I/we have added tests that cover new code. - [x] I/we have run tests and they pass locally with the changes. - [x] I/we have run `go fmt ./...` and `golangci-lint run`. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4275 Co-authored-by: nicole mikołajczyk <git@mkljczk.pl> Co-committed-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
parent
29d481d769
commit
bfc8c31e5f
5 changed files with 238 additions and 6 deletions
|
|
@ -28,6 +28,7 @@ import (
|
|||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
|
@ -473,6 +474,49 @@ func (suite *AccountTestSuite) TestRefreshFederatedRemoteAccountWithKeyChange()
|
|||
suite.True(updatedAcc.PublicKey.Equal(fetchingAcc.PublicKey))
|
||||
}
|
||||
|
||||
func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithAvatarDescription() {
|
||||
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||
defer cncl()
|
||||
|
||||
fetchingAcc := suite.testAccounts["local_account_1"]
|
||||
remoteURI := "https://shrimpnet.example.org/users/shrimp"
|
||||
description := "me scrolling fedi on a laptop, there's a monster ultra white and another fedi user on my right."
|
||||
|
||||
// Fetch the remote account to load into the database.
|
||||
remoteAcc, _, err := suite.dereferencer.GetAccountByURI(ctx,
|
||||
fetchingAcc.Username,
|
||||
testrig.URLMustParse(remoteURI),
|
||||
false,
|
||||
)
|
||||
suite.NoError(err)
|
||||
suite.NotNil(remoteAcc)
|
||||
|
||||
suite.Equal(remoteAcc.AvatarMediaAttachment.Description, description)
|
||||
|
||||
remotePerson := suite.client.TestRemotePeople[remoteURI]
|
||||
|
||||
description = strings.TrimSuffix(description, ".")
|
||||
|
||||
icon := remotePerson.GetActivityStreamsIcon()
|
||||
image := icon.Begin().GetActivityStreamsImage()
|
||||
nameProp := streams.NewActivityStreamsNameProperty()
|
||||
nameProp.AppendXMLSchemaString(description)
|
||||
image.SetActivityStreamsName(nameProp)
|
||||
icon.SetActivityStreamsImage(0, image)
|
||||
remotePerson.SetActivityStreamsIcon(icon)
|
||||
|
||||
updatedAcc, apAcc, err := suite.dereferencer.RefreshAccount(ctx,
|
||||
fetchingAcc.Username,
|
||||
remoteAcc,
|
||||
remotePerson,
|
||||
nil,
|
||||
)
|
||||
|
||||
suite.NoError(err)
|
||||
suite.NotNil(apAcc)
|
||||
suite.Equal(updatedAcc.AvatarMediaAttachment.Description, description)
|
||||
}
|
||||
|
||||
func TestAccountTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(AccountTestSuite))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue