+14
server/handle_sync_get_blob.go
+14
server/handle_sync_get_blob.go
···
3
import (
4
"bytes"
5
6
+
"github.com/Azure/go-autorest/autorest/to"
7
"github.com/haileyok/cocoon/internal/helpers"
8
"github.com/haileyok/cocoon/models"
9
"github.com/ipfs/go-cid"
···
24
c, err := cid.Parse(cstr)
25
if err != nil {
26
return helpers.InputError(e, nil)
27
+
}
28
+
29
+
urepo, err := s.getRepoActorByDid(did)
30
+
if err != nil {
31
+
s.logger.Error("could not find user for requested blob", "error", err)
32
+
return helpers.InputError(e, nil)
33
+
}
34
+
35
+
status := urepo.Status()
36
+
if status != nil {
37
+
if *status == "deactivated" {
38
+
return helpers.InputError(e, to.StringPtr("RepoDeactivated"))
39
+
}
40
}
41
42
var blob models.Blob
+14
server/handle_sync_list_blobs.go
+14
server/handle_sync_list_blobs.go
···
1
package server
2
3
import (
4
"github.com/haileyok/cocoon/internal/helpers"
5
"github.com/haileyok/cocoon/models"
6
"github.com/ipfs/go-cid"
···
33
cursorquery = "AND created_at < ?"
34
}
35
params = append(params, limit)
36
37
var blobs []models.Blob
38
if err := s.db.Raw("SELECT * FROM blobs WHERE did = ? "+cursorquery+" ORDER BY created_at DESC LIMIT ?", nil, params...).Scan(&blobs).Error; err != nil {
···
1
package server
2
3
import (
4
+
"github.com/Azure/go-autorest/autorest/to"
5
"github.com/haileyok/cocoon/internal/helpers"
6
"github.com/haileyok/cocoon/models"
7
"github.com/ipfs/go-cid"
···
34
cursorquery = "AND created_at < ?"
35
}
36
params = append(params, limit)
37
+
38
+
urepo, err := s.getRepoActorByDid(did)
39
+
if err != nil {
40
+
s.logger.Error("could not find user for requested blobs", "error", err)
41
+
return helpers.InputError(e, nil)
42
+
}
43
+
44
+
status := urepo.Status()
45
+
if status != nil {
46
+
if *status == "deactivated" {
47
+
return helpers.InputError(e, to.StringPtr("RepoDeactivated"))
48
+
}
49
+
}
50
51
var blobs []models.Blob
52
if err := s.db.Raw("SELECT * FROM blobs WHERE did = ? "+cursorquery+" ORDER BY created_at DESC LIMIT ?", nil, params...).Scan(&blobs).Error; err != nil {