GoAT Site is library that implements Standard.site in Go.
atprotocol standard-site atproto library
1
fork

Configure Feed

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

feat(blob): supports CID

+15 -22
+2 -1
README.md
··· 8 8 9 9 ## Usage 10 10 11 - > [!NOTE] Check [anhgelus.world/xrpc's documentation](https://tangled.org/anhgelus.world/xrpc) first! 11 + > [!NOTE] 12 + > Check [anhgelus.world/xrpc's documentation](https://tangled.org/anhgelus.world/xrpc) first! 12 13 13 14 Get the module with: 14 15 ```bash
-5
document_test.go
··· 34 34 publishedAt := genTime(t, "published_at") 35 35 path := genPath(t, "path") 36 36 description := rapid.StringN(0, 3_000, 30_000).Draw(t, "description") 37 - coverImage, coverImageRaw := genBlob(t, "image", "cover_image") 38 37 textContent := rapid.String().Draw(t, "text_content") 39 38 tags := rapid.SliceOfN(rapid.String(), 0, 1280).Draw(t, "tags") 40 39 updatedAt := genTime(t, "updated_at") ··· 45 44 "publishedAt": publishedAt.Format(atproto.TimeFormat), 46 45 "path": path, 47 46 "description": description, 48 - "coverImage": coverImageRaw, 49 47 "content": json.RawMessage(`{"$type":"pub.leaflet.content","pages":[{"$type":"pub.leaflet.pages.linearDocument","blocks":[{"$type":"pub.leaflet.pages.linearDocument#block","block":{"$type":"pub.leaflet.blocks.text","plaintext":"hiiiiiiiii"}}],"id":"019d1297-2fdd-733b-9837-911e1758f300"}]}`), 50 48 "textContent": textContent, 51 49 "bskyPostRef": json.RawMessage(`{"cid":"bafyreidepvhssy3zglq3bo4nauszqhqmbk6lzzfay3r2nskvijyiewlr2u","commit":{"cid":"bafyreickwfv4p2jr6zvbdk6mldmddag2m6grpkbbvkvz57mvaqso5dpf5e","rev":"3mhm4oeyyzi2g"},"uri":"at://did:plc:jdhpqeb4cb4mng533dx56cbc/app.bsky.feed.post/3mhm4oevhmk2d","validationStatus":"valid"}`), ··· 76 74 } 77 75 if !doc.PublishedAt.Equal(publishedAt) { 78 76 t.Errorf("invalid publishedAt: %s, wanted %s", doc.PublishedAt, publishedAt) 79 - } 80 - if *doc.CoverImage != *coverImage { 81 - t.Errorf("invalid cover image: %v, wanted %v", *doc.CoverImage, *coverImage) 82 77 } 83 78 if *doc.Path != path { 84 79 t.Errorf("invalid path: %s, wanted %s", *doc.Path, path)
+13 -11
lexicons_test.go
··· 1 1 package site_test 2 2 3 3 import ( 4 + "crypto/sha256" 4 5 "net" 5 6 "net/http" 6 7 "time" ··· 14 15 rapidLowerRunes = rapid.RuneFrom([]rune("abcdefghijklmnopqrstuvwxyz")) 15 16 ) 16 17 17 - func genBlob(t *rapid.T, baseMime, label string) (*xrpc.Blob, map[string]any) { 18 - blob := &xrpc.Blob{ 19 - CID: rapid.StringN(2, -1, 128).Draw(t, label+"_cid"), 20 - MimeType: baseMime + "/" + 21 - rapid.StringOfN(rapidLowerRunes, 2, 20, -1).Draw(t, label+"_mimeType"), 22 - Size: rapid.UintMin(1).Draw(t, label+"_size"), 18 + func genCID(t *rapid.T, label string) *atproto.CID { 19 + cid := &atproto.CID{ 20 + Version: atproto.CIDVersion, 21 + Codec: atproto.CIDCodecRaw, 22 + HashType: atproto.CIDHashSha256, 23 + HashSize: 32, 23 24 } 24 - return blob, map[string]any{ 25 - "$type": blob.Collection(), 26 - "ref": map[string]any{"$link": blob.CID}, 27 - "mimeType": blob.MimeType, 28 - "size": blob.Size, 25 + str := rapid.StringN(64, -1, -1).Draw(t, label) 26 + cp := make([]byte, 32) 27 + for i, v := range sha256.Sum256([]byte(str)) { 28 + cp[i] = v 29 29 } 30 + cid.Digest = cp 31 + return cid 30 32 } 31 33 32 34 var dir *atproto.Directory
-5
publication_test.go
··· 38 38 func TestPublication_JSON(t *testing.T) { 39 39 rapid.Check(t, func(t *rapid.T) { 40 40 theme, themeRaw := genBasicTheme(t) 41 - icon, iconRaw := genBlob(t, "image", "icon") 42 41 description := rapid.StringN(2, 3_000, 30_000).Draw(t, "description") 43 42 name := rapid.StringN(2, 500, 5_000).Draw(t, "name") 44 43 url := genURL(t, "url") ··· 46 45 input := map[string]any{ 47 46 "$type": site.CollectionPublication, 48 47 "basicTheme": themeRaw, 49 - "icon": iconRaw, 50 48 "description": description, 51 49 "name": name, 52 50 "url": url, ··· 70 68 } 71 69 if *pub.Description != description { 72 70 t.Errorf("invalid description: %s, wanted %s", *pub.Description, description) 73 - } 74 - if *pub.Icon != *icon { 75 - t.Errorf("invalid icon: %v, wanted %v", *pub.Icon, *icon) 76 71 } 77 72 if pub.Preferences.ShowInDiscover != showInDiscover { 78 73 t.Errorf("invalid Preferences ShowInDiscover: %v", pub.Preferences.ShowInDiscover)