Monorepo for Tangled tangled.org
5

Configure Feed

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

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 RepoDid syntax.DID 18 19 GitRev syntax.TID // last processed git.refUpdate revision 20 RepoSha string // sha256 sum of git refs (to avoid no-op git fetch) 21 State RepoState 22 ErrorMsg string 23 RetryCount int 24 RetryAfter int64 // Unix timestamp (seconds) 25} 26 27func (r *Repo) AtUri() syntax.ATURI { 28 return syntax.ATURI(fmt.Sprintf("at://%s/%s/%s", r.Did, tangled.RepoNSID, r.Rkey)) 29} 30 31func (r *Repo) RepoIdentifier() string { 32 return r.RepoDid.String() 33} 34 35type RepoState string 36 37const ( 38 RepoStatePending RepoState = "pending" 39 RepoStateDesynchronized RepoState = "desynchronized" 40 RepoStateResyncing RepoState = "resyncing" 41 RepoStateActive RepoState = "active" 42 RepoStateSuspended RepoState = "suspended" 43 RepoStateError RepoState = "error" 44) 45 46var AllRepoStates = []RepoState{ 47 RepoStatePending, 48 RepoStateDesynchronized, 49 RepoStateResyncing, 50 RepoStateActive, 51 RepoStateSuspended, 52 RepoStateError, 53} 54 55func (s RepoState) IsResyncing() bool { 56 return s == RepoStateResyncing 57} 58 59type ObjectFormat string 60 61const ( 62 ObjectFormatSHA1 ObjectFormat = "sha1" 63 ObjectFormatSHA256 ObjectFormat = "sha256" 64) 65 66type HostCursor struct { 67 Hostname string 68 LastSeq int64 69} 70 71type Host struct { 72 Hostname string 73 NoSSL bool 74 Status HostStatus 75 LastSeq int64 76} 77 78type HostStatus string 79 80const ( 81 HostStatusActive HostStatus = "active" 82 HostStatusIdle HostStatus = "idle" 83 HostStatusOffline HostStatus = "offline" 84 HostStatusThrottled HostStatus = "throttled" 85 HostStatusBanned HostStatus = "banned" 86) 87 88var AllHostStatuses = []HostStatus{ 89 HostStatusActive, 90 HostStatusIdle, 91 HostStatusOffline, 92 HostStatusThrottled, 93 HostStatusBanned, 94} 95 96func (h *Host) URL() string { 97 if h.NoSSL { 98 return fmt.Sprintf("http://%s", h.Hostname) 99 } else { 100 return fmt.Sprintf("https://%s", h.Hostname) 101 } 102} 103 104func (h *Host) WsURL() string { 105 if h.NoSSL { 106 return fmt.Sprintf("ws://%s", h.Hostname) 107 } else { 108 return fmt.Sprintf("wss://%s", h.Hostname) 109 } 110} 111 112// func (h *Host) SubscribeGitRefsURL(cursor int64) string { 113// scheme := "wss" 114// if h.NoSSL { 115// scheme = "ws" 116// } 117// u := fmt.Sprintf("%s://%s/xrpc/%s", scheme, h.Hostname, tangled.SubscribeGitRefsNSID) 118// if cursor > 0 { 119// u = fmt.Sprintf("%s?cursor=%d", u, h.LastSeq) 120// } 121// return u 122// } 123 124func (h *Host) LegacyEventsURL(cursor int64) string { 125 u := fmt.Sprintf("%s/events", h.WsURL()) 126 if cursor > 0 { 127 u = fmt.Sprintf("%s?cursor=%d", u, cursor) 128 } 129 return u 130}