-
Notifications
You must be signed in to change notification settings - Fork 43
/
textile.go
41 lines (35 loc) · 1.4 KB
/
textile.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package sync
import (
"encoding/json"
"github.com/FleekHQ/space-daemon/core/textile/bucket"
"github.com/FleekHQ/space-daemon/core/events"
"github.com/FleekHQ/space-daemon/log"
tc "github.com/textileio/go-threads/api/client"
)
func (h *textileHandler) OnCreate(bucketData *bucket.BucketData, listenEvent *tc.ListenEvent) {
log.Info("Default Listener Handler: OnCreate")
instance := &bucket.BucketData{}
if err := json.Unmarshal(listenEvent.Action.Instance, instance); err != nil {
log.Error("failed to unmarshal listen result: %v", err)
}
evt := events.NewTextileEvent(instance.Name)
h.notifier.SendTextileEvent(evt)
}
func (h *textileHandler) OnRemove(bucketData *bucket.BucketData, listenEvent *tc.ListenEvent) {
log.Info("Default Listener Handler: OnRemove")
instance := &bucket.BucketData{}
if err := json.Unmarshal(listenEvent.Action.Instance, instance); err != nil {
log.Error("failed to unmarshal listen result: %v", err)
}
evt := events.NewTextileEvent(instance.Name)
h.notifier.SendTextileEvent(evt)
}
func (h *textileHandler) OnSave(bucketData *bucket.BucketData, listenEvent *tc.ListenEvent) {
log.Info("Default Listener Handler: OnSave")
instance := &bucket.BucketData{}
if err := json.Unmarshal(listenEvent.Action.Instance, instance); err != nil {
log.Error("failed to unmarshal listen result: %v", err)
}
evt := events.NewTextileEvent(instance.Name)
h.notifier.SendTextileEvent(evt)
}