Delete records and stuff

This commit is contained in:
2026-02-12 11:43:52 -06:00
parent 200cb59b0e
commit 009d5701d2
6 changed files with 303 additions and 140 deletions

View File

@@ -23,12 +23,10 @@ package data
import (
"context"
"fmt"
"log/slog"
"time"
"git.bullercodeworks.com/brian/expds/data/models"
"github.com/bluesky-social/indigo/atproto/syntax"
"github.com/spf13/viper"
)
@@ -66,52 +64,6 @@ func NewRepo() (*Repo, error) {
return r, nil
}
func (r *Repo) fetchPds(atId string) (*models.Pds, error) {
p, err := models.NewPdsFromDid(atId)
if err != nil {
return nil, err
}
r.LoadedPDSs[atId] = p
return p, nil
}
func (r *Repo) ReloadPds(atId string) (*models.Pds, error) {
return r.fetchPds(atId)
}
func (r *Repo) GetPDS(atId string) (*models.Pds, error) {
if p, ok := r.LoadedPDSs[atId]; ok && time.Since(p.RefreshTime) < r.BestBy {
return p, nil
}
return r.fetchPds(atId)
}
func (r *Repo) SendToPDS(did syntax.DID) error {
session, err := r.Auth.GetSession(did)
if err != nil {
return err
}
c := session.APIClient()
body := map[string]any{
"repo": c.AccountDID.String(),
"collection": "com.bullercodeworks.expds.status",
"record": map[string]any{
"$type": "com.bullercodeworks.expds.status",
"text": "writeable",
"createdAt": syntax.DatetimeNow(),
},
}
var resp struct {
Uri syntax.ATURI `json:"uri"`
}
r.Logger.Debug("posting expds status...")
if err := c.Post(r.context, "com.atproto.repo.CreateRecord", body, &resp); err != nil {
return err
}
r.Logger.Debug(fmt.Sprintf("posted: %s :: %s", resp.Uri.Authority(), resp.Uri.RecordKey()))
return nil
}
func (r *Repo) SetLogFunc(l func(string, ...any)) {
r.logFunc = l
r.handler = NewAppLogHandler(r.logFunc)