rework media processing a little bit (#191)

* rework media processing a little bit

* review changes
This commit is contained in:
tobi 2021-09-04 14:02:01 +02:00 committed by GitHub
commit 2b14b20802
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 486 additions and 166 deletions

View file

@ -27,10 +27,12 @@ import (
"crypto/x509"
"encoding/json"
"encoding/pem"
"fmt"
"io/ioutil"
"net"
"net/http"
"net/url"
"os"
"time"
"github.com/go-fed/activity/pub"
@ -1285,6 +1287,25 @@ func NewTestFediPeople() map[string]vocab.ActivityStreamsPerson {
}
}
// RemoteAttachmentFile mimics a remote (federated) attachment
type RemoteAttachmentFile struct {
Data []byte
ContentType string
}
func NewTestFediAttachments(relativePath string) map[string]RemoteAttachmentFile {
beeBytes, err := os.ReadFile(fmt.Sprintf("%s/beeplushie.jpg", relativePath))
if err != nil {
panic(err)
}
return map[string]RemoteAttachmentFile{
"https://s3-us-west-2.amazonaws.com/plushcity/media_attachments/files/106/867/380/219/163/828/original/88e8758c5f011439.jpg": {
Data: beeBytes,
ContentType: "image/jpeg",
},
}
}
func NewTestFediStatuses() map[string]vocab.ActivityStreamsNote {
return map[string]vocab.ActivityStreamsNote{
"https://unknown-instance.com/users/brand_new_person/statuses/01FE4NTHKWW7THT67EF10EB839": newNote(