package models import ( "bytes" "log/slog" "time" appbsky "github.com/bluesky-social/indigo/api/bsky" "github.com/bluesky-social/indigo/atproto/syntax" ) type FeedGenerator struct { ID string `gorm:"primaryKey"` // TODO: Avatar, DescriptionFacets AcceptsInteractions *bool ContentMode *string CreatedAt string Description *string Did string DisplayName string Labels []FeedGenerator_Label AutoCreatedAt time.Time `gorm:"autoCreateTime"` AutoUpdatedAt time.Time `gorm:"autoUpdateTime"` } type FeedGenerator_Label struct { FeedGeneratorID string Value string } func NewFeedGenerator(uri syntax.ATURI, rec []byte) *FeedGenerator { var out appbsky.FeedGenerator if err := out.UnmarshalCBOR(bytes.NewReader(rec)); err != nil { slog.Error("could not unmarshal feed generator CBOR", "err", err) return nil } feedgen := FeedGenerator{ ID: string(uri), AcceptsInteractions: out.AcceptsInteractions, ContentMode: out.ContentMode, CreatedAt: out.CreatedAt, Description: out.Description, Did: out.Did, DisplayName: out.DisplayName, } if out.Labels != nil && out.Labels.LabelDefs_SelfLabels != nil && out.Labels.LabelDefs_SelfLabels.Values != nil { for _, label := range out.Labels.LabelDefs_SelfLabels.Values { feedgen.Labels = append(feedgen.Labels, FeedGenerator_Label{ FeedGeneratorID: feedgen.ID, Value: label.Val, }) } } return &feedgen }