An open source supporter broker powered by high-fives. high-five.atprotofans.com/
at main 187 lines 6.7 kB view raw
1package atproto 2 3const ( 4 LexiconSupport = "com.atprotofans.high-five.support" 5 LexiconSupportProof = "com.atprotofans.high-five.supportProof" 6 LexiconBrokerProof = "com.atprotofans.high-five.brokerProof" 7 LexiconActorStatus = "app.bsky.actor.status" 8 LexiconFeedPost = "app.bsky.feed.post" 9 LexiconFacetLink = "app.bsky.richtext.facet#link" 10 LexiconFacetMention = "app.bsky.richtext.facet#mention" 11 12 // New lexicons for one-big-room model 13 LexiconHighFive = "com.atprotofans.high-five.highFive" 14 LexiconHighFiveProof = "com.atprotofans.high-five.highFiveProof" 15) 16 17// StrongRef is a reference to a specific version of a record. 18type StrongRef struct { 19 Type string `json:"$type" cbor:"$type"` 20 URI string `json:"uri" cbor:"uri"` 21 CID string `json:"cid" cbor:"cid"` 22} 23 24// Support is the main high-five record created in the recipient's repository. 25type Support struct { 26 Type string `json:"$type" cbor:"$type"` 27 Subject string `json:"subject" cbor:"subject"` 28 TxnID string `json:"txnid" cbor:"txnid"` 29 CreatedAt string `json:"createdAt" cbor:"createdAt"` 30 Signatures []StrongRef `json:"signatures,omitempty" cbor:"signatures,omitempty"` 31} 32 33// SupportContent is the content that gets hashed for the supportProof CID. 34type SupportContent struct { 35 Type string `json:"$type" cbor:"$type"` 36 Subject string `json:"subject" cbor:"subject"` 37 TxnID string `json:"txnid" cbor:"txnid"` 38 CreatedAt string `json:"createdAt" cbor:"createdAt"` 39 Sig SupportProofSig `json:"$sig" cbor:"$sig"` 40} 41 42// SupportProofSig is the signature portion of the support content. 43type SupportProofSig struct { 44 Type string `json:"$type" cbor:"$type"` 45 Repository string `json:"repository" cbor:"repository"` 46} 47 48// SupportProof is the proof record created in the supporter's repository. 49type SupportProof struct { 50 Type string `json:"$type" cbor:"$type"` 51 CID string `json:"cid" cbor:"cid"` 52} 53 54// BrokerContent is the content that gets hashed for the brokerProof CID. 55type BrokerContent struct { 56 Type string `json:"$type" cbor:"$type"` 57 Subject string `json:"subject" cbor:"subject"` 58 TxnID string `json:"txnid" cbor:"txnid"` 59 CreatedAt string `json:"createdAt" cbor:"createdAt"` 60 Sig BrokerProofSig `json:"$sig" cbor:"$sig"` 61} 62 63// BrokerProofSig is the signature portion of the broker content. 64type BrokerProofSig struct { 65 Type string `json:"$type" cbor:"$type"` 66 Repository string `json:"repository" cbor:"repository"` 67} 68 69// BrokerProof is the proof record created in the broker's repository. 70type BrokerProof struct { 71 Type string `json:"$type" cbor:"$type"` 72 CID string `json:"cid" cbor:"cid"` 73} 74 75// HighFive is the main record created by the identity giving the high-five. 76// Created in the giver's repository under com.atprotofans.high-five.highFive collection. 77type HighFive struct { 78 Type string `json:"$type" cbor:"$type"` 79 TxnID string `json:"txnid" cbor:"txnid"` 80 Subject string `json:"subject" cbor:"subject"` // DID of recipient 81 CreatedAt string `json:"createdAt" cbor:"createdAt"` 82 Signatures []StrongRef `json:"signatures,omitempty" cbor:"signatures,omitempty"` 83} 84 85// HighFiveContent is used for computing the content CID for high-five proofs. 86type HighFiveContent struct { 87 Type string `json:"$type" cbor:"$type"` 88 TxnID string `json:"txnid" cbor:"txnid"` 89 Subject string `json:"subject" cbor:"subject"` 90 CreatedAt string `json:"createdAt" cbor:"createdAt"` 91 Sig HighFiveProofSig `json:"$sig" cbor:"$sig"` 92} 93 94// HighFiveProofSig is the signature portion of the high-five content. 95type HighFiveProofSig struct { 96 Type string `json:"$type" cbor:"$type"` 97 Repository string `json:"repository" cbor:"repository"` // DID of high-five giver 98} 99 100// HighFiveProof is the proof record created in the recipient's repository. 101type HighFiveProof struct { 102 Type string `json:"$type" cbor:"$type"` 103 CID string `json:"cid" cbor:"cid"` 104} 105 106// ActorStatus represents the app.bsky.actor.status record. 107type ActorStatus struct { 108 Type string `json:"$type"` 109 Status string `json:"status"` 110 CreatedAt string `json:"createdAt"` 111 DurationMinutes *int `json:"durationMinutes,omitempty"` 112 Embed *ActorStatusEmbed `json:"embed,omitempty"` 113} 114 115// ActorStatusEmbed represents an embed in the actor status. 116type ActorStatusEmbed struct { 117 Type string `json:"$type"` 118 External ActorStatusEmbedExternal `json:"external"` 119} 120 121// ActorStatusEmbedExternal represents the external link in an embed. 122type ActorStatusEmbedExternal struct { 123 URI string `json:"uri"` 124 Title string `json:"title"` 125 Description string `json:"description"` 126} 127 128// CreateRecordRequest is the request body for com.atproto.repo.createRecord. 129type CreateRecordRequest struct { 130 Repo string `json:"repo"` 131 Collection string `json:"collection"` 132 RKey string `json:"rkey,omitempty"` 133 Record interface{} `json:"record"` 134} 135 136// CreateRecordResponse is the response from com.atproto.repo.createRecord. 137type CreateRecordResponse struct { 138 URI string `json:"uri"` 139 CID string `json:"cid"` 140} 141 142// DeleteRecordRequest is the request body for com.atproto.repo.deleteRecord. 143type DeleteRecordRequest struct { 144 Repo string `json:"repo"` 145 Collection string `json:"collection"` 146 RKey string `json:"rkey"` 147} 148 149// FeedPost represents an app.bsky.feed.post record. 150type FeedPost struct { 151 Type string `json:"$type"` 152 Text string `json:"text"` 153 CreatedAt string `json:"createdAt"` 154 Facets []PostFacet `json:"facets,omitempty"` 155 Reply *PostReply `json:"reply,omitempty"` 156} 157 158// PostReply contains references for reply threading. 159type PostReply struct { 160 Root PostRef `json:"root"` 161 Parent PostRef `json:"parent"` 162} 163 164// PostRef is a reference to a post (used in replies). 165type PostRef struct { 166 URI string `json:"uri"` 167 CID string `json:"cid"` 168} 169 170// PostFacet represents a rich text facet in a post. 171type PostFacet struct { 172 Index FacetIndex `json:"index"` 173 Features []FacetFeature `json:"features"` 174} 175 176// FacetIndex specifies the byte range for a facet. 177type FacetIndex struct { 178 ByteStart int `json:"byteStart"` 179 ByteEnd int `json:"byteEnd"` 180} 181 182// FacetFeature represents a feature in a facet (e.g., link, mention). 183type FacetFeature struct { 184 Type string `json:"$type"` 185 URI string `json:"uri,omitempty"` // For links 186 DID string `json:"did,omitempty"` // For mentions 187}