summaryrefslogtreecommitdiff
path: root/internal/media/media.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/media/media.go')
-rw-r--r--internal/media/media.go31
1 files changed, 29 insertions, 2 deletions
diff --git a/internal/media/media.go b/internal/media/media.go
index e96c37020..0bd196b27 100644
--- a/internal/media/media.go
+++ b/internal/media/media.go
@@ -1,7 +1,34 @@
package media
-import gtsmodel "github.com/superseriousbusiness/gotosocial/internal/db/bundb/migrations/20211113114307_init"
+import (
+ "fmt"
+ "sync"
+
+ "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+)
type Media struct {
- Attachment *gtsmodel.MediaAttachment
+ mu sync.Mutex
+ attachment *gtsmodel.MediaAttachment
+ rawData []byte
+}
+
+func (m *Media) Thumb() (*ImageMeta, error) {
+ m.mu.Lock()
+ thumb, err := deriveThumbnail(m.rawData, m.attachment.File.ContentType)
+ if err != nil {
+ return nil, fmt.Errorf("error deriving thumbnail: %s", err)
+ }
+ m.attachment.Blurhash = thumb.blurhash
+ aaaaaaaaaaaaaaaa
+}
+
+func (m *Media) PreLoad() {
+ m.mu.Lock()
+ defer m.mu.Unlock()
+}
+
+func (m *Media) Load() {
+ m.mu.Lock()
+ defer m.mu.Unlock()
}