Live video on the AT Protocol
1package atproto
2
3import (
4 "context"
5 "fmt"
6 "strings"
7
8 "github.com/bluesky-social/indigo/atproto/lexicon"
9)
10
11func generatePermissionSets(ctx context.Context, lexs []*lexicon.SchemaFile) ([]*lexicon.SchemaFile, error) {
12 recordLexicons := []*lexicon.SchemaFile{}
13 for _, lex := range lexs {
14 main, ok := lex.Defs["main"]
15 if !ok {
16 continue
17 }
18 switch main.Inner.(type) {
19 case lexicon.SchemaRecord:
20 recordLexicons = append(recordLexicons, lex)
21 case lexicon.SchemaPermissionSet:
22 return nil, fmt.Errorf("unexpected permission set in `lexicons` directory: %s", lex.ID)
23 }
24 }
25
26 allRecords := []string{}
27 allCollectionStrings := []string{
28 "atproto",
29 "blob:*/*",
30 "repo?collection=app.bsky.feed.post&action=create",
31 "repo?collection=app.bsky.actor.status",
32 "repo?collection=app.bsky.graph.block",
33 "repo?collection=app.bsky.graph.follow",
34 "rpc:app.bsky.actor.getProfile?aud=did:web:api.bsky.app%23bsky_appview",
35 "rpc:app.bsky.actor.getProfiles?aud=did:web:api.bsky.app%23bsky_appview",
36 "include:place.stream.authFull",
37 "rpc:com.atproto.moderation.createReport?aud=*",
38 }
39 for _, record := range recordLexicons {
40 allRecords = append(allRecords, record.ID)
41 allCollectionStrings = append(allCollectionStrings, fmt.Sprintf("repo?collection=%s", record.ID))
42 }
43
44 OAuthString = strings.Join(allCollectionStrings, " ")
45 permissionSets := []*lexicon.SchemaFile{}
46
47 // place.stream.authFull
48 authFullTitle := "Full Streamplace Access"
49 authFullDetail := "Full access to all Streamplace features and data."
50 authFullSet := &lexicon.SchemaPermissionSet{
51 Type: "permission-set",
52 Title: &authFullTitle,
53 Detail: &authFullDetail,
54 Permissions: []lexicon.SchemaPermission{
55 {
56 Type: "permission",
57 Resource: "repo",
58 Collection: allRecords,
59 },
60 },
61 }
62 authFull := &lexicon.SchemaFile{
63 Lexicon: 1,
64 ID: "place.stream.authFull",
65 Defs: map[string]lexicon.SchemaDef{
66 "main": {
67 Inner: authFullSet,
68 },
69 },
70 }
71 permissionSets = append(permissionSets, authFull)
72
73 return permissionSets, nil
74}