forked from
tangled.org/core
Monorepo for Tangled
1package tap
2
3import (
4 "encoding/json"
5 "fmt"
6
7 "github.com/bluesky-social/indigo/atproto/syntax"
8)
9
10type EventType string
11
12const (
13 EvtRecord EventType = "record"
14 EvtIdentity EventType = "identity"
15)
16
17type Event struct {
18 ID int64 `json:"id"`
19 Type EventType `json:"type"`
20 Record *RecordEventData `json:"record,omitempty"`
21 Identity *IdentityEventData `json:"identity,omitempty"`
22}
23
24type RecordEventData struct {
25 Live bool `json:"live"`
26 Did syntax.DID `json:"did"`
27 Rev string `json:"rev"`
28 Collection syntax.NSID `json:"collection"`
29 Rkey syntax.RecordKey `json:"rkey"`
30 Action RecordAction `json:"action"`
31 Record json.RawMessage `json:"record,omitempty"`
32 CID *syntax.CID `json:"cid,omitempty"`
33}
34
35func (r *RecordEventData) AtUri() syntax.ATURI {
36 return syntax.ATURI(fmt.Sprintf("at://%s/%s/%s", r.Did, r.Collection, r.Rkey))
37}
38
39type RecordAction string
40
41const (
42 RecordCreateAction RecordAction = "create"
43 RecordUpdateAction RecordAction = "update"
44 RecordDeleteAction RecordAction = "delete"
45)
46
47type IdentityEventData struct {
48 DID syntax.DID `json:"did"`
49 Handle string `json:"handle"`
50 IsActive bool `json:"is_active"`
51 Status RepoStatus `json:"status"`
52}
53
54type RepoStatus string
55
56const (
57 RepoStatusActive RepoStatus = "active"
58 RepoStatusTakendown RepoStatus = "takendown"
59 RepoStatusSuspended RepoStatus = "suspended"
60 RepoStatusDeactivated RepoStatus = "deactivated"
61 RepoStatusDeleted RepoStatus = "deleted"
62)