A vibe coded tangled fork which supports pijul.
at dda7e5c4760ecd9809464b15499aa4c2bfc41d72 117 lines 2.5 kB view raw
1package models 2 3import ( 4 "fmt" 5 6 "github.com/bluesky-social/indigo/atproto/syntax" 7 "tangled.org/core/api/tangled" 8) 9 10type Repo struct { 11 Did syntax.DID 12 Rkey syntax.RecordKey 13 Cid *syntax.CID 14 // content of tangled.Repo 15 Name string 16 KnotDomain string 17 18 GitRev syntax.TID // last processed git.refUpdate revision 19 RepoSha string // sha256 sum of git refs (to avoid no-op git fetch) 20 State RepoState 21 ErrorMsg string 22 RetryCount int 23 RetryAfter int64 // Unix timestamp (seconds) 24} 25 26func (r *Repo) AtUri() syntax.ATURI { 27 return syntax.ATURI(fmt.Sprintf("at://%s/%s/%s", r.Did, tangled.RepoNSID, r.Rkey)) 28} 29 30func (r *Repo) DidSlashRepo() string { 31 return fmt.Sprintf("%s/%s", r.Did, r.Name) 32} 33 34type RepoState string 35 36const ( 37 RepoStatePending RepoState = "pending" 38 RepoStateDesynchronized RepoState = "desynchronized" 39 RepoStateResyncing RepoState = "resyncing" 40 RepoStateActive RepoState = "active" 41 RepoStateSuspended RepoState = "suspended" 42 RepoStateError RepoState = "error" 43) 44 45var AllRepoStates = []RepoState{ 46 RepoStatePending, 47 RepoStateDesynchronized, 48 RepoStateResyncing, 49 RepoStateActive, 50 RepoStateSuspended, 51 RepoStateError, 52} 53 54func (s RepoState) AllStates() []RepoState { 55 return []RepoState{ 56 RepoStatePending, 57 RepoStateDesynchronized, 58 RepoStateResyncing, 59 RepoStateActive, 60 RepoStateSuspended, 61 RepoStateError, 62 } 63} 64 65type HostCursor struct { 66 Hostname string 67 LastSeq int64 68} 69 70type Host struct { 71 Hostname string 72 NoSSL bool 73 Status HostStatus 74 LastSeq int64 75} 76 77type HostStatus string 78 79const ( 80 HostStatusActive HostStatus = "active" 81 HostStatusIdle HostStatus = "idle" 82 HostStatusOffline HostStatus = "offline" 83 HostStatusThrottled HostStatus = "throttled" 84 HostStatusBanned HostStatus = "banned" 85) 86 87var AllHostStatuses = []HostStatus{ 88 HostStatusActive, 89 HostStatusIdle, 90 HostStatusOffline, 91 HostStatusThrottled, 92 HostStatusBanned, 93} 94 95// func (h *Host) SubscribeGitRefsURL(cursor int64) string { 96// scheme := "wss" 97// if h.NoSSL { 98// scheme = "ws" 99// } 100// u := fmt.Sprintf("%s://%s/xrpc/%s", scheme, h.Hostname, tangled.SubscribeGitRefsNSID) 101// if cursor > 0 { 102// u = fmt.Sprintf("%s?cursor=%d", u, h.LastSeq) 103// } 104// return u 105// } 106 107func (h *Host) LegacyEventsURL(cursor int64) string { 108 scheme := "wss" 109 if h.NoSSL { 110 scheme = "ws" 111 } 112 u := fmt.Sprintf("%s://%s/events", scheme, h.Hostname) 113 if cursor > 0 { 114 u = fmt.Sprintf("%s?cursor=%d", u, cursor) 115 } 116 return u 117}