+2
-2
automod/consumer/firehose.go
+2
-2
automod/consumer/firehose.go
···
144
144
145
145
for _, op := range evt.Ops {
146
146
logger = logger.With("eventKind", op.Action, "path", op.Path)
147
-
collection, rkey, err := splitRepoPath(op.Path)
147
+
collection, rkey, err := syntax.ParseRepoPath(op.Path)
148
148
if err != nil {
149
-
logger.Error("invalid path in repo op")
149
+
logger.Error("invalid path in repo op", "err", err)
150
150
return nil
151
151
}
152
152
-25
automod/consumer/util.go
-25
automod/consumer/util.go
···
1
-
package consumer
2
-
3
-
import (
4
-
"fmt"
5
-
"strings"
6
-
7
-
"github.com/bluesky-social/indigo/atproto/syntax"
8
-
)
9
-
10
-
// TODO: move this to a "ParsePath" helper in syntax package?
11
-
func splitRepoPath(path string) (syntax.NSID, syntax.RecordKey, error) {
12
-
parts := strings.SplitN(path, "/", 3)
13
-
if len(parts) != 2 {
14
-
return "", "", fmt.Errorf("invalid record path: %s", path)
15
-
}
16
-
collection, err := syntax.ParseNSID(parts[0])
17
-
if err != nil {
18
-
return "", "", err
19
-
}
20
-
rkey, err := syntax.ParseRecordKey(parts[1])
21
-
if err != nil {
22
-
return "", "", err
23
-
}
24
-
return collection, rkey, nil
25
-
}
+1
-19
cmd/beemo/firehose_consumer.go
+1
-19
cmd/beemo/firehose_consumer.go
···
7
7
"log/slog"
8
8
"net/http"
9
9
"net/url"
10
-
"strings"
11
10
12
11
comatproto "github.com/bluesky-social/indigo/api/atproto"
13
12
appbsky "github.com/bluesky-social/indigo/api/bsky"
···
60
59
return events.HandleRepoStream(ctx, con, scheduler, logger)
61
60
}
62
61
63
-
// TODO: move this to a "ParsePath" helper in syntax package?
64
-
func splitRepoPath(path string) (syntax.NSID, syntax.RecordKey, error) {
65
-
parts := strings.SplitN(path, "/", 3)
66
-
if len(parts) != 2 {
67
-
return "", "", fmt.Errorf("invalid record path: %s", path)
68
-
}
69
-
collection, err := syntax.ParseNSID(parts[0])
70
-
if err != nil {
71
-
return "", "", err
72
-
}
73
-
rkey, err := syntax.ParseRecordKey(parts[1])
74
-
if err != nil {
75
-
return "", "", err
76
-
}
77
-
return collection, rkey, nil
78
-
}
79
-
80
62
// NOTE: for now, this function basically never errors, just logs and returns nil. Should think through error processing better.
81
63
func HandleRepoCommit(ctx context.Context, logger *slog.Logger, evt *comatproto.SyncSubscribeRepos_Commit, postCallback func(context.Context, syntax.DID, syntax.RecordKey, appbsky.FeedPost) error) error {
82
64
···
102
84
103
85
for _, op := range evt.Ops {
104
86
logger = logger.With("eventKind", op.Action, "path", op.Path)
105
-
collection, rkey, err := splitRepoPath(op.Path)
87
+
collection, rkey, err := syntax.ParseRepoPath(op.Path)
106
88
if err != nil {
107
89
logger.Error("invalid path in repo op")
108
90
return nil
+1
-18
cmd/goat/firehose.go
+1
-18
cmd/goat/firehose.go
···
133
133
return events.HandleRepoStream(ctx, con, scheduler, nil)
134
134
}
135
135
136
-
// TODO: move this to a "ParsePath" helper in syntax package?
137
-
func splitRepoPath(path string) (syntax.NSID, syntax.RecordKey, error) {
138
-
parts := strings.SplitN(path, "/", 3)
139
-
if len(parts) != 2 {
140
-
return "", "", fmt.Errorf("invalid record path: %s", path)
141
-
}
142
-
collection, err := syntax.ParseNSID(parts[0])
143
-
if err != nil {
144
-
return "", "", err
145
-
}
146
-
rkey, err := syntax.ParseRecordKey(parts[1])
147
-
if err != nil {
148
-
return "", "", err
149
-
}
150
-
return collection, rkey, nil
151
-
}
152
-
153
136
func (gfc *GoatFirehoseConsumer) handleIdentityEvent(ctx context.Context, evt *comatproto.SyncSubscribeRepos_Identity) error {
154
137
out := make(map[string]interface{})
155
138
out["type"] = "identity"
···
229
212
}
230
213
231
214
for _, op := range evt.Ops {
232
-
collection, rkey, err := splitRepoPath(op.Path)
215
+
collection, rkey, err := syntax.ParseRepoPath(op.Path)
233
216
if err != nil {
234
217
logger.Error("invalid path in repo op", "eventKind", op.Action, "path", op.Path)
235
218
return nil