Get an ever updating ics link for all the events you RSVP to on the Atmosphere
whenslunch.app
1.6 kB
52 lines
1package listener
2
3import (
4 _ "embed"
5 "encoding/json"
6 "fmt"
7
8 comatproto "github.com/bluesky-social/indigo/api/atproto"
9 "github.com/klauspost/compress/zstd"
10)
11
12//go:embed zstd_dictionary
13var ZSTDDictionary []byte
14
15func NewZSTDDecoder() (*zstd.Decoder, error) {
16 dec, err := zstd.NewReader(nil, zstd.WithDecoderDicts(ZSTDDictionary))
17 if err != nil {
18 return nil, fmt.Errorf("failed to create zstd decoder: %w", err)
19 }
20 return dec, nil
21}
22
23type Event struct {
24 Did string `json:"did"`
25 TimeUS int64 `json:"time_us"`
26 Kind string `json:"kind,omitempty"`
27 Commit *Commit `json:"commit,omitempty"`
28 Account *comatproto.SyncSubscribeRepos_Account `json:"account,omitempty"`
29 Identity *comatproto.SyncSubscribeRepos_Identity `json:"identity,omitempty"`
30}
31
32type Commit struct {
33 Rev string `json:"rev,omitempty"`
34 Operation string `json:"operation,omitempty"`
35 Collection string `json:"collection,omitempty"`
36 RKey string `json:"rkey,omitempty"`
37 Record json.RawMessage `json:"record,omitempty"`
38 CID string `json:"cid,omitempty"`
39}
40
41var (
42 EventKindCommit = "commit"
43 EventKindAccount = "account"
44 EventKindIdentity = "identity"
45
46 CommitOperationCreate = "create"
47 CommitOperationUpdate = "update"
48 CommitOperationDelete = "delete"
49
50 CollectionCalendarEvent = "community.lexicon.calendar.event"
51 CollectionCalendarRsvp = "community.lexicon.calendar.rsvp"
52)