summaryrefslogtreecommitdiff
path: root/testrig/transportcontroller.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-09-26 11:56:01 +0200
committerLibravatar GitHub <noreply@github.com>2022-09-26 11:56:01 +0200
commitc4a08292ee44bc731ff90bad18a3f37e5ee8ef22 (patch)
tree1726f8450ec37f744204a857c3be2bfab17f206c /testrig/transportcontroller.go
parent[bugfix] more nil checks baybeeeeeeeeeeeeeeeeeeee (#854) (diff)
downloadgotosocial-c4a08292ee44bc731ff90bad18a3f37e5ee8ef22.tar.xz
[feature] Show + federate emojis in accounts (#837)
* Start adding account emoji * get emojis serialized + deserialized nicely * update tests * set / retrieve emojis on accounts * show account emojis in web view * fetch emojis from db based on ids * fix typo in test * lint * fix pg migration * update tests * update emoji checking logic * update comment * clarify comments + add some spacing * tidy up loops a lil (thanks kim)
Diffstat (limited to 'testrig/transportcontroller.go')
-rw-r--r--testrig/transportcontroller.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/testrig/transportcontroller.go b/testrig/transportcontroller.go
index 68f03398d..70f2f0c61 100644
--- a/testrig/transportcontroller.go
+++ b/testrig/transportcontroller.go
@@ -64,6 +64,7 @@ type MockHTTPClient struct {
testRemoteGroups map[string]vocab.ActivityStreamsGroup
testRemoteServices map[string]vocab.ActivityStreamsService
testRemoteAttachments map[string]RemoteAttachmentFile
+ testRemoteEmojis map[string]vocab.TootEmoji
SentMessages sync.Map
}
@@ -90,6 +91,7 @@ func NewMockHTTPClient(do func(req *http.Request) (*http.Response, error), relat
mockHTTPClient.testRemoteGroups = NewTestFediGroups()
mockHTTPClient.testRemoteServices = NewTestFediServices()
mockHTTPClient.testRemoteAttachments = NewTestFediAttachments(relativeMediaPath)
+ mockHTTPClient.testRemoteEmojis = NewTestFediEmojis()
mockHTTPClient.do = func(req *http.Request) (*http.Response, error) {
responseCode := http.StatusNotFound
@@ -173,6 +175,19 @@ func NewMockHTTPClient(do func(req *http.Request) (*http.Response, error), relat
responseBytes = serviceJSON
responseContentType = applicationActivityJSON
responseContentLength = len(serviceJSON)
+ } else if emoji, ok := mockHTTPClient.testRemoteEmojis[req.URL.String()]; ok {
+ emojiI, err := streams.Serialize(emoji)
+ if err != nil {
+ panic(err)
+ }
+ emojiJSON, err := json.Marshal(emojiI)
+ if err != nil {
+ panic(err)
+ }
+ responseCode = http.StatusOK
+ responseBytes = emojiJSON
+ responseContentType = applicationActivityJSON
+ responseContentLength = len(emojiJSON)
} else if attachment, ok := mockHTTPClient.testRemoteAttachments[req.URL.String()]; ok {
responseCode = http.StatusOK
responseBytes = attachment.Data