diff options
| author | 2025-06-19 15:10:41 +0200 | |
|---|---|---|
| committer | 2025-06-19 15:10:41 +0200 | |
| commit | bfc8c31e5f80bd7e405ad407d58597a92a1e85fd (patch) | |
| tree | 53645d0ddfdd32469f36eaa649b31be14d8018c3 /testrig | |
| parent | [bugfix] delete interaction requests when deleting account (#4278) (diff) | |
| download | gotosocial-bfc8c31e5f80bd7e405ad407d58597a92a1e85fd.tar.xz | |
[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>
Diffstat (limited to 'testrig')
| -rw-r--r-- | testrig/testmodels.go | 49 | ||||
| -rw-r--r-- | testrig/transportcontroller.go | 11 |
2 files changed, 60 insertions, 0 deletions
diff --git a/testrig/testmodels.go b/testrig/testmodels.go index 86ea32fce..42caf59bd 100644 --- a/testrig/testmodels.go +++ b/testrig/testmodels.go @@ -3578,6 +3578,12 @@ func NewTestFediPeople() map[string]vocab.ActivityStreamsPerson { } someUserPub := &someUserPriv.PublicKey + shrimpPriv, err := rsa.GenerateKey(rand.Reader, 2048) + if err != nil { + panic(err) + } + shrimpPub := &shrimpPriv.PublicKey + return map[string]vocab.ActivityStreamsPerson{ "https://unknown-instance.com/users/brand_new_person": newAPPerson( URLMustParse("https://unknown-instance.com/users/brand_new_person"), @@ -3599,7 +3605,9 @@ func NewTestFediPeople() map[string]vocab.ActivityStreamsPerson { nil, "image/jpeg", nil, + nil, "image/png", + nil, false, ), "https://turnip.farm/users/turniplover6969": newAPPerson( @@ -3622,7 +3630,9 @@ func NewTestFediPeople() map[string]vocab.ActivityStreamsPerson { nil, "image/jpeg", nil, + nil, "image/png", + nil, false, ), "http://example.org/users/Some_User": newAPPerson( @@ -3645,7 +3655,34 @@ func NewTestFediPeople() map[string]vocab.ActivityStreamsPerson { nil, "image/jpeg", nil, + nil, + "image/png", + nil, + false, + ), + "https://shrimpnet.example.org/users/shrimp": newAPPerson( + URLMustParse("https://shrimpnet.example.org/users/shrimp"), + URLMustParse("https://shrimpnet.example.org/users/shrimp/following"), + URLMustParse("https://shrimpnet.example.org/users/shrimp/followers"), + URLMustParse("https://shrimpnet.example.org/users/shrimp/inbox"), + URLMustParse("https://shrimpnet.example.org/inbox"), + URLMustParse("https://shrimpnet.example.org/users/shrimp/outbox"), + URLMustParse("https://shrimpnet.example.org/users/shrimp/collections/featured"), + nil, + nil, + "shrimp", + "Shrimp", + "", + URLMustParse("https://shrimpnet.example.org/@shrimp"), + true, + URLMustParse("https://shrimpnet.example.org/users/shrimp#main-key"), + shrimpPub, + URLMustParse("https://shrimpnet.example.org/files/public-1c8468b8-eb2d-485f-9967-f4238ded95e7.webp"), + "image/jpeg", + util.Ptr("me scrolling fedi on a laptop, there's a monster ultra white and another fedi user on my right."), + nil, "image/png", + nil, false, ), } @@ -4398,8 +4435,10 @@ func newAPPerson( pkey *rsa.PublicKey, avatarURL *url.URL, avatarContentType string, + avatarDescription *string, headerURL *url.URL, headerContentType string, + headerDescription *string, manuallyApprovesFollowers bool, ) vocab.ActivityStreamsPerson { person := streams.NewActivityStreamsPerson() @@ -4564,6 +4603,11 @@ func newAPPerson( avatarURLProperty := streams.NewActivityStreamsUrlProperty() avatarURLProperty.AppendIRI(avatarURL) iconImage.SetActivityStreamsUrl(avatarURLProperty) + if avatarDescription != nil { + nameProp := streams.NewActivityStreamsNameProperty() + nameProp.AppendXMLSchemaString(*avatarDescription) + iconImage.SetActivityStreamsName(nameProp) + } iconProperty.AppendActivityStreamsImage(iconImage) person.SetActivityStreamsIcon(iconProperty) @@ -4577,6 +4621,11 @@ func newAPPerson( headerURLProperty := streams.NewActivityStreamsUrlProperty() headerURLProperty.AppendIRI(headerURL) headerImage.SetActivityStreamsUrl(headerURLProperty) + if headerDescription != nil { + nameProp := streams.NewActivityStreamsNameProperty() + nameProp.AppendXMLSchemaString(*headerDescription) + headerImage.SetActivityStreamsName(nameProp) + } headerProperty.AppendActivityStreamsImage(headerImage) person.SetActivityStreamsImage(headerProperty) diff --git a/testrig/transportcontroller.go b/testrig/transportcontroller.go index 641232b73..16bbfe1a6 100644 --- a/testrig/transportcontroller.go +++ b/testrig/transportcontroller.go @@ -566,6 +566,17 @@ func WebfingerResponse(req *http.Request) ( }, }, } + case "https://shrimpnet.example.org/.well-known/webfinger?resource=acct%3Ashrimp%40shrimpnet.example.org": + wfr = &apimodel.WellKnownResponse{ + Subject: "acct:shrimp@shrimpnet.example.org", + Links: []apimodel.Link{ + { + Rel: "self", + Type: applicationActivityJSON, + Href: "https://shrimpnet.example.org/users/shrimp", + }, + }, + } case "https://misconfigured-instance.com/.weird-webfinger-location/webfinger?resource=acct%3Asomeone%40misconfigured-instance.com": wfr = &apimodel.WellKnownResponse{ Subject: "acct:someone@misconfigured-instance.com", |
