an app.bsky.* indexer
1package models
2
3import (
4 "bytes"
5 "log/slog"
6 "time"
7
8 chatbsky "github.com/bluesky-social/indigo/api/chat"
9 "github.com/bluesky-social/indigo/atproto/syntax"
10)
11
12type ActorDeclaration struct {
13 ID string `gorm:"primaryKey"`
14
15 AllowIncoming string
16
17 AutoCreatedAt time.Time `gorm:"autoCreateTime"`
18 AutoUpdatedAt time.Time `gorm:"autoUpdateTime"`
19}
20
21func NewActorDeclaration(uri syntax.ATURI, rec []byte) *ActorDeclaration {
22 var out chatbsky.ActorDeclaration
23 if err := out.UnmarshalCBOR(bytes.NewReader(rec)); err != nil {
24 slog.Error("could not unmarshal chat actor declaration CBOR", "err", err)
25 return nil
26 }
27
28 return &ActorDeclaration{
29 ID: string(uri),
30 AllowIncoming: out.AllowIncoming,
31 }
32}