Skip to content

Commit

Permalink
feat(event): add StorageObjectUnpinnedEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
pcfreak30 committed Sep 18, 2024
1 parent 0dcce36 commit 5e2f890
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions event/storage_unpin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package event

import (
"go.lumeweb.com/portal/core"
"go.lumeweb.com/portal/db/models"
)

const (
EVENT_STORAGE_OBJECT_UNPINNED = "storage.object.unpinned"
)

func init() {
core.RegisterEvent(EVENT_STORAGE_OBJECT_UNPINNED, &StorageObjectPinnedEvent{})
}

type StorageObjectUnpinnedEvent struct {
core.Event
}

func (e *StorageObjectUnpinnedEvent) SetPin(metadata *models.Pin) {
e.Set("pin", metadata)
}

func (e StorageObjectUnpinnedEvent) Pin() *models.Pin {
return e.Get("pin").(*models.Pin)
}
func (e StorageObjectUnpinnedEvent) IP() string {
return e.Get("ip").(string)
}

func FireStorageObjectUnpinnedEvent(ctx core.Context, pin *models.Pin) error {
return Fire[*StorageObjectPinnedEvent](ctx, EVENT_STORAGE_OBJECT_UNPINNED, func(evt *StorageObjectPinnedEvent) error {
evt.SetPin(pin)
return nil
})
}

0 comments on commit 5e2f890

Please sign in to comment.