tangled
alpha
login
or
join now
diffdown.com
/
diffdown-app
0
fork
atom
Diffdown is a real-time collaborative Markdown editor/previewer built on the AT Protocol
diffdown.com
0
fork
atom
overview
issues
10
pulls
pipelines
xrpc: add ListComments and UpdateComment methods
diffdown.com
2 weeks ago
b6625be6
bc4b1e20
+26
-4
1 changed file
expand all
collapse all
unified
split
internal
atproto
xrpc
client.go
+26
-4
internal/atproto/xrpc/client.go
reviewed
···
292
292
return nil
293
293
}
294
294
295
295
-
const collectionDocument = "com.diffdown.document"
296
296
-
297
295
// GetDocument fetches a document by its rkey.
298
296
func (c *Client) GetDocument(rkey string) (*model.Document, error) {
299
299
-
value, _, err := c.GetRecord(c.session.DID, collectionDocument, rkey)
297
297
+
value, _, err := c.GetRecord(c.session.DID, model.CollectionDocument, rkey)
300
298
if err != nil {
301
299
return nil, err
302
300
}
···
311
309
312
310
// PutDocument creates or updates a document.
313
311
func (c *Client) PutDocument(rkey string, doc *model.Document) (string, string, error) {
314
314
-
return c.PutRecord(collectionDocument, rkey, doc)
312
312
+
return c.PutRecord(model.CollectionDocument, rkey, doc)
313
313
+
}
314
314
+
315
315
+
// ListComments lists all comment records for a given document.
316
316
+
func (c *Client) ListComments(did, docRKey string, limit int, cursor string) ([]Record, string, error) {
317
317
+
records, nextCursor, err := c.ListRecords(did, model.CollectionComment, limit, cursor)
318
318
+
if err != nil {
319
319
+
return nil, "", err
320
320
+
}
321
321
+
var filtered []Record
322
322
+
for _, r := range records {
323
323
+
var comment model.CommentRecord
324
324
+
if err := json.Unmarshal(r.Value, &comment); err != nil {
325
325
+
continue
326
326
+
}
327
327
+
if comment.DocRKey == docRKey {
328
328
+
filtered = append(filtered, r)
329
329
+
}
330
330
+
}
331
331
+
return filtered, nextCursor, nil
332
332
+
}
333
333
+
334
334
+
// UpdateComment updates an existing comment record (e.g., for resolution toggle).
335
335
+
func (c *Client) UpdateComment(rkey string, record interface{}) (uri, cid string, err error) {
336
336
+
return c.PutRecord(model.CollectionComment, rkey, record)
315
337
}