mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 02:02:25 -05:00
[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)
This commit is contained in:
parent
15a67b7bef
commit
c4a08292ee
34 changed files with 934 additions and 127 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue