this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add verbose logging to palomar handle updates (#384)

This change adds verbose logging to Palomar handle updates and resolves
handles from PLC when seeing an update instead of trusting the handle
from the event.

authored by

Jaz and committed by
GitHub
adea82ed a38a41d8

+26 -5
+6 -1
search/firehose.go
··· 153 153 154 154 }, 155 155 RepoHandle: func(evt *comatproto.SyncSubscribeRepos_Handle) error { 156 - if err := s.updateUserHandle(ctx, evt.Did, evt.Handle); err != nil { 156 + did, err := syntax.ParseDID(evt.Did) 157 + if err != nil { 158 + s.logger.Error("bad DID in RepoHandle event", "did", evt.Did, "handle", evt.Handle, "seq", evt.Seq, "err", err) 159 + return nil 160 + } 161 + if err := s.updateUserHandle(ctx, did, evt.Handle); err != nil { 157 162 // TODO: handle this case (instead of return nil) 158 163 s.logger.Error("failed to update user handle", "did", evt.Did, "handle", evt.Handle, "seq", evt.Seq, "err", err) 159 164 }
+20 -4
search/indexing.go
··· 11 11 12 12 appbsky "github.com/bluesky-social/indigo/api/bsky" 13 13 "github.com/bluesky-social/indigo/atproto/identity" 14 + "github.com/bluesky-social/indigo/atproto/syntax" 14 15 "github.com/bluesky-social/indigo/util" 15 16 "github.com/ipfs/go-cid" 16 17 ··· 132 133 return nil 133 134 } 134 135 135 - func (s *Server) updateUserHandle(ctx context.Context, did, handle string) error { 136 - log := s.logger.With("repo", did, "op", "updateUserHandle", "handle", handle) 136 + func (s *Server) updateUserHandle(ctx context.Context, did syntax.DID, handle string) error { 137 + log := s.logger.With("repo", did.String(), "op", "updateUserHandle", "handle_from_event", handle) 138 + 139 + err := s.dir.Purge(ctx, did.AtIdentifier()) 140 + if err != nil { 141 + log.Warn("failed to purge DID from directory", "err", err) 142 + return err 143 + } 144 + 145 + ident, err := s.dir.LookupDID(ctx, did) 146 + if err != nil { 147 + log.Warn("failed to lookup DID in directory", "err", err) 148 + return err 149 + } 150 + 151 + log.Info("updating user handle", "handle_from_dir", handle) 152 + 137 153 b, err := json.Marshal(map[string]any{ 138 154 "script": map[string]any{ 139 155 "source": "ctx._source.handle = params.handle", 140 156 "lang": "painless", 141 157 "params": map[string]any{ 142 - "handle": handle, 158 + "handle": ident.Handle, 143 159 }, 144 160 }, 145 161 }) ··· 150 166 151 167 req := esapi.UpdateRequest{ 152 168 Index: s.profileIndex, 153 - DocumentID: did, 169 + DocumentID: did.String(), 154 170 Body: bytes.NewReader(b), 155 171 } 156 172