mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 17:52:24 -05:00
allow dereferencing of groups (#256)
This commit is contained in:
parent
231075f28d
commit
0cd2bd2960
4 changed files with 310 additions and 14 deletions
|
|
@ -45,7 +45,8 @@ type DereferencerStandardTestSuite struct {
|
|||
storage *kv.KVStore
|
||||
|
||||
testRemoteStatuses map[string]vocab.ActivityStreamsNote
|
||||
testRemoteAccounts map[string]vocab.ActivityStreamsPerson
|
||||
testRemotePeople map[string]vocab.ActivityStreamsPerson
|
||||
testRemoteGroups map[string]vocab.ActivityStreamsGroup
|
||||
testRemoteAttachments map[string]testrig.RemoteAttachmentFile
|
||||
testAccounts map[string]*gtsmodel.Account
|
||||
|
||||
|
|
@ -55,7 +56,8 @@ type DereferencerStandardTestSuite struct {
|
|||
func (suite *DereferencerStandardTestSuite) SetupSuite() {
|
||||
suite.testAccounts = testrig.NewTestAccounts()
|
||||
suite.testRemoteStatuses = testrig.NewTestFediStatuses()
|
||||
suite.testRemoteAccounts = testrig.NewTestFediPeople()
|
||||
suite.testRemotePeople = testrig.NewTestFediPeople()
|
||||
suite.testRemoteGroups = testrig.NewTestFediGroups()
|
||||
suite.testRemoteAttachments = testrig.NewTestFediAttachments("../../../testrig/media")
|
||||
}
|
||||
|
||||
|
|
@ -89,8 +91,7 @@ func (suite *DereferencerStandardTestSuite) mockTransportController() transport.
|
|||
responseType := ""
|
||||
responseLength := 0
|
||||
|
||||
note, ok := suite.testRemoteStatuses[req.URL.String()]
|
||||
if ok {
|
||||
if note, ok := suite.testRemoteStatuses[req.URL.String()]; ok {
|
||||
// the request is for a note that we have stored
|
||||
noteI, err := streams.Serialize(note)
|
||||
if err != nil {
|
||||
|
|
@ -104,8 +105,7 @@ func (suite *DereferencerStandardTestSuite) mockTransportController() transport.
|
|||
responseType = "application/activity+json"
|
||||
}
|
||||
|
||||
person, ok := suite.testRemoteAccounts[req.URL.String()]
|
||||
if ok {
|
||||
if person, ok := suite.testRemotePeople[req.URL.String()]; ok {
|
||||
// the request is for a person that we have stored
|
||||
personI, err := streams.Serialize(person)
|
||||
if err != nil {
|
||||
|
|
@ -119,8 +119,21 @@ func (suite *DereferencerStandardTestSuite) mockTransportController() transport.
|
|||
responseType = "application/activity+json"
|
||||
}
|
||||
|
||||
attachment, ok := suite.testRemoteAttachments[req.URL.String()]
|
||||
if ok {
|
||||
if group, ok := suite.testRemoteGroups[req.URL.String()]; ok {
|
||||
// the request is for a person that we have stored
|
||||
groupI, err := streams.Serialize(group)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
groupJson, err := json.Marshal(groupI)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
responseBytes = groupJson
|
||||
responseType = "application/activity+json"
|
||||
}
|
||||
|
||||
if attachment, ok := suite.testRemoteAttachments[req.URL.String()]; ok {
|
||||
responseBytes = attachment.Data
|
||||
responseType = attachment.ContentType
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue