A vibe coded tangled fork which supports pijul.
at sl/tap-appview 68 lines 1.3 kB view raw
1package models 2 3import ( 4 "fmt" 5 "time" 6 7 "github.com/bluesky-social/indigo/atproto/syntax" 8 "tangled.org/core/api/tangled" 9) 10 11type Follow struct { 12 UserDid string 13 SubjectDid string 14 FollowedAt time.Time 15 Rkey string 16} 17 18func (f *Follow) AsRecord() tangled.GraphFollow { 19 return tangled.GraphFollow{ 20 Subject: f.SubjectDid, 21 CreatedAt: f.FollowedAt.Format(time.RFC3339), 22 } 23} 24 25func FollowFromRecord(did syntax.DID, rkey syntax.RecordKey, record tangled.GraphFollow) (Follow, error) { 26 subjectDid, err := syntax.ParseDID(record.Subject) 27 if err != nil { 28 return Follow{}, fmt.Errorf("subject should be valid did: %w", err) 29 } 30 31 created, err := time.Parse(time.RFC3339, record.CreatedAt) 32 if err != nil { 33 return Follow{}, fmt.Errorf("invalid time format '%s'", record.CreatedAt) 34 } 35 36 return Follow{ 37 UserDid: did.String(), 38 Rkey: rkey.String(), 39 SubjectDid: subjectDid.String(), 40 FollowedAt: created, 41 }, nil 42} 43 44type FollowStats struct { 45 Followers int64 46 Following int64 47} 48 49type FollowStatus int 50 51const ( 52 IsNotFollowing FollowStatus = iota 53 IsFollowing 54 IsSelf 55) 56 57func (s FollowStatus) String() string { 58 switch s { 59 case IsNotFollowing: 60 return "IsNotFollowing" 61 case IsFollowing: 62 return "IsFollowing" 63 case IsSelf: 64 return "IsSelf" 65 default: 66 return "IsNotFollowing" 67 } 68}